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 <roo-code@z.ewheeler.org>
This commit is contained in:
Eric Wheeler 2025-03-08 18:41:51 -08:00
parent 8de202ba09
commit 4e0f868261

View file

@ -393,10 +393,27 @@ export class TerminalProcess extends EventEmitter<TerminalProcessEvents> {
// 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",
"<VSCE shell integration markers not found: terminal output and command execution status is unknown>\n" +
`<preOutput>${inspectPreOutput}</preOutput>\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 }))