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 {
153
153
154
154
// Restore terminal associations from storage
155
155
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
+ } ) ) ;
156
163
}
157
164
158
165
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
17
17
import { IWorkspaceContextService } from '../../../../../../platform/workspace/common/workspace.js' ;
18
18
import { TestContextService } from '../../../../../test/common/workbenchTestServices.js' ;
19
19
import 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' ;
21
21
import { OperatingSystem } from '../../../../../../base/common/platform.js' ;
22
+ import { Emitter } from '../../../../../../base/common/event.js' ;
22
23
23
24
class TestRunInTerminalTool extends RunInTerminalTool {
24
25
protected override _osBackend : Promise < OperatingSystem > = Promise . resolve ( OperatingSystem . Windows ) ;
@@ -53,6 +54,9 @@ suite('RunInTerminalTool', () => {
53
54
return [ ] ;
54
55
} ,
55
56
} ) ;
57
+ instantiationService . stub ( ITerminalService , {
58
+ onDidDisposeInstance : new Emitter < ITerminalInstance > ( ) . event
59
+ } ) ;
56
60
workspaceService = instantiationService . invokeFunction ( accessor => accessor . get ( IWorkspaceContextService ) ) as TestContextService ;
57
61
58
62
runInTerminalTool = store . add ( instantiationService . createInstance ( TestRunInTerminalTool ) ) ;
You can’t perform that action at this time.
0 commit comments