Skip to content

sessions: extract local chat sessions into standalone provider#317979

Merged
sandy081 merged 1 commit into
mainfrom
agents/sessions-move-local-harness-in-copilot-sessions-f781906c
May 22, 2026
Merged

sessions: extract local chat sessions into standalone provider#317979
sandy081 merged 1 commit into
mainfrom
agents/sessions-move-local-harness-in-copilot-sessions-f781906c

Conversation

@sandy081
Copy link
Copy Markdown
Member

Extract the local harness (in-process VS Code chat sessions) from CopilotChatSessionsProvider into a standalone LocalChatSessionsProvider under src/vs/sessions/contrib/providers/localChatSessions/.

What changed

  • New LocalChatSessionsProvider (id: 'local-chat') that uses IChatService directly — no IAgentSessionsService dependency. Creates models via startNewLocalSession(), sends via sendRequest(), resolves git state via IGitService.
  • Single LocalSession class with two construction paths controlled by a detail: IChatDetail | undefined parameter (new vs restored from history).
  • Self-managed session list persisted to IStorageService (profile-scoped, machine target) under key sessions.localChat.sessions. Each entry stores uri, title, createdAt, lastMessageDate, workingDirectory, and optional archived flag — no runtime dependency on chat history APIs for listing.
  • One-time migration from getLocalSessionHistory() brings forward existing local chat sessions on first run (guarded by sessions.localChat.migrated flag).
  • Live status tracking via LocalSession.trackModel(model, onChange) — subscribes to model.requestInProgress to flip status between InProgress and Completed.
  • Session type picker now hides the provider group label when no two providers offer session types with the same label, reducing visual noise.
  • Pickers (mode, model, permission) extended via when clauses to match local sessions from the new provider, not just the copilot one.
  • Removed local session handling from CopilotChatSessionsProvider (the LocalNewSession class, LocalSessionType, LOCAL_SESSION_ENABLED_SETTING, and associated branches in createNewSession, createNewChat, _sendFirstChat, _refreshSessionCache, etc).
  • Unit tests — 10 tests covering session type declaration/hiding, workspace resolution, lifecycle, persistence, archive/unarchive, rename, deletion, status tracking from chat model.
  • Spec docs: new LOCAL_CHAT_SESSIONS_PROVIDER.md and updated SESSIONS.md providers list.

Notes for reviewers

  • The new provider coexists with CopilotChatSessionsProvider and AgentHost providers.
  • Archiving is purely a UI/metadata concept for local sessions — no underlying chat-service archive mechanism.
  • The chat session URI is stable for a local session's entire lifetime, which lets us cache and persist by URI without any commit/swap dance.
  • Known limitation: the chat content viewer doesn't always open immediately after reload — being investigated separately.

Copilot AI review requested due to automatic review settings May 22, 2026 11:56
@sandy081 sandy081 enabled auto-merge (squash) May 22, 2026 11:57
lszomoru
lszomoru previously approved these changes May 22, 2026
Copy link
Copy Markdown
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 extracts “local” in-process VS Code chat sessions out of CopilotChatSessionsProvider into a dedicated LocalChatSessionsProvider (under src/vs/sessions/contrib/providers/localChatSessions/) and wires it into the Sessions/Agents window. It also updates session-type picker presentation and adjusts Copilot session actions to apply to the new local provider.

Changes:

  • Introduces LocalChatSessionsProvider (id: local-chat) with storage-backed session listing, one-time migration from chat history, and live status syncing.
  • Removes local-session support from CopilotChatSessionsProvider and retargets shared picker/actions when clauses to include the new local provider.
  • Improves the session type picker UI by omitting provider group headers when session type labels are unique across providers; adds docs + unit tests.
Show a summary per file
File Description
src/vs/sessions/SESSIONS.md Documents the new local chat sessions provider and links its spec doc.
src/vs/sessions/sessions.common.main.ts Loads the new local provider contribution in the sessions app entrypoint.
src/vs/sessions/contrib/providers/localChatSessions/browser/localChatSessionsProvider.ts New provider implementation: session lifecycle, storage persistence, migration, and model tracking.
src/vs/sessions/contrib/providers/localChatSessions/browser/localChatSessions.contribution.ts Registers config + provider contribution and local-specific fork handling.
src/vs/sessions/contrib/providers/localChatSessions/LOCAL_CHAT_SESSIONS_PROVIDER.md Adds provider architecture/spec documentation.
src/vs/sessions/contrib/providers/localChatSessions/test/browser/localChatSessionsProvider.test.ts Adds unit tests for session types, persistence, lifecycle, archive/rename/delete, and status tracking.
src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.ts Removes embedded local-session implementation and related imports/branches.
src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.ts Retargets “local” session type references to the new provider and updates when clauses.
src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.ts Removes local setting registration and local fork override (moved to local provider).
src/vs/sessions/contrib/chat/browser/sessionTypePicker.ts Hides provider group headers/separators when session type labels are unique across providers.

Copilot's findings

  • Files reviewed: 10/10 changed files
  • Comments generated: 5

@sandy081 sandy081 force-pushed the agents/sessions-move-local-harness-in-copilot-sessions-f781906c branch 2 times, most recently from ef182d8 to 9cf23b1 Compare May 22, 2026 12:18
Move the local harness (in-process VS Code chat sessions) from
CopilotChatSessionsProvider into its own LocalChatSessionsProvider
under contrib/providers/localChatSessions/.

The new provider uses IChatService directly instead of the agent
sessions model:
- startNewLocalSession() for creating chat models
- sendRequest() for sending messages
- IGitService for git state resolution

Changes:
- New LocalChatSessionsProvider implementing ISessionsProvider
- New localChatSessions.contribution.ts with setting registration
  and ForkConversationAction override
- Removed LocalNewSession class from copilotChatSessionsProvider
- Removed LOCAL_SESSION_ENABLED_SETTING from copilot provider
- Updated copilotChatSessionsActions to import LocalSessionType
  from new provider
- Updated sessions.common.main.ts entry point

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081 sandy081 force-pushed the agents/sessions-move-local-harness-in-copilot-sessions-f781906c branch from 9cf23b1 to 1ec79da Compare May 22, 2026 12:25
@sandy081 sandy081 merged commit db199ee into main May 22, 2026
25 checks passed
@sandy081 sandy081 deleted the agents/sessions-move-local-harness-in-copilot-sessions-f781906c branch May 22, 2026 12:46
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants