Skip to content

Fix BYOK models disappearing during startup#319123

Open
EmirX3D wants to merge 3 commits into
microsoft:mainfrom
EmirX3D:fix-byok-model-startup-race
Open

Fix BYOK models disappearing during startup#319123
EmirX3D wants to merge 3 commits into
microsoft:mainfrom
EmirX3D:fix-byok-model-startup-race

Conversation

@EmirX3D
Copy link
Copy Markdown

@EmirX3D EmirX3D commented May 30, 2026

Fixes a startup timing race where configured Custom Endpoint/BYOK models could be hidden from the chat model picker because chat.hasByokModels.lastKnown restored as false before extension registration or model resolution completed, by treating configured non-Copilot language model provider groups as an immediate positive BYOK signal and covering the cold-start case with a regression test.

Closes #319121

Copilot AI review requested due to automatic review settings May 30, 2026 11:17
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves resilience and UX around chat session persistence and BYOK visibility by rebuilding missing session indices from disk, treating configured BYOK providers as an early positive signal, and migrating stored local chat sessions from profile-scoped to application-scoped storage.

Changes:

  • Rebuild ChatSessionStore index from persisted session files when the persisted index is missing/empty.
  • Make HasByokModelsContribution resolve true immediately when non-Copilot provider groups are configured (even before extensions register).
  • Migrate local chat session metadata from StorageScope.PROFILE to StorageScope.APPLICATION, plus add tests and documentation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/model/chatSessionStore.ts Adds one-time index rebuild scanning persisted session files with limited parallelism.
src/vs/workbench/contrib/chat/test/common/model/chatSessionStore.test.ts Adds test coverage for rebuilding the index from valid session files while skipping corrupt ones.
src/vs/workbench/contrib/chat/browser/hasByokModelsContribution.ts Treats configured non-Copilot provider groups as an immediate positive BYOK signal on startup.
src/vs/workbench/contrib/chat/test/browser/hasByokModelsContribution.test.ts Adds regression test for “configured groups should show BYOK UI even if persisted state is false”.
src/vs/sessions/contrib/providers/localChatSessions/browser/localChatSessionsProvider.ts Migrates persisted local chat sessions from profile to application storage and merges forward on load.
src/vs/sessions/contrib/providers/localChatSessions/test/browser/localChatSessionsProvider.test.ts Adds test for legacy-to-application storage migration behavior.
src/vs/sessions/contrib/providers/localChatSessions/LOCAL_CHAT_SESSIONS_PROVIDER.md Documents new storage scope and legacy merge-forward behavior.

Comment thread src/vs/workbench/contrib/chat/common/model/chatSessionStore.ts
Comment thread src/vs/workbench/contrib/chat/common/model/chatSessionStore.ts
Copy link
Copy Markdown
Contributor

@dmitrivMS dmitrivMS left a comment

Choose a reason for hiding this comment

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

This is doing too much for the stated problem. The race needs to be addressed, but this is doing a lot more than fixing hasByokModels state...

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.

Custom Endpoint (BYOK) models disappear from model picker on VS Code restart - hasByokModels.lastKnown race condition

4 participants