|
6 | 6 | import { CancellationToken } from '../../../../base/common/cancellation.js';
|
7 | 7 | import { Codicon } from '../../../../base/common/codicons.js';
|
8 | 8 | import { Emitter, Event } from '../../../../base/common/event.js';
|
9 |
| -import { Disposable, IDisposable } from '../../../../base/common/lifecycle.js'; |
| 9 | +import { Disposable, DisposableStore, IDisposable } from '../../../../base/common/lifecycle.js'; |
10 | 10 | import { localize } from '../../../../nls.js';
|
11 | 11 | import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
|
12 | 12 | import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
|
@@ -102,17 +102,22 @@ const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(Workbench
|
102 | 102 | workbenchRegistry.registerWorkbenchContribution(ChatSessionsContribution, LifecyclePhase.Restored);
|
103 | 103 |
|
104 | 104 | class ContributedChatSessionData implements IDisposable {
|
| 105 | + private readonly _disposableStore: DisposableStore; |
| 106 | + |
105 | 107 | constructor(
|
106 | 108 | readonly session: ChatSession,
|
107 | 109 | readonly chatSessionType: string,
|
108 | 110 | readonly id: string,
|
109 | 111 | private readonly onWillDispose: (session: ChatSession, chatSessionType: string, id: string) => void
|
110 | 112 | ) {
|
| 113 | + this._disposableStore = new DisposableStore(); |
| 114 | + this._disposableStore.add(this.session.onWillDispose(() => { |
| 115 | + this.onWillDispose(this.session, this.chatSessionType, this.id); |
| 116 | + })); |
111 | 117 | }
|
112 | 118 |
|
113 | 119 | dispose(): void {
|
114 |
| - this.onWillDispose(this.session, this.chatSessionType, this.id); |
115 |
| - this.session.dispose(); |
| 120 | + this._disposableStore.dispose(); |
116 | 121 | }
|
117 | 122 | }
|
118 | 123 |
|
@@ -411,7 +416,9 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
|
411 | 416 | this._sessions.set(sessionKey, sessionData);
|
412 | 417 |
|
413 | 418 | return session;
|
414 |
| - } private _onWillDisposeSession(session: ChatSession, chatSessionType: string, id: string): void { |
| 419 | + } |
| 420 | + |
| 421 | + private _onWillDisposeSession(session: ChatSession, chatSessionType: string, id: string): void { |
415 | 422 | const sessionKey = `${chatSessionType}_${id}`;
|
416 | 423 | this._sessions.delete(sessionKey);
|
417 | 424 | }
|
|
0 commit comments