Skip to content

feat(web): add opt-in Ladybird panes for threads - #47

Merged
lgalabru merged 34 commits into
mainfrom
feat/web-panes
Nov 27, 2026
Merged

lgalabru merged 34 commits into
mainfrom
feat/web-panes

Conversation

@lgalabru

@lgalabru lgalabru commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

TL;DR

Add opt-in Ladybird web panes for the thread conversation, composer, usage and Ctrl+D controls, with terminal fallbacks. The composer supports image drops, runtime modes and update hints; activity strips share a compact layout with terminal mode. The README explains setup and how to switch back. Linux openpty calls now match both platform signatures.

Agent Trajectory

The request was to render the thread view as web pages inside Rex while preserving terminal mode. The spike settled on Ladybird's terminal renderer and the existing thread model and dispatch path, with a pane-local authenticated HTTP server.

Real Rex and Ladybird checks drove the sizing, shared backgrounds, attachment handling and composer layout. Native drops required handling Ladybird's composition input as well as browser paste and drop events. Linux CI exposed a platform difference in openpty, fixed without suppressing the lint.

Validation covers the CLI and terminal UI, server authentication and limits, attachment paths and uploads, session chart isolation, and the display layout. All four views were checked in Ladybird, including native terminal image drops.

load_thread_data gives the ThreadData the terminal view draws, so a
web pane can render the same thing instead of reading the store its
own way.
The last event seq and the conversation items' revision, in two
single-row reads. A view that polls reloads only when it moves: a full
load is about 8 ms on a 10 000-item thread.
`axel web pane THREAD` serves the thread on 127.0.0.1 from the pane's
own process and runs `terminal-browser open --no-merge` there, which
draws Chromium with the Kitty graphics protocol. The page renders the
model the terminal view draws and sends through the composer's own
dispatch, so both views route a message the same way. It is the whole
thread view in one pane: conversation, tool runs, questions, composer.

The server uses only the standard library and is bounded everywhere.
A secret in the first URL becomes an HttpOnly cookie every request
needs; the Host must match and writes must be same-origin JSON, so
other pages and DNS rebinding get nothing.

`axel panes auto|web|terminal` chooses ($AXEL_PANES overrides it).
`auto` is web where terminal-browser is installed and we're in Rex.
Without it, or when it can't draw, the pane falls back to the terminal
view and says why. `axel web serve` serves a thread to a desktop
browser, for debugging.
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
axel Ready Ready Preview Nov 27, 2026 4:13pm UTC

The web pane now runs Ladybird's terminal mode (`--headless=terminal
--temporary-profile`), which draws the page as Kitty graphics, instead
of terminal-browser. Ladybird renders the page as Chrome does, needs
nothing bundled, and is found on PATH or as Ladybird.app.

Web panes are an experimental runtime flag, off by default: `axel
panes web` turns them on, and even then they're used only where
Ladybird is installed. `$AXEL_LADYBIRD` names it explicitly, which
also keeps the Ladybird on a developer's machine out of the tests.
@lgalabru lgalabru changed the title feat: web panes — the thread view as a web page in its Rex pane feat: web panes (experimental) — the thread view drawn by Ladybird in its Rex pane Nov 26, 2026
… scale

The first web pane held the whole thread in one page at a pixel ratio
of 1: tiny on Retina, and the terminal view's layout was gone. A web
thread view now keeps the layout and labels of the terminal one: the
conversation, the composer below, the activity pane beside it. Each is
`axel web pane THREAD --view messages|composer|activity`, with
Ladybird at the pane's own device pixel ratio, read from its pixels per
cell. Each falls back to its own terminal counterpart.

The pages are redesigned. The conversation has avatars, folded thinking
and tool steps, question cards and a working indicator. The composer
shows who a message goes to. The activity pane shows each agent's
state, context, spend and last hour, the recent steps and plan limits.
Closing the web composer closes the view, as the terminal one does.
Rex 0.1.0-preview.25 panes export neither REX_SESSION nor REX_SERVER,
and a block being closed can't ask Rex which session it is in. The
composer's hang-up handler asked then, so its calls to close the
stream and tokens panes went nowhere. It now keeps the Rex address it
started with.
…'s scale

Ladybird's terminal mode keeps the pane's last row for a status line
with the page's address and port, and has no option to hide it.  It
also takes its pixel ratio only when it starts, from a terminal size
that on a phone may carry no pixels, so the page drew at ratio 1:
minuscule there.

Ladybird now runs on a pty of our own, one row taller than the pane.
What it writes to that row is dropped, and so is Ctrl-L, which opens
its address prompt there.  A size without pixels is asked with
`CSI 14 t`, and when the pane's cells change enough to change the
ratio, Ladybird is started again at the new one on a fresh pty.  On a
hangup its process group is ended, with SIGKILL after 1.5 s since it
ignores SIGTERM.
Ladybird's frames are opaque RGB, so a transparent page can't blend
into its pane.  The page now takes the terminal's background and
foreground, asked before Ladybird starts, and derives every surface
as a step between the two.  They are appended to `/app.css` as a
`:root` rule because the page's CSP refuses inline style.  Code blocks
and question cards use those surfaces instead of fixed dark colours.
…e pane

Also records in RFD 0007 what the pty capture showed: the status
line's bytes, the `CSI 14 t` fallback to 800x600, RGB frames, SIGTERM
ignored, and the CSP refusing inline style.
The page took only the terminal's text and background colours, set its
own small sans-serif type, and kept that theme when Ladybird restarted
at another scale.

The pane now asks its terminal, in one round trip ended by `CSI c`, for
its text and background colours, its 16-colour palette and, when
missing, its pixel size.  Before each Ladybird start the page's theme
is set from them: the palette as `--p0` to `--p15`, dim text from
palette 8, and a text size that makes a character one terminal cell
wide.  The binary now carries JetBrains Mono 2.304 (OFL), Rex's default
terminal font, which Ladybird can't reach in Ghostty's binary.
…animating

The pages looked like a chat app, the activity pane was wordy, and
scrolling crawled.  Idle, the conversation sent 180 full 10 MB frames in
3 s from CSS animations, and 20 wheel events still hadn't settled after
20 s.

The conversation now uses the terminal view's name badges, here with
rounded corners and a rounded arrow, `>` lines for your messages and
one dim `↗` line per run of tools.  The activity pane is one line per
agent: context dots, tokens, cost and a dot matrix of its last hour,
then plan limits as dot meters.  Nothing animates, a working agent's
mark is still, and updates replace only the timeline entries that
changed.  An idle pane now sends no frames, and the same 20 wheel
events settle in 0.74 s.  A test keeps animations out.
… pane

The owner liked the terminal view's braille sparks and asked for the
same, done better.  Each agent's last hour is now a chart in braille
geometry, two dots across and four down per cell, as wide as the pane.
The series is resampled to the dots that fit, the top dot of a column
is lit in part for the exact value, and a gradient runs up each column.
The name, state, context, tokens and cost are written over it.  Context
and plan limits are gauges two dots high, green to yellow to red along
their length.
Ladybird eases every 40-pixel wheel step over about 200 ms, a dozen
full-pane frames each, so a trackpad's stream of steps made the page
lurch.  The page now takes the wheel itself: a line per step, applied
at once, at most one frame for the steps since the last.  20 steps now
draw 17 frames and settle in 0.49 s, from 29 frames and 0.74 s.
The web pane stopped starting Ladybird with its own `starting {program}` message when it moved onto its own pty, and the key check failed.
With web panes on, Ctrl+D in the composer or the conversation opens
the thread controls as a web page in the floating layer the terminal
pane uses.  It shows each session with its badge, context gauge and
spend, a braille chart of the thread's last hour with its totals
written over it, and the terminal pane's menu, walked with the same
keys (j/k, the action's letter, Enter, Esc, y/n).

The page only walks the steps.  `/api/control` takes an outcome,
returns the question the terminal pane asks, and once confirmed
carries it out through `manage::act`; it accepts only the agents and
hosts the menu offered.  `manage::load` now reads a store, not a
context, so the pane's poller can call it.  Without Ladybird the pane
is the terminal controls.
The thread controls added a `stepHtml` to the page script, which
already had one drawing a tool step.  The later declaration replaced
the earlier, so drawing any tool step ran the controls' code and every
update of the conversation threw ("d.actions" undefined in Ladybird's
log): an existing thread opened half drawn or blank.  The controls'
one is now `ctlStepHtml`, and a test refuses a page script that
declares a name twice.
…there

The page scrolled to the bottom once, at its first render, before its
font arrived; the font then lengthened every line and left an existing
thread opened partway up.  The page now keeps whether the reader is at
the latest message from their scrolling, and follows it again when the
font loads, when the pane is resized while docking, and on each update.
Reset and hard reset relaunch a thread's panes by finding its
composers in `ps`, by `axel thread compose THREAD` only, so a web
composer (`axel web pane THREAD --view composer`) was never found and
its panes kept running the old view.  Both are found now, by whole
words, so another thread whose id starts the same isn't.
Ladybird was started with the page's only secret in its address
(`/?k=SECRET`), and the same value became the page's cookie.  On macOS
any local process can read every process's arguments, so anyone on
the machine could take it from `ps` and drive the thread.

The address now carries a token good for one page load within 30 s,
and each Ladybird start mints its own.  Spending it earns a separate
cookie made when the server starts, which no command line carries.
Both are 32 bytes from /dev/urandom, compared in constant time.  Writes
must now carry this server's `Origin` (a write with none passed
before), and a method other than GET or POST is refused as it is read.
The rules live in `web/guard.rs`.
Terminal and web panes were told apart in two places with two enums
for one choice (`ui::PaneKind`, `web::PaneChoice`), each pane's
command was built by hand in both, and the web fallback kept its own
copy of what runs each terminal pane.

`cmd/display.rs` now holds it: `Pane` (conversation, composer,
activity, controls) and `Display` (terminal, web), and a
`PaneDisplay` trait, implemented by `TerminalPanes` and `WebPanes`,
that gives the command Rex runs for a pane, runs a pane here, and
sizes the composer.  Docking, splitting, the controls and the web
fallback all go through it.  `--view` and `axel panes` are parsed
into the enums by clap, and `web::WebView` is gone.  A shell that
turns into a terminal conversation now registers how to come back
after a Rex restart, as every other pane does.
`ManageData.state` and `SessionRow.state` were strings ("open",
"paused", ...) compared as strings in the menu's rules, and the web
controls kept a second table of action names.  The thread's state is
now the store's `ThreadState`, a session's is a new `SessionStatus`,
and `Action::as_str` names an action where it leaves the program.
They become text only where they are drawn or sent to the page.
`manage::load` ran to 75 lines: the per-session part is now
`session_row`, with what it looks up read once into `Known`.  Every
loop that runs for the pane's life says so and what bounds it,
`web/mod.rs` keeps its tests at the end, and the invariants the
server, the status-line filter and the controls rely on are asserted.
Also brings CONTRACTS.md up to the controls view, the one-time address token, the fonts route and the enums the controls now carry.
@lgalabru lgalabru changed the title feat: web panes (experimental) — the thread view drawn by Ladybird in its Rex pane feat(web): add opt-in Ladybird panes for threads Nov 27, 2026
@lgalabru

Copy link
Copy Markdown
Owner Author

@jonleopard, would you try this experiment on your Mac/Linux setup and share feedback on rendering, pane proportions, and image drops?

Web panes are opt-in and off by default. They use Ladybird's terminal mode inside Rex. The README setup instructions cover installation and axel panes web; reopen a thread to try it. axel panes terminal switches back to text.

Feedback on anything that feels less usable than terminal mode would be especially helpful.

@lgalabru
lgalabru merged commit 9026ceb into main Nov 27, 2026
4 checks passed
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