diff --git a/src/components/terminal/ActionLinkMenu.tsx b/src/components/terminal/ActionLinkMenu.tsx index fb91e030..45488c3a 100644 --- a/src/components/terminal/ActionLinkMenu.tsx +++ b/src/components/terminal/ActionLinkMenu.tsx @@ -48,11 +48,11 @@ export default function ActionLinkMenu({ state, onClose }: ActionLinkMenuProps) if (!state) return null; - const { x, y, link, actions, execute } = state; + const { x, y, link, actions, prepare } = state; const pos = computeMenuPosition(x, y, ref.current); const handleAction = (actionId: string) => { - execute(actionId); + prepare(actionId); onClose(); }; diff --git a/src/components/terminal/ActionLinkTooltip.tsx b/src/components/terminal/ActionLinkTooltip.tsx index 950460b6..ac3cad36 100644 --- a/src/components/terminal/ActionLinkTooltip.tsx +++ b/src/components/terminal/ActionLinkTooltip.tsx @@ -112,6 +112,9 @@ export default function ActionLinkTooltip({ state }: ActionLinkTooltipProps) { {t("terminal.click")} → + + {t("terminal.actionLinkPrepareCommand")} + void>(() => {}); const pasteTextRef = useRef<(text: string, options?: { skipDialog?: boolean }) => void>(() => {}); - const executeActionCommandRef = useRef<((command: string) => void) | null>(null); const disconnectedRef = useRef(false); const reconnectingRef = useRef(false); const preservedReconnectContentRef = useRef(null); @@ -724,10 +723,6 @@ export default function XTerminal({ syncSuggestionsWithInputState(); }; - executeActionCommandRef.current = (command: string) => { - void executeInputCommand(command).catch(() => {}); - }; - const isCredentialPromptInputMode = () => { if (credentialPromptInputUntilRef.current > Date.now()) { return true; @@ -2054,7 +2049,6 @@ export default function XTerminal({ clearCredentialPromptInputMode(); shellIntegrationRef.current.enabled = false; shellIntegrationRef.current.commandRunning = false; - executeActionCommandRef.current = null; replaceInputCommandRef.current = null; pasteTextRef.current = () => {}; resetCredentialAutofill(); @@ -2136,7 +2130,7 @@ export default function XTerminal({ terminalInstance, terminalSettings, sessionId, - executeActionCommandRef, + replaceInputCommandRef, performanceMode === "overloaded" || !visible, ); diff --git a/src/hooks/useActionLinks.ts b/src/hooks/useActionLinks.ts index 2b0f3c94..0e7b0e30 100644 --- a/src/hooks/useActionLinks.ts +++ b/src/hooks/useActionLinks.ts @@ -30,7 +30,7 @@ export interface MenuState { y: number; link: ActionLink; actions: ResolvedAction[]; - execute: (actionId: string) => void; + prepare: (actionId: string) => void; } export interface UseActionLinksResult { @@ -48,7 +48,7 @@ export function useActionLinks( terminal: Terminal | null, terminalSettings: AppSettings["terminal"], _sessionId: string, - executeCommandRef: React.RefObject<((command: string) => void) | null>, + prepareCommandRef: React.RefObject<((command: string) => void) | null>, suspended = false, ): UseActionLinksResult { const addonRef = useRef(null); @@ -87,13 +87,13 @@ export function useActionLinks( allowCtrlOrMetaClickExecute: true, allowAltClickMenu: true, fallbackAltClickToDefaultAction: true, - executeCommand: (command) => executeCommandRef.current?.(command), + executeCommand: (command) => prepareCommandRef.current?.(command), showTooltip: ({ event, link }) => { setTooltipState({ x: event.clientX, y: event.clientY, link }); }, hideTooltip: () => setTooltipState(null), showMenu: ({ event, link, actions, execute }) => { - setMenuState({ x: event.clientX, y: event.clientY, link, actions, execute }); + setMenuState({ x: event.clientX, y: event.clientY, link, actions, prepare: execute }); }, }; @@ -109,7 +109,7 @@ export function useActionLinks( setTooltipState(null); setMenuState(null); }; - }, [terminal, enabled, executeCommandRef]); + }, [terminal, enabled, prepareCommandRef]); // Sync matchers and enabled state when settings change useEffect(() => { diff --git a/src/lib/actionLinksMatcher.ts b/src/lib/actionLinksMatcher.ts index 6ff19a12..6f3d0f99 100644 --- a/src/lib/actionLinksMatcher.ts +++ b/src/lib/actionLinksMatcher.ts @@ -22,7 +22,7 @@ function defaultTooltip(ctx: ActionContext, defaultAction?: ActionDefinition): s const lines = [ `Type: ${ctx.kind}`, `Value: ${ctx.value}`, - `Ctrl/Cmd + Click to execute default action`, + `Ctrl/Cmd + Click to prepare default command`, `Alt + Click to view more actions`, ];