Listen to models, not widgets, in local session provider#279504
Listen to models, not widgets, in local session provider#279504roblourens merged 2 commits intomainfrom
Conversation
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the LocalAgentsSessionsProvider to listen directly to chat models via a new observable instead of listening to chat widgets. This architectural improvement provides a more direct and reliable way to track chat sessions.
Key Changes:
- Added a new
chatModelsobservable toIChatServicethat exposes all live chat models - Refactored
LocalAgentsSessionsProviderto useautorunto reactively listen to model changes instead of widget lifecycle events - Updated test mocks to include the new
chatModelsproperty
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/common/chatService.ts |
Added documentation and interface definition for the new chatModels observable |
src/vs/workbench/contrib/chat/common/chatServiceImpl.ts |
Implemented chatModels as a derived observable that exposes the live session models |
src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.ts |
Refactored to listen to chatModels observable instead of widget lifecycle events, using autorun for reactive tracking and DisposableMap for managing model listeners |
src/vs/workbench/contrib/chat/test/common/mockChatService.ts |
Added chatModels property to mock implementation for testing |
src/vs/workbench/contrib/chat/test/browser/localAgentSessionsProvider.test.ts |
Added chatModels property to test mock and reorganized imports |
| // Listen for models being added or removed | ||
| this._register(autorun(reader => { | ||
| const models = this.chatService.chatModels.read(reader); | ||
| this.registerModelListeners(models); | ||
| })); |
There was a problem hiding this comment.
The new reactive behavior where LocalAgentsSessionsProvider listens to chatModels observable and registers/unregisters model listeners dynamically lacks test coverage. Consider adding tests that verify:
- Listeners are registered when models are added to
chatModelsobservable - Listeners are cleaned up when models are removed from
chatModelsobservable - Events fire correctly when models change (e.g., title changes via
setCustomTitle)
This would ensure the new reactive pattern works as expected and prevents regressions.
For #279359