From a68793b6c4a9fff115ce2712f317034ddf50f1c7 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sat, 25 Apr 2026 14:55:28 -0500 Subject: [PATCH] refactor(tui): share remote shell detection Reuse the platform helper for SSH-aware copy hints so hotkey display and input handling cannot drift. --- ui-tui/src/content/hotkeys.ts | 5 ++--- ui-tui/src/lib/platform.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ui-tui/src/content/hotkeys.ts b/ui-tui/src/content/hotkeys.ts index e6311da0f47..4a52414cf41 100644 --- a/ui-tui/src/content/hotkeys.ts +++ b/ui-tui/src/content/hotkeys.ts @@ -1,6 +1,5 @@ -import { isMac } from '../lib/platform.js' +import { isMac, isRemoteShell } from '../lib/platform.js' -const isRemoteShell = Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY) const action = isMac ? 'Cmd' : 'Ctrl' const paste = isMac ? 'Cmd' : 'Alt' @@ -10,7 +9,7 @@ const copyHotkeys: [string, string][] = isMac ['Ctrl+C', 'interrupt / clear draft / exit'] ] : [ - ...(isRemoteShell ? ([['Cmd+C', 'copy selection when forwarded by the terminal']] as [string, string][]) : []), + ...(isRemoteShell() ? ([['Cmd+C', 'copy selection when forwarded by the terminal']] as [string, string][]) : []), ['Ctrl+C', 'copy selection / interrupt / clear draft / exit'] ] diff --git a/ui-tui/src/lib/platform.ts b/ui-tui/src/lib/platform.ts index c75d981d051..c8b38b0d5f0 100644 --- a/ui-tui/src/lib/platform.ts +++ b/ui-tui/src/lib/platform.ts @@ -34,7 +34,7 @@ export const isMacActionFallback = ( export const isAction = (key: { ctrl: boolean; meta: boolean; super?: boolean }, ch: string, target: string): boolean => isActionMod(key) && ch.toLowerCase() === target -const isRemoteShell = (env: NodeJS.ProcessEnv = process.env): boolean => +export const isRemoteShell = (env: NodeJS.ProcessEnv = process.env): boolean => Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.SSH_TTY) export const isCopyShortcut = (