diff --git a/webview-ui/src/config/platform-configs.json b/webview-ui/src/config/platform-configs.json index c566477a..3c0f43cd 100644 --- a/webview-ui/src/config/platform-configs.json +++ b/webview-ui/src/config/platform-configs.json @@ -3,12 +3,14 @@ "messageEncoding": "none", "showNavbar": false, "postMessageHandler": "vscode", - "togglePlanActKeys": "Meta+Shift+a" + "togglePlanActKeys": "Meta+Shift+a", + "supportsTerminalMentions": true }, "standalone": { "messageEncoding": "json", "showNavbar": true, "postMessageHandler": "standalone", - "togglePlanActKeys": "Meta+Shift+p" + "togglePlanActKeys": "Meta+Shift+p", + "supportsTerminalMentions": false } } diff --git a/webview-ui/src/config/platform.config.ts b/webview-ui/src/config/platform.config.ts index cd1819a1..935ac937 100644 --- a/webview-ui/src/config/platform.config.ts +++ b/webview-ui/src/config/platform.config.ts @@ -7,6 +7,7 @@ export interface PlatformConfig { encodeMessage: MessageEncoder decodeMessage: MessageDecoder togglePlanActKeys: string + supportsTerminalMentions: boolean } // Internal type for JSON structure (not exported) @@ -15,6 +16,7 @@ type PlatformConfigJson = { showNavbar: boolean postMessageHandler: "vscode" | "standalone" togglePlanActKeys: string + supportsTerminalMentions: boolean } type PlatformConfigs = Record @@ -81,6 +83,7 @@ export const PLATFORM_CONFIG: PlatformConfig = { encodeMessage: messageEncoders[selectedConfig.messageEncoding], decodeMessage: messageDecoders[selectedConfig.messageEncoding], togglePlanActKeys: selectedConfig.togglePlanActKeys, + supportsTerminalMentions: selectedConfig.supportsTerminalMentions, } type MessageEncoding = "none" | "json" diff --git a/webview-ui/src/utils/context-mentions.ts b/webview-ui/src/utils/context-mentions.ts index 6a3686c1..ac2ec45b 100644 --- a/webview-ui/src/utils/context-mentions.ts +++ b/webview-ui/src/utils/context-mentions.ts @@ -1,6 +1,7 @@ import { mentionRegex } from "@shared/context-mentions" import { Fzf } from "fzf" import * as path from "path" +import { PLATFORM_CONFIG } from "@/config/platform.config" export interface SearchResult { path: string @@ -96,17 +97,22 @@ export interface ContextMenuQueryItem { description?: string } -const DEFAULT_CONTEXT_MENU_OPTIONS = [ - ContextMenuOptionType.URL, - ContextMenuOptionType.Problems, - ContextMenuOptionType.Terminal, - ContextMenuOptionType.Git, - ContextMenuOptionType.Folder, - ContextMenuOptionType.File, -] +function getContextMenuEntries(): ContextMenuOptionType[] { + const entries = [ + ContextMenuOptionType.URL, + ContextMenuOptionType.Problems, + ContextMenuOptionType.Git, + ContextMenuOptionType.Folder, + ContextMenuOptionType.File, + ] + if (PLATFORM_CONFIG.supportsTerminalMentions) { + entries.splice(2, 0, ContextMenuOptionType.Terminal) + } + return entries +} export function getContextMenuOptionIndex(option: ContextMenuOptionType) { - return DEFAULT_CONTEXT_MENU_OPTIONS.findIndex((item) => item === option) + return getContextMenuEntries().findIndex((item) => item === option) } export function getContextMenuOptions( @@ -163,7 +169,7 @@ export function getContextMenuOptions( return commits.length > 0 ? [workingChanges, ...commits] : [workingChanges] } - return DEFAULT_CONTEXT_MENU_OPTIONS.map((type) => ({ type })) + return getContextMenuEntries().map((type) => ({ type })) } const lowerQuery = query.toLowerCase()