Export terminal chat context key strings to prevent hardcoded strings and layering violations#283907
Merged
meganrogge merged 2 commits intomainfrom Dec 16, 2025
Merged
Conversation
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Ensure context keys are part of an enum
Export terminal chat context key strings to prevent hardcoded strings and layering violations
Dec 16, 2025
meganrogge
approved these changes
Dec 16, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a layering violation issue by properly exporting terminal chat context key strings through the terminalContribExports.ts bridge file. Previously, code in the terminal/ layer was using hardcoded string literals ('hasHiddenChatTerminals', 'hasChatTerminals') instead of referencing the enum values from TerminalChatContextKeyStrings in terminalContrib/chat. Direct imports would have violated the layering architecture, so the solution follows the existing pattern of re-exporting these values through terminalContribExports.ts.
Key changes:
- Added
TerminalContribContextKeyStringsenum toterminalContribExports.tsthat re-exportsChatHasTerminalsandChatHasHiddenTerminals - Replaced hardcoded strings with enum references in
terminalContextKey.ts,terminalTabbedView.ts, andterminalMenus.ts
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/vs/workbench/contrib/terminal/terminalContribExports.ts |
Added TerminalContribContextKeyStrings enum exporting chat context keys to provide layer-safe access |
src/vs/workbench/contrib/terminal/common/terminalContextKey.ts |
Replaced hardcoded 'hasHiddenChatTerminals' string with enum reference in shouldShowViewInlineActions expression |
src/vs/workbench/contrib/terminal/browser/terminalTabbedView.ts |
Replaced hardcoded 'hasHiddenChatTerminals' string with enum reference in context change listener |
src/vs/workbench/contrib/terminal/browser/terminalMenus.ts |
Replaced hardcoded 'hasHiddenChatTerminals' string with enum reference in menu visibility condition |
dmitrivMS
approved these changes
Dec 16, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Context key strings for terminal chat features were hardcoded as strings (
'hasHiddenChatTerminals','hasChatTerminals') instead of referencing theTerminalChatContextKeyStringsenum. Direct imports fromterminalContrib/chatcaused layering violations.Changes
Exported context key strings via
terminalContribExports.tsTerminalContribContextKeyStringsenum exportingChatHasTerminalsandChatHasHiddenTerminalsTerminalContribCommandIdandTerminalContribSettingIdReplaced hardcoded strings in three files:
terminalMenus.tsterminalTabbedView.tsterminalContextKey.tsThis provides type safety, prevents typos, and maintains proper layer separation between
terminal/andterminalContrib/.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.