You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(chat): Track and persist enabled MCP servers for chat sessions - #795
- Introduces the ability to save and load a specific set of enabled MCP servers for each chat session.
- Updates `ChatSession` domain model and associated persistence layer (database schema) to support this setting.
- Enhances UI components (ChatView, ChatViewModel) to manage and display the selected enabled servers.
- Improves label management logic in session views and sidebars, including a helper function to calculate label ID toggles.
BREAKING CHANGE: The `ChatSession` entity now includes `enabledMcpServerIds` for persisting user selection of enabled tools. Consumers must adapt to handle this new field in the domain model and repository.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Several moderate active issues remain, including destructive reconciliation on failed MCP loads, stale-state reload handling, unordered persistence writes, and repeated macOS keychain permission prompts.
This pull request adds per-chat persistence for enabled MCP servers, wiring selections through the chat domain, database, session lifecycle, and desktop UI. It also includes label-management refinements, accessibility improvements, localization updates, and macOS keychain changes.
Changes:
Adds enabledMcpServerIds to chat sessions, schema migrations, repositories, services, synchronization, and UI state.
Connects MCP selections to session creation, loading, sending, retrying, and background persistence.
Optimizes secret writes and updates macOS keychain handling.
Moderate, 4 votes: Avoid passing -T during existing-item updates because it can repeatedly trigger macOS keychain permission prompts. Moderate, 1 vote: Use a non-secret existence or cache check instead of retrieving the secret for the no-op save guard.
Loads, exposes, and persists session-specific MCP selections.
Moderate, 4 votes: Serialize or enforce last-write-wins ordering for per-session enabled-server updates to prevent rapid toggles from persisting a stale set.
Controls MCP selection, reconciles server changes, and displays approval status.
Moderate, 2 votes: Preserve persisted IDs when the MCP catalog cannot be loaded instead of treating an unavailable catalog as empty and erasing the selection. Moderate, 3 votes: Ensure reload effects read the current enabledServerIds rather than a stale value captured from the first composition.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical correctness issues remain in persistence ordering and migration safety, and a DI failure can erase enabled MCP server selections, so the change needs fixes before approval.
When Koin cannot provide McpInstanceService, this marks the catalog load as successful even though no external servers were loaded. The reconciliation below then treats the built-in-only list as authoritative and persists an empty/trimmed selection, so a transient service/DI failure can erase the session's enabled MCP server IDs. Treat a null service as a failed load and skip reconciliation in that case.
Add round-trip and migration coverage for enabled-server persistence
The new enabled-server persistence path is not covered by the existing ChatSessionRepositoryIT, which already exercises session creation and updates. Please add round-trip and replacement-update coverage (including the migration/default [] case); otherwise a schema/query/JSON mismatch can silently cause resumed sessions to lose their tool selection.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active moderate and critical findings remain, including destructive session-state reconciliation when the MCP service is unavailable and unused imports that will fail the repository’s ktlint checks.
When Koin cannot provide McpInstanceService, this expression still marks the catalog load as successful. The resulting list contains only built-in tools, so the reconciliation below immediately removes every persisted external server ID and persists the truncated set. A missing service is not an authoritative empty catalog; only reconcile when a non-null service returned a successful catalog, otherwise preserve the session selection for the next retry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ChatSessiondomain model and associated persistence layer (database schema) to support this setting.Related Issue(s)
Type of Change
What Changed & Why
How to Test
./gradlew testScreenshots / Recordings (if applicable)
Checklist
main./gradlew spotlessApplyand./gradlew detektlocally./gradlew testand all tests passgit commit -sAdditional Notes