@@ -50,6 +50,7 @@ describe("TerminalProcess", () => {
5050
5151 // Create a process for testing
5252 terminalProcess = new TestTerminalProcess ( mockTerminalInfo )
53+ mockTerminalInfo . process = terminalProcess
5354
5455 TerminalRegistry [ "terminals" ] . push ( mockTerminalInfo )
5556
@@ -142,10 +143,11 @@ describe("TerminalProcess", () => {
142143 } )
143144
144145 it . each ( [
145- [ "PowerShell" , ". {\necho one\necho two\n}" ] ,
146- [ "fish" , "begin\necho one\necho two\nend" ] ,
147- ] ) ( "uses the %s multiline wrapper" , async ( profile , expectedCommand ) => {
148- Terminal . setTerminalProfile ( profile )
146+ [ "PowerShell" , true , false , ". {\necho one\necho two\n}" ] ,
147+ [ "fish" , false , true , "begin\necho one\necho two\nend" ] ,
148+ ] ) ( "uses the %s multiline wrapper" , async ( _profile , isPowerShell , isFish , expectedCommand ) => {
149+ const psSpy = vi . spyOn ( Terminal , "isActiveShellPowerShell" ) . mockReturnValue ( isPowerShell )
150+ const fishSpy = vi . spyOn ( Terminal , "isActiveShellFish" ) . mockReturnValue ( isFish )
149151
150152 try {
151153 mockStream = ( async function * ( ) {
@@ -165,7 +167,8 @@ describe("TerminalProcess", () => {
165167
166168 expect ( mockTerminal . shellIntegration . executeCommand ) . toHaveBeenCalledWith ( expectedCommand )
167169 } finally {
168- Terminal . setTerminalProfile ( undefined )
170+ psSpy . mockRestore ( )
171+ fishSpy . mockRestore ( )
169172 }
170173 } )
171174
@@ -218,24 +221,20 @@ describe("TerminalProcess", () => {
218221 consoleWarnSpy . mockRestore ( )
219222 } )
220223
221- it ( "emits no_shell_integration with commandSubmitted=true when stream is empty after submission" , async ( ) => {
222- const consoleErrorSpy = vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } )
223-
224- let details : { message : string ; commandSubmitted : boolean } | undefined
224+ it ( "completes without warning when the execution stream is empty after submission" , async ( ) => {
225+ const noShellIntegrationSpy = vi . fn ( )
226+ let completedOutput : string | undefined
225227
226228 const eventPromises = Promise . all ( [
227229 new Promise < void > ( ( resolve ) =>
228- terminalProcess . once ( "no_shell_integration " , ( d ) => {
229- details = d
230+ terminalProcess . once ( "completed " , ( output ?: string ) => {
231+ completedOutput = output
230232 resolve ( )
231233 } ) ,
232234 ) ,
233- new Promise < void > ( ( resolve ) => terminalProcess . once ( "completed" , ( _output ?: string ) => resolve ( ) ) ) ,
234235 new Promise < void > ( ( resolve ) => terminalProcess . once ( "continue" , resolve ) ) ,
235236 ] )
236237
237- // Empty stream: simulates VS Code firing onDidStartTerminalShellExecution
238- // before the shell has fully initialised on a freshly-created terminal.
239238 async function * emptyStream ( ) : AsyncGenerator < string > {
240239 terminalProcess . emit ( "shell_execution_complete" , { exitCode : 0 } )
241240 return
@@ -246,32 +245,31 @@ describe("TerminalProcess", () => {
246245 mockExecution = { read : vi . fn ( ) . mockReturnValue ( mockStream ) }
247246 mockTerminal . shellIntegration . executeCommand . mockReturnValue ( mockExecution )
248247
248+ terminalProcess . once ( "no_shell_integration" , noShellIntegrationSpy )
249+
249250 const runPromise = terminalProcess . run ( "test command" )
250- terminalProcess . emit ( "stream_available" , mockStream )
251251 await runPromise
252252 await eventPromises
253253
254- expect ( details ?. commandSubmitted ) . toBe ( true )
255- consoleErrorSpy . mockRestore ( )
254+ expect ( mockExecution . read ) . toHaveBeenCalledTimes ( 1 )
255+ expect ( completedOutput ) . toBe ( "" )
256+ expect ( noShellIntegrationSpy ) . not . toHaveBeenCalled ( )
256257 } )
257258
258- it ( "emits no_shell_integration with commandSubmitted=true when stream has data but no ]633;C" , async ( ) => {
259- const consoleErrorSpy = vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } )
260-
261- let details : { message : string ; commandSubmitted : boolean } | undefined
259+ it ( "captures execution output even when VS Code does not include start markers" , async ( ) => {
260+ const noShellIntegrationSpy = vi . fn ( )
261+ let completedOutput : string | undefined
262262
263263 const eventPromises = Promise . all ( [
264264 new Promise < void > ( ( resolve ) =>
265- terminalProcess . once ( "no_shell_integration " , ( d ) => {
266- details = d
265+ terminalProcess . once ( "completed " , ( output ?: string ) => {
266+ completedOutput = output
267267 resolve ( )
268268 } ) ,
269269 ) ,
270- new Promise < void > ( ( resolve ) => terminalProcess . once ( "completed" , ( _output ?: string ) => resolve ( ) ) ) ,
271270 new Promise < void > ( ( resolve ) => terminalProcess . once ( "continue" , resolve ) ) ,
272271 ] )
273272
274- // Stream has output but never emits ]633;C — genuine shell integration failure.
275273 mockStream = ( async function * ( ) {
276274 yield "some output without marker\n"
277275 terminalProcess . emit ( "shell_execution_complete" , { exitCode : 0 } )
@@ -280,13 +278,15 @@ describe("TerminalProcess", () => {
280278 mockExecution = { read : vi . fn ( ) . mockReturnValue ( mockStream ) }
281279 mockTerminal . shellIntegration . executeCommand . mockReturnValue ( mockExecution )
282280
281+ terminalProcess . once ( "no_shell_integration" , noShellIntegrationSpy )
282+
283283 const runPromise = terminalProcess . run ( "test command" )
284- terminalProcess . emit ( "stream_available" , mockStream )
285284 await runPromise
286285 await eventPromises
287286
288- expect ( details ?. commandSubmitted ) . toBe ( true )
289- consoleErrorSpy . mockRestore ( )
287+ expect ( mockExecution . read ) . toHaveBeenCalledTimes ( 1 )
288+ expect ( completedOutput ) . toBe ( "some output without marker\n" )
289+ expect ( noShellIntegrationSpy ) . not . toHaveBeenCalled ( )
290290 } )
291291
292292 it ( "sets hot state for compiling commands" , async ( ) => {
0 commit comments