M31: illogical tui (tabs, splits and needs-you in any terminal) #50

Closed
opened 2026-10-02 07:58:06 +00:00 by jhgaylor · 1 comment
Owner

Depends on: #48 (S19, done). Works without #49, but heavy output wastes CPU until #49 lands.
Blocks: #51 (M32: copy mode)

TUI track. illogical in any terminal, as herdr does: illogical tui draws tabs, splits and a "needs you" sidebar, over the same socket and protocol as the web client. It works locally, over ssh, or against another host with --host.


  • Where: crates/cli/src/tui/; new dependencies ratatui and crossterm. Start from spikes/s19-tui (about 950 lines that already work).
  • Engine: one GhosttyEngine per pane, fed snapshot and output frames; size resizes it.
    • Add a cells() walk over libghostty's RenderState to crates/vt, next to the formatter, so the client and the daemon share one wrapper.
    • Palette colors stay palette indexes, so the outer terminal's theme applies.
    • Skip drawing a pane while its program has synchronized output (mode 2026) on.
  • Layout: the daemon's TabView.layout for the size we view; its one-cell gaps are the dividers. view claims the size when the TUI is opened, focused or typed in, like any client. State is hello/state, plus delta through State::apply (M23).
  • Sidebar: sessions and tabs with each tab's worst attention (● ✓ ◌), then needs you from PaneInfo.reason with its headline. On a selected entry: Enter goes there; allow, deny and dismiss go through /api/attention/act (M24).
  • Keys: read as events (crossterm, asking the outer terminal for kitty keyboard flags), then encoded for each pane's own modes by libghostty's key::Encoder::set_options_from_terminal. That covers DECCKM, modifyOtherKeys and the kitty protocol. Ctrl-] is the menu key (and twice types it), as in illogical attach. Bracketed paste is passed through when the pane wants it.
  • Mouse:
    • click to focus;
    • drag a divider (resize_split);
    • drag a pane's top edge onto another pane's edge (move_pane);
    • wheel: the program's own (through mouse::Encoder), arrow keys on the alternate screen, or local scrollback;
    • right-click: the web client's pane and tab menus (split, close, policy, rename, purge, integration, dismiss).
  • Blocks:
    • agent blocks as a plain transcript of messages and tool calls, with approve/deny on keys;
    • browser blocks as a line with their URL.
  • Also: cursor shape and color; the pane title in the status line; --session to start in one.
  • Done when:
    • Claude Code, Neovim (kitty keys) and htop behave in TUI panes as they do in Ghostty directly, including Claude Code's Shift+Enter;
    • a layout is edited from the TUI and the web client at once and both stay right (an e2e test like tmux.spec.ts, driving the TUI through a PTY);
    • ssh geek illogical tui works in an 80x24 terminal and in a 300x80 one;
    • a Claude Code approval is answered from the sidebar without opening its pane;
    • a frame stays under 2 ms (build and write) with four busy panes at 200x50 (bench.sh).
**Depends on:** #48 (S19, done). Works without #49, but heavy output wastes CPU until #49 lands. **Blocks:** #51 (M32: copy mode) *TUI track. illogical in any terminal, as herdr does: `illogical tui` draws tabs, splits and a "needs you" sidebar, over the same socket and protocol as the web client. It works locally, over ssh, or against another host with `--host`.* -------- - **Where:** `crates/cli/src/tui/`; new dependencies ratatui and crossterm. Start from `spikes/s19-tui` (about 950 lines that already work). - **Engine:** one `GhosttyEngine` per pane, fed snapshot and output frames; `size` resizes it. - Add a `cells()` walk over libghostty's `RenderState` to `crates/vt`, next to the formatter, so the client and the daemon share one wrapper. - Palette colors stay palette indexes, so the outer terminal's theme applies. - Skip drawing a pane while its program has synchronized output (mode 2026) on. - **Layout:** the daemon's `TabView.layout` for the size we `view`; its one-cell gaps are the dividers. `view` claims the size when the TUI is opened, focused or typed in, like any client. State is `hello`/`state`, plus `delta` through `State::apply` (M23). - **Sidebar:** sessions and tabs with each tab's worst attention (● ✓ ◌), then *needs you* from `PaneInfo.reason` with its headline. On a selected entry: Enter goes there; allow, deny and dismiss go through `/api/attention/act` (M24). - **Keys:** read as events (crossterm, asking the outer terminal for kitty keyboard flags), then encoded for each pane's own modes by libghostty's `key::Encoder::set_options_from_terminal`. That covers DECCKM, modifyOtherKeys and the kitty protocol. Ctrl-] is the menu key (and twice types it), as in `illogical attach`. Bracketed paste is passed through when the pane wants it. - **Mouse:** - click to focus; - drag a divider (`resize_split`); - drag a pane's top edge onto another pane's edge (`move_pane`); - wheel: the program's own (through `mouse::Encoder`), arrow keys on the alternate screen, or local scrollback; - right-click: the web client's pane and tab menus (split, close, policy, rename, purge, integration, dismiss). - **Blocks:** - agent blocks as a plain transcript of messages and tool calls, with approve/deny on keys; - browser blocks as a line with their URL. - **Also:** cursor shape and color; the pane title in the status line; `--session` to start in one. - **Done when:** - Claude Code, Neovim (kitty keys) and htop behave in TUI panes as they do in Ghostty directly, including Claude Code's Shift+Enter; - a layout is edited from the TUI and the web client at once and both stay right (an e2e test like `tmux.spec.ts`, driving the TUI through a PTY); - `ssh geek illogical tui` works in an 80x24 terminal and in a 300x80 one; - a Claude Code approval is answered from the sidebar without opening its pane; - a frame stays under 2 ms (build and write) with four busy panes at 200x50 (`bench.sh`).
Author
Owner

Done 2026-10-02, merged in 15c3331. illogical tui [--session S] (--host for any host). docs/features.md has the keys and the mouse.

What landed:

  • Engine: crates/vt/src/ghostty/view.rs, the client side of the shared libghostty wrapper.
    • cells() over the render state (palette colors stay indexes);
    • the cursor's shape and color;
    • scrollback;
    • key, mouse, paste and focus encoding through libghostty's encoders, for each pane's own modes.
  • Kitty keys: the daemon used to drop the kitty keyboard reply for everyone. Now attach takes kitty_keys, and a pane answers while such a client is attached.
  • TUI: crates/cli/src/tui/ (ratatui), about 2,500 lines with tests.
    • sidebar with each tab's worst attention, and needs you with allow / allow always / deny / dismiss;
    • Ctrl-] commands (? lists them), and the web client's pane, tab and session menus;
    • mouse: focus, divider drag, Alt-drag to move a pane, wheel to scroll back / page / the program;
    • zoom, rename, --session;
    • agent transcripts with a/A/d/i, and browser blocks as their address;
    • cursor shape and color, the title in the status line, synchronized output;
    • #49's capped zstd snapshots and #52's acks.

Against done-when:

  • Claude Code (2.1.287) in a TUI pane: Shift+Enter (kitty CSI 13;2u) adds a line without submitting, and Ctrl-C clears and exits.
    • Neovim edits, modes and redraws are right; it gets kitty keys now that the query is answered (daemon test programs_hear_of_kitty_keys_…).
    • htop isn't installed here, so top and less stood in.
    • This was through tmux as the outer terminal, with kitty sequences sent as Ghostty sends them, not in Ghostty itself.
  • TUI and web client together: web/e2e/tui.spec.ts runs the TUI in tmux beside the browser. Splits, typing, renames and closes go both ways. The full browser suite passes: 111 passed, 9 skipped.
  • Sizes:
    • Not checked as written: geek runs no ssh server (port 22 refused, no Tailscale SSH), so ssh geek illogical tui itself wasn't run.
    • What was checked: the TUI in a PTY at 80x24 (sidebar narrows to 20 columns) and 300x80, --host http://… against another daemon, and the static musl build.
  • An approval answered from the sidebar: done with the fake ACP agent's permission request: Ctrl-] w, down to the entry, a, and the agent ran it, without opening its pane.
  • Frame time: release, four flooding panes at 200x50 (spikes/s19-tui/bench.sh with TUI_BIN): build p99 0.86 ms; build and write p50 0.94 ms, p99 1.5 ms (max 3.4); 42% of a core.

Differences from the issue: a pane is moved with Alt-drag or Move pane… then a click, because panes have no title bar to drag by. Questions and forms from agents are answered in the browser; the TUI shows them as a line.

Done 2026-10-02, merged in 15c3331. `illogical tui [--session S]` (`--host` for any host). docs/features.md has the keys and the mouse. **What landed:** - **Engine:** `crates/vt/src/ghostty/view.rs`, the client side of the shared libghostty wrapper. - `cells()` over the render state (palette colors stay indexes); - the cursor's shape and color; - scrollback; - key, mouse, paste and focus encoding through libghostty's encoders, for each pane's own modes. - **Kitty keys:** the daemon used to drop the kitty keyboard reply for everyone. Now `attach` takes `kitty_keys`, and a pane answers while such a client is attached. - **TUI:** `crates/cli/src/tui/` (ratatui), about 2,500 lines with tests. - sidebar with each tab's worst attention, and *needs you* with allow / allow always / deny / dismiss; - Ctrl-] commands (`?` lists them), and the web client's pane, tab and session menus; - mouse: focus, divider drag, Alt-drag to move a pane, wheel to scroll back / page / the program; - zoom, rename, `--session`; - agent transcripts with a/A/d/i, and browser blocks as their address; - cursor shape and color, the title in the status line, synchronized output; - #49's capped zstd snapshots and #52's acks. **Against done-when:** - **Claude Code** (2.1.287) in a TUI pane: Shift+Enter (kitty CSI 13;2u) adds a line without submitting, and Ctrl-C clears and exits. - Neovim edits, modes and redraws are right; it gets kitty keys now that the query is answered (daemon test `programs_hear_of_kitty_keys_…`). - htop isn't installed here, so `top` and `less` stood in. - This was through tmux as the outer terminal, with kitty sequences sent as Ghostty sends them, not in Ghostty itself. - **TUI and web client together:** `web/e2e/tui.spec.ts` runs the TUI in tmux beside the browser. Splits, typing, renames and closes go both ways. The full browser suite passes: 111 passed, 9 skipped. - **Sizes:** - **Not checked as written:** geek runs no ssh server (port 22 refused, no Tailscale SSH), so `ssh geek illogical tui` itself wasn't run. - What was checked: the TUI in a PTY at 80x24 (sidebar narrows to 20 columns) and 300x80, `--host http://…` against another daemon, and the static musl build. - **An approval answered from the sidebar:** done with the fake ACP agent's permission request: Ctrl-] w, down to the entry, `a`, and the agent ran it, without opening its pane. - **Frame time:** release, four flooding panes at 200x50 (`spikes/s19-tui/bench.sh` with `TUI_BIN`): build p99 0.86 ms; build and write p50 0.94 ms, p99 1.5 ms (max 3.4); 42% of a core. **Differences from the issue:** a pane is moved with Alt-drag or *Move pane…* then a click, because panes have no title bar to drag by. Questions and forms from agents are answered in the browser; the TUI shows them as a line.
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jhgaylor/illogical#50
No description provided.