fix(tui): use command shortcuts on macOS

Make the Ink TUI match macOS keyboard expectations: Command handles copy and common editor/session shortcuts, while Control remains reserved for interrupt/cancel flows. Update the visible hotkey help to show platform-appropriate labels.
This commit is contained in:
kshitijk4poor 2026-04-19 12:01:36 +05:30 committed by kshitij
parent dcd763c284
commit 8c9fdedaf5
4 changed files with 65 additions and 29 deletions

View file

@ -0,0 +1,19 @@
/** Platform-aware keybinding helpers.
*
* On macOS the "action" modifier is Cmd (key.meta in Ink), on other platforms
* it is Ctrl. Ctrl+C is ALWAYS the interrupt key regardless of platform
* it must never be remapped to copy.
*/
export const isMac = process.platform === 'darwin'
/** The display label for the action modifier key. */
export const modLabel = isMac ? '⌘' : 'Ctrl'
/** True when the platform action-modifier is pressed (Cmd on macOS, Ctrl elsewhere). */
export const isActionMod = (key: { ctrl: boolean; meta: boolean }): boolean =>
isMac ? key.meta : key.ctrl
/** Match action-modifier + a single character (case-insensitive). */
export const isAction = (key: { ctrl: boolean; meta: boolean }, ch: string, target: string): boolean =>
isActionMod(key) && ch.toLowerCase() === target