closest so far!

This commit is contained in:
Alx-Ai 2025-06-05 07:42:20 +00:00
parent 8521881c9d
commit 30849a36e4
4 changed files with 43 additions and 24 deletions

View file

@ -5,6 +5,12 @@ export const config = {
// Default speed in milliseconds for animations and transitions
playbackSpeed: 500,
// Streaming mode specific timing
get streamingPlaybackSpeed(): number {
const isStreamingMode = import.meta.env.VITE_STREAMING_MODE === 'True' || import.meta.env.VITE_STREAMING_MODE === 'true';
return isStreamingMode ? 1000 : this.playbackSpeed; // Slower for streaming
},
// Whether to enable debug mode (faster animations, more console logging)
isDebugMode: import.meta.env.VITE_DEBUG_MODE === 'true' || import.meta.env.VITE_DEBUG_MODE === 'True',
@ -59,7 +65,7 @@ export const config = {
* Get effective playback speed (minimal if instant mode, normal speed otherwise)
*/
get effectivePlaybackSpeed(): number {
return this.isInstantMode ? 10 : this.playbackSpeed;
return this.isInstantMode ? 10 : this.streamingPlaybackSpeed;
},
// Animation timing configuration

View file

@ -231,7 +231,10 @@ export function updateChatWindows(phase: any, stepMessages = false) {
index++; // Only increment after animation completes
// Schedule next message with proper delay
setTimeout(showNext, config.effectivePlaybackSpeed / 2);
// In streaming mode, add extra delay to prevent message overlap
const isStreamingMode = import.meta.env.VITE_STREAMING_MODE === 'True' || import.meta.env.VITE_STREAMING_MODE === 'true';
const messageDelay = isStreamingMode ? config.effectivePlaybackSpeed : config.effectivePlaybackSpeed / 2;
setTimeout(showNext, messageDelay);
};
// Add the message with word animation
@ -394,7 +397,10 @@ function animateMessageWords(message: string, contentSpanId: string, targetPower
// Calculate delay based on word length and playback speed
// Longer words get slightly longer display time
const wordLength = words[wordIndex - 1].length;
const delay = Math.max(30, Math.min(120, config.effectivePlaybackSpeed / 10 * (wordLength / 4)));
// In streaming mode, use a more consistent delay to prevent overlap
const isStreamingMode = import.meta.env.VITE_STREAMING_MODE === 'True' || import.meta.env.VITE_STREAMING_MODE === 'true';
const baseDelay = isStreamingMode ? 150 : config.effectivePlaybackSpeed / 10;
const delay = Math.max(50, Math.min(200, baseDelay * (wordLength / 4)));
setTimeout(addNextWord, delay);
// Scroll to ensure newest content is visible

View file

@ -79,7 +79,7 @@ function initScene() {
if (isStreamingMode) {
setTimeout(() => {
togglePlayback()
}, 2000)
}, 5000) // Increased delay to 5 seconds for Chrome to stabilize
}
})
}).catch(err => {

View file

@ -279,8 +279,14 @@ export function advanceToNextPhase() {
console.log(`Processing phase transition for ${currentPhase.name}`);
}
// In streaming mode, add extra delay before speech to ensure phase is fully displayed
const isStreamingMode = import.meta.env.VITE_STREAMING_MODE === 'True' || import.meta.env.VITE_STREAMING_MODE === 'true';
const speechDelay = isStreamingMode ? 2000 : 0; // 2 second delay in streaming mode
// First show summary if available
if (currentPhase.summary && currentPhase.summary.trim() !== '') {
// Delay speech in streaming mode
setTimeout(() => {
// Speak the summary and advance after
if (!gameState.isSpeaking) {
speakSummary(currentPhase.summary)
@ -296,11 +302,12 @@ export function advanceToNextPhase() {
nextPhase();
}
}).finally(() => {
// Any cleanup code here
});
} else {
console.error("Attempted to start speaking when already speaking...")
console.error("Attempted to start speaking when already speaking...");
}
}, speechDelay);
} else {
console.log("No summary available, skipping speech");
// No summary to speak, advance immediately