A local-first multi-agent app development platform, built on PenguinHarness
Server-side terminals: an integrated dock and a standalone page
- Date: 2026-08-14
- Type: feature
- Scope:
server,web,desktop - PR: #285
Shells now run in the server, not in the browser tab that shows them: every pty byte feeds a headless xterm in the daemon, so views are disposable. A reload, a moved panel or a second device repaints the exact screen — scrollback, colours, cursor, input modes — while the shell keeps running.
Server: /api/terminals
- Control plane over JSON: list / create (
cwd,name,cols/rows,shell) / get / kill, plus plain-textcapture(line ranges) andkeys(literal text orEnter/C-c-style tokens) so non-rendering clients can drive a shell too. Unnamed terminals auto-increment per user (tmp,tmp 2, …) and carry a stable display number that never shifts under reorders. - Data plane: binary WebSocket at
/api/terminals/:id/stream, output coalesced (~5 ms window, immediate leading flush). Attach resizes the pty to the client's geometry, then one Restore frame repaints the whole screen; output produced meanwhile is buffered in. - Size has a single claimant (focus/attach claims, others' updates are ignored), sessions
outlive connections, exited ones stay readable for a grace period, 12 live shells per
user, and shutdown escalates SIGHUP to SIGKILL (
nohupservers inherit ignored HUP). - A viewer lagging past 1 MiB stops receiving live output and is resynced with a fresh Restore once its socket drains — never disconnected.
- The shell is the user's own, started so their profile is in effect:
$SHELLwith-lon POSIX, and on Windows PowerShell (pwsh, elsepowershell) rather than%ComSpec%, which reads no profile at all.PENGUIN_SHELLoverrides it everywhere. This is not the agent's command shell, which stays POSIX-first and-NoProfilefor determinism. - Security: a terminal is a shell as the server's OS account and is per-user, not
Project-scoped (foreign ids answer 404); the upgrade checks the session cookie plus a
strict
Origin(exacthost:port,http(s)only), since WebSocket handshakes bypass CORS. Don't enable terminals for accounts you wouldn't give SSH.
Web App
- Dock (
Ctrl+`): a multi-pane terminal panel, at most one pane per edge of the content area. Tabs are labelledN: title(stable number + live OSC title,user@hoststripped), drag sideways to reorder, squeeze browser-style when crowded, and wheel-scroll. Dragging a tab out of the strip — or a pane's header — brings up the edge overlay (edge bands, drop targets, a preview of the exact landing region) and moves the terminal/pane to the chosen edge, creating a pane there on demand. The pane/main boundary drags to resize (ratio-persisted per edge, double-click resets). Layout changes never reconnect: xterm views are pooled by terminal id and handed between panes as DOM. - The dock belongs to the conversation it was opened in: switching Sessions switches panes, tabs and visibility with it, and switching back restores them. A terminal opened while drafting moves into the Session that draft becomes — every draft shares one scope, having no id of its own, so otherwise it would sit there waiting to reappear in the next new conversation. The shells keep running either way — the toolbar's terminal menu lists every live one, and picking one brings it into the conversation on screen.
- A left or right pane and the chat's Agents/Workspace panel share the same horizontal half of the content area, so only one of them is on screen: whichever the user asked for last. Opening a panel displaces the side pane; opening or focusing a terminal retracts the panel. They also share the width — one dragged on any of the three is the width the next one opens at — and the same 200ms slide, the displaced side collapsing rather than popping, with its shell and screen untouched behind it. Top and bottom panes cost height rather than width and keep their own ratio.
- Opening lands on the last-shown live shell, else the newest live one, else a fresh one;
panes, sizes, tab order, assignments and each pane's shown terminal persist. Being OPEN
does not: a fresh load starts with the panel closed, and reopening comes back to exactly
the arrangement that was there. The count on the toolbar is this conversation's, so
closing its last terminal takes it to zero rather than leaving it parked on a shell
running somewhere else. A tab's
×kills that shell; killing the last one closes the pane. Detach hands one terminal to its own/terminal?id=…window while the dock keeps its remaining tabs. /terminalpage: full-window and deep-linkable —?id=attaches an existing terminal (the detach handoff),?cwd=/?name=parameterize a new one; the attached id is written back into the URL so a reload or a copied link reattaches.- Chat toolbar: icon-only panel switcher — pinned triggers plus a hover-opened Create menu listing Agents panel / Terminal / Workspace with per-row pin toggles (agents + workspace pinned by default). The terminal shows a live shell count (updated the moment the user creates or closes one) and its pinned icon lists live terminals on hover for one-click focus.
- Light and dark, as the terminal's own setting (user menu → Terminal theme): light, dark, or follow the app, defaulting to dark whatever the app is doing — a terminal is where prompts and TUIs are tuned for a dark screen. Switching repaints in place; the shell, its scrollback and its connection all survive. Surfaces are the app's own tones rather than a terminal's charcoal, so a docked pane no longer reads as a foreign window; the sixteen ANSI colours stay recognisable and get their own light-mode set, legible on white.
- Clipboard: copy via
Ctrl+Shift+C/Ctrl+Insert/Ctrl+C-with-selection (otherwise still SIGINT); paste viaCtrl+V/Ctrl+Shift+V/Shift+Insertriding the native paste event (no clipboard permission). Right-click copies the selection or pastes, never the page menu; middle-click pastes; both defer to apps owning the mouse (vim, htop). Clicking anywhere in the view focuses the shell; hover-revealed controls also show on keyboard focus.