Skip to content

Listen to models, not widgets, in local session provider#279504

Merged
roblourens merged 2 commits intomainfrom
roblou/radical-bat
Nov 26, 2025
Merged

Listen to models, not widgets, in local session provider#279504
roblourens merged 2 commits intomainfrom
roblou/radical-bat

Conversation

@roblourens
Copy link
Member

For #279359

Copilot AI review requested due to automatic review settings November 26, 2025 02:09
@roblourens roblourens enabled auto-merge (squash) November 26, 2025 02:09
@roblourens roblourens self-assigned this Nov 26, 2025
@vs-code-engineering
Copy link

vs-code-engineering bot commented Nov 26, 2025

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.ts

dmitrivMS
dmitrivMS previously approved these changes Nov 26, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 chatModels observable to IChatService that exposes all live chat models
  • Refactored LocalAgentsSessionsProvider to use autorun to reactively listen to model changes instead of widget lifecycle events
  • Updated test mocks to include the new chatModels property

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

Comment on lines +45 to 49
// Listen for models being added or removed
this._register(autorun(reader => {
const models = this.chatService.chatModels.read(reader);
this.registerModelListeners(models);
}));
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new reactive behavior where LocalAgentsSessionsProvider listens to chatModels observable and registers/unregisters model listeners dynamically lacks test coverage. Consider adding tests that verify:

  1. Listeners are registered when models are added to chatModels observable
  2. Listeners are cleaned up when models are removed from chatModels observable
  3. 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.

Copilot uses AI. Check for mistakes.
@roblourens roblourens merged commit 94c7f62 into main Nov 26, 2025
28 checks passed
@roblourens roblourens deleted the roblou/radical-bat branch November 26, 2025 03:52
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants