$ fssg build --deterministic --validate |

How to Design Reliable Keyboard Shortcuts for a Cross-Platform AI CLI

IOSM

A keyboard shortcut in an AI CLI is not decoration. It is a control-plane input.

When a model is streaming, tools are running, and the terminal is holding mutable session state, interrupt, steer, suspend, and select model are operational commands. If a terminal swallows one chord or an operating system cannot implement the action, the failure is larger than a minor UX defect. The operator loses a predictable way to control execution.

While reviewing the current IOSM CLI keybinding layer, I found a useful design pattern: bind actions to several acceptable inputs, normalize configuration at the boundary, and degrade unsupported capabilities explicitly. This sounds small. It is the difference between a shortcut table and an input protocol.

The wrong abstraction is key → callback

The simplest implementation starts with a key:

Ctrl+P -> next model
Ctrl+Z -> suspend
Ctrl+L -> model selector

That model assumes the same byte sequence reaches the application in every terminal. It also assumes the named action exists on every operating system. Neither assumption is safe.

IOSM CLI uses the opposite direction. It defines application actions first—cycleModelForward, cycleModelBackward, selectModel, expandTools, toggleThinking, steer, suspend—then maps each action to one or more keys. The runtime asks whether an input matches an action; features do not own raw terminal sequences.

cycleModelForward: ["ctrl+p", "alt+p"],
cycleModelBackward: ["shift+ctrl+p", "alt+shift+p"],
selectModel: ["ctrl+l", "alt+l"],
expandTools: ["ctrl+o", "alt+o"],
toggleThinking: ["ctrl+t", "alt+t"]

This inversion creates a stable semantic layer. A future terminal adapter can change inputs without rewriting model selection, tool-panel state, or session logic. Documentation can show the effective bindings for an action instead of claiming that one physical chord is universal.

Fallbacks are compatibility paths

Several control combinations are not equally reliable across terminal emulators, shells, multiplexers, remote sessions, and operating systems. IOSM CLI therefore pairs vulnerable Ctrl chords with Alt alternatives. On macOS, steering uses Ctrl+Enter with Ctrl+\ as a fallback when extended key reporting is unavailable. Image paste uses Ctrl+V on Unix-like systems and Alt+V on Windows.

The important design choice is that these are not hidden retries. Both inputs are declared members of the same action:

input(ctrl+p) ─┐
                ├─> action(cycleModelForward)
input(alt+p)  ─┘

A fallback should preserve semantics, not approximate them. If Alt+P opens a different selector and merely lets the user reach the next model eventually, it is not a real fallback. Compatibility paths must terminate in the same action and state transition.

This also changes testing. The invariant is no longer “Ctrl+P works.” It becomes:

for every configured key K of action A:
    decode(K) -> A
    execute(A) -> the same state transition

That is a much stronger contract.

Normalize configuration once

User configuration creates a second compatibility problem. Names drift. Documentation evolves. People write Control+P, ctrl+p, or Option+P. Older examples may use key -> action; newer configuration may prefer action -> key(s).

The current IOSM CLI loader handles this at one boundary. It:

  • trims and lowercases action tokens;
  • ignores spaces, underscores, and hyphens when resolving action names;
  • normalizes Control to ctrl, Option to alt, and Return to enter;
  • accepts a string or an array of keys;
  • deduplicates normalized alternatives;
  • recognizes aliases such as nextModel, previousModel, and openModelSelector;
  • preserves the older reverse mapping format.

This is the right place for tolerance. The rest of the runtime should receive one canonical vocabulary.

{
  "cycleModelForward": ["ctrl+p", "alt+p"],
  "selectModel": ["ctrl+l", "alt+l"]
}

I would not spread alias handling through event handlers. Boundary normalization keeps the core strict while allowing the interface to remain compatible. The same principle appears throughout reliable agent runtimes: accept a bounded set of external representations, convert them once, and execute against a narrow internal contract.

Unsupported is a capability state

Ctrl+Z exposes a more important distinction. Suspending a process on Unix relies on job-control signals. Windows terminals do not provide the same path.

Pretending otherwise would produce a binding that exists in help text but cannot complete its action. IOSM CLI instead leaves the default suspend binding empty on Windows. The handler also guards the operation and shows a warning if it is reached there. On Unix, it stops the TUI before sending SIGTSTP; if suspension fails, it restores the interface rather than leaving the terminal broken.

That gives three explicit states:

State Meaning Correct behavior
bound platform can execute the action advertise and accept the keys
remapped capability exists, but another chord is safer advertise the effective alternative
unsupported platform cannot provide the action expose no false default; fail visibly if invoked

This is capability negotiation at a local boundary. The application should not confuse “no binding” with “feature forgotten,” or “input received” with “operation supported.”

The same distinction matters in agent tools. A runtime may know the name of an operation while the current environment cannot provide its semantics. Honest degradation is safer than a nominally uniform interface.

Help must render runtime truth

Shortcut documentation becomes stale when it is maintained as a separate list. The IOSM CLI /hotkeys surface renders active values, including platform-specific choices such as image paste. That is more than convenience: it lets the operator inspect the control contract of the running process.

A reliable CLI should derive three surfaces from the same action map:

  1. input matching;
  2. user-visible hints and /hotkeys output;
  3. tests for defaults, aliases, overrides, and platform branches.

If these surfaces have independent constants, drift is inevitable. The code can accept Alt+P while startup help still insists on Ctrl+P, or documentation can promise suspend on a platform where the default map disables it.

I use a simple rule: the effective configuration is the documentation source at runtime. Static docs explain the model and common defaults. The process itself reports what is actually active.

Conflicts need a policy, not luck

Action-first mappings also make collisions visible. If a user assigns one chord to two application actions, matching order can silently choose a winner. If an extension registers the same shortcut as a built-in action, ownership becomes ambiguous.

The current repository establishes a strong normalization and mapping foundation, but collision diagnostics are a natural next hardening step. A configuration validator could construct the reverse index:

{
  "ctrl+p": ["cycleModelForward", "openProjectPalette"]
}

It could then classify collisions:

  • reject two global actions sharing one input;
  • allow the same chord in disjoint UI contexts;
  • require an explicit priority when an extension shadows a built-in action;
  • show the resolved owner in /hotkeys.

This is a design extension, not a claim about a released IOSM CLI feature. The repository verifies normalization, aliases, alternative keys, user overrides, and platform-specific defaults; a full context-aware conflict policy would require another layer.

Small controls deserve systems thinking

It is easy to treat hotkeys as polish added after the runtime works. I see the opposite. The moment an AI tool can mutate files, run processes, or continue autonomously, operator controls become part of execution safety.

A dependable shortcut system therefore needs the same properties as any other protocol boundary:

  • stable semantic action names;
  • canonical input normalization;
  • equivalent compatibility paths;
  • explicit platform capabilities;
  • observable effective configuration;
  • deterministic conflict resolution.

IOSM CLI already implements the first five strongly enough to show the architecture. The broader lesson is not “add more shortcuts.” It is to stop modeling terminal input as a bag of callbacks.

A terminal-native agent should know the difference between a key it received, an action the operator requested, and a capability the environment can actually execute. Once those are separate, cross-platform control stops being a collection of exceptions and becomes an engineering contract.

Sources

FACET AI CLI Terminal
facet@ai:~$