From 4e0f868261b7eddc1a06b5dd1b52ab4542a61fff Mon Sep 17 00:00:00 2001 From: Eric Wheeler Date: Sat, 8 Mar 2025 18:41:51 -0800 Subject: [PATCH] fix: improve error handling when start sequence not received but stream started When VSCE start sequence (]633;C or ]133;C) is not received, but the stream has started: - Emit no_shell_integration event with clear error message - Include preOutput in completed event for bug reporting - Call continue() to ensure proper cleanup - Return early to prevent further processing This helps diagnose potential upstream VSCE bugs by providing more context in the error messages and ensuring proper cleanup of terminal state. Signed-off-by: Eric Wheeler --- src/integrations/terminal/TerminalProcess.ts | 23 +++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/integrations/terminal/TerminalProcess.ts b/src/integrations/terminal/TerminalProcess.ts index c80014f0cb..c5e1c901b5 100644 --- a/src/integrations/terminal/TerminalProcess.ts +++ b/src/integrations/terminal/TerminalProcess.ts @@ -393,10 +393,27 @@ export class TerminalProcess extends EventEmitter { // Emit any remaining output before completing this.emitRemainingBufferIfListening() } else { - console.error( - "[Terminal Process] VSCE output start escape sequence (]633;C or ]133;C) not received! VSCE Bug? preOutput: " + - inspect(preOutput, { colors: false, breakLength: Infinity }), + const errorMsg = + "VSCE output start escape sequence (]633;C or ]133;C) not received, but the stream has started. Upstream VSCE Bug?" + + const inspectPreOutput = inspect(preOutput, { colors: false, breakLength: Infinity }) + console.error(`[Terminal Process] ${errorMsg} preOutput: ${inspectPreOutput}`) + + // Emit no_shell_integration event + this.emit("no_shell_integration", errorMsg) + + // Emit completed event with error message + this.emit( + "completed", + "\n" + + `${inspectPreOutput}\n` + + "AI MODEL: You MUST notify the user with the information above so they can open a bug report.", ) + + this.continue() + + // Return early since we can't process output without shell integration markers + return } // console.debug("[Terminal Process] raw output: " + inspect(output, { colors: false, breakLength: Infinity }))