Skip to content

fix(tui): wire up features that were built but never reachable - #490

Merged
emal-avala merged 2 commits into
mainfrom
fix/tui-dead-wiring
Jul 25, 2026
Merged

fix(tui): wire up features that were built but never reachable#490
emal-avala merged 2 commits into
mainfrom
fix/tui-dead-wiring

Conversation

@emal-avala

Copy link
Copy Markdown
Member

Summary

A TUI audit turned up several capabilities that exist in the tree but are never actually connected — code that is written, sometimes tested, and unreachable at runtime. This wires them up and pins each contract with tests.

What was dead, and what it does now

Feature Before After
Ctrl+L Documented in KEYBINDINGS.md, no handler existed Forces a full repaint (invalidates the layout cache + clears the terminal)
Kitty keyboard protocol Detected and reported, but PushKeyboardEnhancementFlags was never called anywhere in the repo — so the Ctrl+Enter/Shift+Enter disambiguation the UI advertises was never requested Pushed on entry, popped on exit / restore / panic, balanced so we never pop flags we didn't push
Desktop notifications NotifierService fully implemented and tested, never constructed Notifies when attention is required and the terminal is unfocused: permission/plan/question modal opens, and turn completion
NO_COLOR Mapped to 16-colour — i.e. still colour, contrary to no-color.org Real monochrome mode: drops fg/bg, preserves bold/dim/italic/underline so structure survives. Also honours CLICOLOR=0; FORCE_COLOR can override upward
Non-TTY launch Died inside enable_raw_mode() with a raw errno Fails early naming the offending stream and pointing at --prompt / --output-format json

Notes on the trickier two

Kitty protocol is deliberately not enabled on browser-engine terminal widgets embedded in code editors — they mis-encode shifted printables under this protocol. The decision is a pure function (keyboard_enhancement_allowed) so it's unit-tested rather than inferred at runtime. Push/pop ordering matches the existing teardown discipline exactly (pushed last, popped first, including in the panic hook) — a leaked keyboard mode wrecks the user's shell.

Notifications are dispatched off the event loop via spawn_blocking: the Linux/Windows backends do a synchronous which/where.exe probe and the macOS focus probe shells out, so dispatching inline would stall rendering. The gate uses the terminal's own focus-change reporting rather than the service's probe, which always returns false on Linux/Windows.

A suspected bug that turned out not to exist

The audit flagged /tasks as shadowed by the pane toggle, making the background-task CLI unreachable. Investigated: false. The line in question is a skill-shadow skip list (stopping a user skill named tasks from hijacking the command); the toggle matches bare /tasks exactly, so /tasks output 3 already falls through to the command bridge. No code change — but a regression test now pins both halves so a future edit can't introduce the bug that was suspected.

Verification

  • 565 tests pass (31 new), clippy --all-targets -- -D warnings clean, fmt --check clean.
  • New tests cover: Ctrl+L redraw, kitty push/pop escape sequences and stack balance, the enhancement allow/deny matrix, the TTY-guard matrix and message actionability, NO_COLOR/CLICOLOR/FORCE_COLOR precedence, mono attribute preservation, per-slot palette stripping, notifier decision logic, and the /tasks routing contract.
  • One existing test changed deliberately: no_color_overrides_apple_terminal now expects mono instead of 16-colour — that is the fix.

Several TUI capabilities existed in the tree but were never actually
connected. This connects them and adds tests pinning each contract.

- Ctrl+L (documented in KEYBINDINGS.md, never implemented): now forces a
  full repaint — invalidates the layout cache and clears the terminal.
- Kitty keyboard protocol was detected and reported but the enhancement
  flags were never pushed, so the Ctrl+Enter / Shift+Enter disambiguation
  the UI advertises was never requested. Now pushed last on entry and
  popped first on exit, in the restore path and the panic hook, balanced
  so we never pop flags we did not push. Deliberately skipped on
  browser-engine terminal widgets embedded in code editors, which
  mis-encode shifted printables under this protocol.
- Desktop notifications: NotifierService was implemented and tested but
  never constructed. The TUI now notifies when attention is required and
  the terminal is unfocused (permission/plan/question modal opening, turn
  completion), dispatched off the event loop since the backends probe the
  environment synchronously.
- NO_COLOR mapped to 16-colour output — i.e. still colour, contrary to
  no-color.org. Adds a real monochrome mode that drops foreground and
  background while preserving bold/dim/italic/underline, honours
  CLICOLOR=0, and lets FORCE_COLOR override detection upward.
- Entering the TUI on a non-TTY died inside enable_raw_mode with a raw
  errno. It now fails early naming the offending stream and pointing at
  --prompt / --output-format json.

Note: a suspected `/tasks` shadowing bug was investigated and does not
exist — the toggle matches the bare form exactly, so arguments already
reach the command bridge. Added a regression test pinning both halves.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

The Windows console rejects PushKeyboardEnhancementFlags outright (the
sequence is a Unix terminal concept), so the pushed flag correctly stays
false there — but the test assumed the push always succeeds and failed on
windows-latest.

Assert the real invariant instead: we record a push exactly when bytes were
emitted, and only ever pop what we pushed. Both branches are checked, so the
balance guarantee is covered on every platform rather than only where the
protocol exists.
@emal-avala
emal-avala merged commit 8aade1a into main Jul 25, 2026
13 of 15 checks passed
@emal-avala
emal-avala deleted the fix/tui-dead-wiring branch July 25, 2026 08:14
@emal-avala emal-avala mentioned this pull request Jul 25, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant