CONTEXT KEYS CLEANUP#322783
Merged
Merged
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @sandy081Matched files:
@lszomoruMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Sessions window context keys by consolidating “active session” and context-menu overlay keys into a single set (sessionType, sessionProviderId, etc.), and centralizes the logic for applying those keys via a new helper in the sessions service layer. It also updates usages across sessions contributions, provider docs, and Copilot extension menu when clauses to align with the renamed keys.
Changes:
- Replace
activeSession*andchatSession*overlay context keys with unifiedsession*context keys. - Add
setSessionContextKeys/setActiveSessionContextKeyshelper to apply all session-derived keys consistently and efficiently (cached bindings). - Update Sessions window actions/menus/docs and Copilot extension contribution
whenclauses to use the new key names.
Show a summary per file
| File | Description |
|---|---|
| src/vs/sessions/SESSIONS.md | Update rename gating docs to reference sessionSupportsRename. |
| src/vs/sessions/SESSIONS_LIST.md | Update documentation/examples and context key list to sessionType / sessionProviderId. |
| src/vs/sessions/services/sessions/common/sessionsManagement.ts | Remove unused exported context key and its imports. |
| src/vs/sessions/services/sessions/common/sessionContextKeys.ts | New helper to bind/cache and apply session-derived context keys to a context service. |
| src/vs/sessions/services/sessions/browser/sessionsService.ts | Switch active-session context key updates to use the new helper; remove bespoke key wiring. |
| src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts | Update rename/delete/archive gating to use unified session context keys. |
| src/vs/sessions/contrib/sessions/browser/views/sessionsList.ts | Update item overlay keys to sessionType / sessionProviderId / sessionSupports*. |
| src/vs/sessions/contrib/sessions/browser/sessionsActions.ts | Update provider-based gating to use SessionProviderIdContext. |
| src/vs/sessions/contrib/providers/localChatSessions/LOCAL_CHAT_SESSIONS_PROVIDER.md | Update docs to reference renamed context keys. |
| src/vs/sessions/contrib/providers/copilotChatSessions/COPILOT_CHAT_SESSIONS_PROVIDER.md | Update docs to reference renamed context keys. |
| src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.ts | Replace ActiveSession* keys with unified Session* keys in menu gating and bindings. |
| src/vs/sessions/contrib/providers/agentHost/browser/mobile/mobileChatInputConfigPicker.ts | Rename combined-picker gating key to SessionUsesCombinedConfigPickerContext. |
| src/vs/sessions/contrib/providers/agentHost/browser/agentSessionSettings.contribution.ts | Update regex gating to SessionProviderIdContext. |
| src/vs/sessions/contrib/providers/agentHost/browser/agentHostSettings.contribution.ts | Update regex gating to SessionProviderIdContext. |
| src/vs/sessions/contrib/providers/agentHost/browser/agentHostSessionConfigPicker.ts | Update provider gating to SessionProviderIdContext. |
| src/vs/sessions/contrib/providers/agentHost/browser/agentHostSessionBranchActions.ts | Update provider gating to SessionProviderIdContext. |
| src/vs/sessions/contrib/providers/agentHost/browser/agentHostAgentPicker.ts | Update provider gating to SessionProviderIdContext. |
| src/vs/sessions/contrib/providers/agentHost/AGENT_HOST_SESSIONS_PROVIDER.md | Update docs to reference renamed delete-gating key. |
| src/vs/sessions/contrib/files/browser/files.contribution.ts | Rename git repository/sync gating keys to unified Session* variants. |
| src/vs/sessions/contrib/codeReview/browser/codeReview.contributions.ts | Update workspace-virtual and provider gating keys to unified Session* keys. |
| src/vs/sessions/contrib/chat/browser/runScriptAction.ts | Update workspace-virtual gating to SessionWorkspaceIsVirtualContext. |
| src/vs/sessions/contrib/chat/browser/modelPicker.ts | Update combined-picker gating to SessionUsesCombinedConfigPickerContext. |
| src/vs/sessions/contrib/applyCommitsToParentRepo/browser/applyChangesToParentRepo.ts | Replace IsActiveSessionArchivedContext with SessionIsArchivedContext. |
| src/vs/sessions/common/contextkeys.ts | Define the new unified Session* context keys and remove the old ActiveSession*/ChatSession* overlay keys. |
| src/vs/sessions/browser/parts/sessionView.ts | Replace per-key autoruns with a single autorun using setActiveSessionContextKeys on the scoped context service. |
| extensions/copilot/package.json | Update Sessions-window when clauses to use sessionType / sessionProviderId / sessionIsArchived. |
| .github/instructions/sessions.instructions.md | Update contributor instructions to reflect the new context key names. |
Copilot's findings
- Files reviewed: 27/27 changed files
- Comments generated: 2
Comment on lines
11
to
+16
| export const IsNewChatSessionContext = new RawContextKey<boolean>('isNewChatSession', true); | ||
| export const ActiveSessionProviderIdContext = new RawContextKey<string>('activeSessionProviderId', '', localize('activeSessionProviderId', "The provider ID of the active session")); | ||
| export const ActiveSessionTypeContext = new RawContextKey<string>('activeSessionType', '', localize('activeSessionType', "The session type of the active session")); | ||
| export const ActiveSessionWorkspaceIsVirtualContext = new RawContextKey<boolean>('activeSessionWorkspaceIsVirtual', true, localize('activeSessionWorkspaceIsVirtual', "Whether the active session's workspace is virtual")); | ||
| export const IsActiveSessionArchivedContext = new RawContextKey<boolean>('isActiveSessionArchived', false, localize('isActiveSessionArchived', "Whether the active session is archived (marked as done)")); | ||
| export const ActiveSessionHasGitRepositoryContext = new RawContextKey<boolean>('activeSessionHasGitRepository', false, localize('activeSessionHasGitRepository', "Whether the active session has an associated git repository")); | ||
| export const ActiveSessionHasGitSyncActionRunningContext = new RawContextKey<boolean>('activeSessionHasGitSyncActionRunning', false, localize('activeSessionHasGitSyncActionRunning', "Whether the active session has a git sync action currently running")); | ||
| export const ActiveSessionUsesCombinedConfigPickerContext = new RawContextKey<boolean>('activeSessionUsesCombinedConfigPicker', false, localize('activeSessionUsesCombinedConfigPicker', "Whether the active session's provider offers a combined mode and model configuration picker (used on phone layouts in place of the standalone pickers)")); | ||
| export const ChatSessionProviderIdContext = new RawContextKey<string>('chatSessionProviderId', '', localize('chatSessionProviderId', "The provider ID of a session in context menu overlays")); | ||
| export const ChatSessionTypeContext = new RawContextKey<string>('chatSessionType', '', localize('chatSessionType', "The session type of a session in context menu overlays")); | ||
| export const ChatSessionSupportsRenameContext = new RawContextKey<boolean>('chatSessionSupportsRename', false, localize('chatSessionSupportsRename', "Whether a session in context menu overlays can be renamed")); | ||
| export const ChatSessionSupportsDeleteContext = new RawContextKey<boolean>('chatSessionSupportsDelete', false, localize('chatSessionSupportsDelete', "Whether a session in context menu overlays can be deleted")); | ||
| export const SessionProviderIdContext = new RawContextKey<string>('sessionProviderId', '', localize('sessionProviderId', "The provider ID of the session in scope (the active session globally, or a specific session within an isolated component such as the session view or a context menu overlay)")); | ||
| export const SessionTypeContext = new RawContextKey<string>('sessionType', '', localize('sessionType', "The session type of the session in scope (the active session globally, or a specific session within an isolated component such as the session view or a context menu overlay)")); | ||
| export const SessionWorkspaceIsVirtualContext = new RawContextKey<boolean>('sessionWorkspaceIsVirtual', true, localize('sessionWorkspaceIsVirtual', "Whether the session's workspace is virtual")); | ||
| export const SessionHasGitRepositoryContext = new RawContextKey<boolean>('sessionHasGitRepository', false, localize('sessionHasGitRepository', "Whether the session has an associated git repository")); | ||
| export const SessionHasGitSyncActionRunningContext = new RawContextKey<boolean>('sessionHasGitSyncActionRunning', false, localize('sessionHasGitSyncActionRunning', "Whether the session has a git sync action currently running")); |
Comment on lines
6293
to
6297
| { | ||
| "command": "github.copilot.claude.sessions.rename", | ||
| "when": "chatSessionType == claude-code && chatSessionProviderId == default-copilot", | ||
| "when": "sessionType == claude-code && sessionProviderId == default-copilot", | ||
| "group": "1_edit@4" | ||
| }, |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Copilot Generated Description:Refactor context keys for session management by renaming and consolidating keys for clarity and consistency across the application. This includes updates to context keys related to session types and providers. Adjustments made to imports and usage throughout the codebase to reflect these changes.