@@ -49,10 +49,10 @@ export class TerminalProcess extends BaseTerminalProcess {
4949 "[TerminalProcess] Shell integration not available. Command sent without knowledge of response." ,
5050 )
5151
52- this . emit (
53- "no_shell_integration ",
54- "Command was submitted; output is not available, as shell integration is inactive." ,
55- )
52+ this . emit ( "no_shell_integration" , {
53+ message : "Command was submitted; output is not available, as shell integration is inactive. ",
54+ commandSubmitted : true ,
55+ } )
5656
5757 this . emit (
5858 "completed" ,
@@ -70,10 +70,10 @@ export class TerminalProcess extends BaseTerminalProcess {
7070 this . removeAllListeners ( "stream_available" )
7171
7272 // Emit no_shell_integration event with descriptive message
73- this . emit (
74- "no_shell_integration" ,
75- `VSCE shell integration stream did not start within ${ Terminal . getShellIntegrationTimeout ( ) / 1000 } seconds. Terminal problem?` ,
76- )
73+ this . emit ( "no_shell_integration" , {
74+ message : `VSCE shell integration stream did not start within ${ Terminal . getShellIntegrationTimeout ( ) / 1000 } seconds. Terminal problem?` ,
75+ commandSubmitted : true ,
76+ } )
7777
7878 // Reject with descriptive error
7979 reject (
@@ -95,10 +95,16 @@ export class TerminalProcess extends BaseTerminalProcess {
9595 this . once ( "shell_execution_complete" , ( details : ExitCodeDetails ) => resolve ( details ) )
9696 } )
9797
98- // Execute command
99- const defaultWindowsShellProfile = vscode . workspace
100- . getConfiguration ( "terminal.integrated.defaultProfile" )
101- . get ( "windows" )
98+ // Execute command.
99+ // Determine whether the active shell is PowerShell so we can apply the
100+ // PS-specific counter/sleep workarounds. Prefer the Zoo Code profile
101+ // override (if set) over the VS Code default profile. Fix for the wrong
102+ // config API: must be getConfiguration("terminal.integrated").get(
103+ // "defaultProfile.windows"), not the reversed form that always returns null.
104+ const profileOverride = Terminal . getTerminalProfile ( )
105+ const defaultWindowsShellProfile =
106+ profileOverride ??
107+ vscode . workspace . getConfiguration ( "terminal.integrated" ) . get < string > ( "defaultProfile.windows" )
102108
103109 const isPowerShell =
104110 process . platform === "win32" &&
@@ -208,26 +214,35 @@ export class TerminalProcess extends BaseTerminalProcess {
208214 // Emit any remaining output before completing
209215 this . emitRemainingBufferIfListening ( )
210216 } else {
211- const errorMsg =
212- "VSCE output start escape sequence (]633;C or ]133;C) not received, but the stream has started. Upstream VSCE Bug?"
213-
214217 const inspectPreOutput = inspect ( preOutput , { colors : false , breakLength : Infinity } )
218+
219+ // Empty stream (preOutput === '') is a first-run race: VS Code fires
220+ // onDidStartTerminalShellExecution before the shell is fully initialized on
221+ // a freshly-created terminal. The command was never submitted, so this is
222+ // retryable (commandSubmitted: false triggers the execa fallback).
223+ //
224+ // Non-empty preOutput means the stream had data but ]633;C never arrived —
225+ // a genuine shell integration failure after submission (not retryable).
226+ const commandSubmitted = preOutput !== ""
227+
228+ const errorMsg = commandSubmitted
229+ ? "VSCE output start escape sequence (]633;C or ]133;C) not received, but the stream has started. Upstream VSCE Bug?"
230+ : "VSCE shell integration stream completed with no output on first command (shell startup race). Command was not submitted."
231+
215232 console . error ( `[Terminal Process] ${ errorMsg } preOutput: ${ inspectPreOutput } ` )
216233
217- // Emit no_shell_integration event
218- this . emit ( "no_shell_integration" , errorMsg )
234+ this . emit ( "no_shell_integration" , { message : errorMsg , commandSubmitted } )
219235
220- // Emit completed event with error message
221236 this . emit (
222237 "completed" ,
223- "<VSCE shell integration markers not found: terminal output and command execution status is unknown>\n" +
224- `<preOutput>${ inspectPreOutput } </preOutput>\n` +
225- "AI MODEL: You MUST notify the user with the information above so they can open a bug report." ,
238+ commandSubmitted
239+ ? "<VSCE shell integration markers not found: terminal output and command execution status is unknown>\n" +
240+ `<preOutput>${ inspectPreOutput } </preOutput>\n` +
241+ "AI MODEL: You MUST notify the user with the information above so they can open a bug report."
242+ : "<shell integration stream was empty on first execution: command was not submitted>" ,
226243 )
227244
228245 this . continue ( )
229-
230- // Return early since we can't process output without shell integration markers
231246 return
232247 }
233248
0 commit comments