File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/vs/workbench/contrib/terminalContrib/chatAgentTools Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,13 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
153153
154154 // Restore terminal associations from storage
155155 this . _restoreTerminalAssociations ( ) ;
156+ this . _register ( this . _terminalService . onDidDisposeInstance ( e => {
157+ for ( const [ sessionId , toolTerminal ] of this . _sessionTerminalAssociations . entries ( ) ) {
158+ if ( e === toolTerminal . instance ) {
159+ this . _sessionTerminalAssociations . delete ( sessionId ) ;
160+ }
161+ }
162+ } ) ) ;
156163 }
157164
158165 async prepareToolInvocation ( context : IToolInvocationPreparationContext , token : CancellationToken ) : Promise < IPreparedToolInvocation | undefined > {
Original file line number Diff line number Diff line change @@ -17,8 +17,9 @@ import { TerminalChatAgentToolsSettingId } from '../../common/terminalChatAgentT
1717import { IWorkspaceContextService } from '../../../../../../platform/workspace/common/workspace.js' ;
1818import { TestContextService } from '../../../../../test/common/workbenchTestServices.js' ;
1919import type { TestInstantiationService } from '../../../../../../platform/instantiation/test/common/instantiationServiceMock.js' ;
20- import type { ITerminalInstance } from '../../../../terminal/browser/terminal.js' ;
20+ import { ITerminalService , type ITerminalInstance } from '../../../../terminal/browser/terminal.js' ;
2121import { OperatingSystem } from '../../../../../../base/common/platform.js' ;
22+ import { Emitter } from '../../../../../../base/common/event.js' ;
2223
2324class TestRunInTerminalTool extends RunInTerminalTool {
2425 protected override _osBackend : Promise < OperatingSystem > = Promise . resolve ( OperatingSystem . Windows ) ;
@@ -53,6 +54,9 @@ suite('RunInTerminalTool', () => {
5354 return [ ] ;
5455 } ,
5556 } ) ;
57+ instantiationService . stub ( ITerminalService , {
58+ onDidDisposeInstance : new Emitter < ITerminalInstance > ( ) . event
59+ } ) ;
5660 workspaceService = instantiationService . invokeFunction ( accessor => accessor . get ( IWorkspaceContextService ) ) as TestContextService ;
5761
5862 runInTerminalTool = store . add ( instantiationService . createInstance ( TestRunInTerminalTool ) ) ;
You can’t perform that action at this time.
0 commit comments