Add onDidDispose event for chat sessions input states #312433
Add onDidDispose event for chat sessions input states #312433mjbvz merged 3 commits intomicrosoft:mainfrom
Conversation
This isn't fully hooked up since input states don't have a full lifecycle yet in the service Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Adds a disposal lifecycle hook to chat session input states so extensions can react when an input state is no longer valid.
Changes:
- Introduce
ChatSessionInputState.onDidDisposein the proposed API. - Implement
onDidDisposeinChatSessionInputStateImpland dispose input states when sessions/controllers are disposed. - Add logic to dispose prior input states associated with a session resource.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts | Adds onDidDispose to the proposed ChatSessionInputState API surface. |
| src/vs/workbench/api/common/extHostChatSessions.ts | Implements the new event and wires disposal of input states to session/controller lifecycle paths. |
Copilot's findings
- Files reviewed: 1/2 changed files
- Comments generated: 1
| // Dispose any previous input states for this session resource | ||
| if (sessionResource && controllerData) { | ||
| this._disposeInputStatesForResource(controllerData.inputStates, sessionResource); | ||
| } | ||
|
|
There was a problem hiding this comment.
Disposing prior input states here (inside getInputStateForSession, which is used by the option-group proxy command wrapper) can dispose the active ChatSessionInputStateImpl that the UI/extension is still using to receive onDidChange updates for the session. This call path is triggered when a user runs an option-group command and should not tear down the session’s live input state. Suggest removing the _disposeInputStatesForResource(...) call from this method (or changing the command wrapper to use an untracked/snapshot input state) and only disposing/replacing states in the session lifecycle paths ($provideChatSessionContent / $provideChatSessionInputState / $disposeChatSessionContent).
| // Dispose any previous input states for this session resource | |
| if (sessionResource && controllerData) { | |
| this._disposeInputStatesForResource(controllerData.inputStates, sessionResource); | |
| } |
No description provided.