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

@ -8,6 +8,7 @@ import type {
VoiceRecordResponse
} from '../gatewayTypes.js'
import { writeOsc52Clipboard } from '../lib/osc52.js'
import { isAction, isMac } from '../lib/platform.js'
import { getInputSelection } from './inputSelectionStore.js'
import type { InputHandlerContext, InputHandlerResult } from './interfaces.js'
@ -224,10 +225,6 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
return terminal.scrollWithSelection(key.pageUp ? -step : step)
}
if (key.ctrl && key.shift && ch.toLowerCase() === 'c') {
return copySelection()
}
if (key.escape && terminal.hasSelection) {
return clearSelection()
}
@ -244,7 +241,7 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
return
}
if (isCtrl(key, ch, 'c')) {
if (isAction(key, ch, 'c') || (key.ctrl && key.shift && ch.toLowerCase() === 'c')) {
if (terminal.hasSelection) {
return copySelection()
}
@ -254,6 +251,21 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
if (inputSel && inputSel.end > inputSel.start) {
writeOsc52Clipboard(inputSel.value.slice(inputSel.start, inputSel.end))
inputSel.clear()
}
return
}
if (isCtrl(key, ch, 'c')) {
if (!isMac && terminal.hasSelection) {
return copySelection()
}
const inputSel = getInputSelection()
if (!isMac && inputSel && inputSel.end > inputSel.start) {
writeOsc52Clipboard(inputSel.value.slice(inputSel.start, inputSel.end))
inputSel.clear()
return
}
@ -274,11 +286,11 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
return actions.die()
}
if (isCtrl(key, ch, 'd')) {
if (isAction(key, ch, 'd') || isCtrl(key, ch, 'd')) {
return actions.die()
}
if (isCtrl(key, ch, 'l')) {
if (isAction(key, ch, 'l') || isCtrl(key, ch, 'l')) {
if (actions.guardBusySessionSwitch()) {
return
}
@ -288,11 +300,11 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
return actions.newSession()
}
if (isCtrl(key, ch, 'b')) {
if (isAction(key, ch, 'b') || isCtrl(key, ch, 'b')) {
return voice.recording ? voiceStop() : voiceStart()
}
if (isCtrl(key, ch, 'g')) {
if (isAction(key, ch, 'g') || isCtrl(key, ch, 'g')) {
return cActions.openEditor()
}
@ -311,7 +323,7 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
return
}
if (isCtrl(key, ch, 'k') && cRefs.queueRef.current.length && live.sid) {
if ((isAction(key, ch, 'k') || isCtrl(key, ch, 'k')) && cRefs.queueRef.current.length && live.sid) {
const next = cActions.dequeue()
if (next) {