60 KiB
Permanent terminal (bottom panel / floating window)
A full terminal available from every destination, independent of chats.
Each terminal starts at the machine's login prompt (su -l <user> for the
server's own account), so the operator types that account's password before
getting a shell. It keeps running, logged in, when the panel is hidden or the
app navigates or reloads; it ends when the Pipelines server restarts (run
tmux inside it for work that must survive that).
Behaviour
- Modes (Settings → Appearance → Terminal, or the terminal's own ⋮ menu): Bottom panel docks under the app (the app shrinks above it, never hidden under it); Floating window is a window over the app. Both are toggled by the bar's Terminal button (every destination's bar ends with it) and the shortcuts below.
- First open: the first time the terminal is shown in an app run (once
every machine's list has arrived) it starts one terminal, as New terminal
does, unless one is already running; it shows the login prompt and the
operator types the password into the terminal (the PTY hides it). From
then on the button, shortcuts and the narrow page only hide and show it:
no toggle opens another terminal, even after every tab is closed (New
terminal does). Opening one by hand first counts as the first
(
TerminalHub.firstOpenDone,openTerminalIfNone). Each new tab is its own login and asks for the password again. - Shortcuts (
terminal_shortcuts.dart, handled by the surface as aFocusManagerearly key handler, so they work wherever focus is, including in the chat composer, which does not receive the key):- Alt+T (Option+T), Ctrl+T, Cmd+T (Meta+T) and **Ctrl+
** show or hide the terminal in the selected mode; on a narrow window they open and close the full-screen page. Only the one modifier counts (Ctrl+Shift+T, Ctrl+Alt+T pass through); Option+T, which types † on a Mac, is also matched by key position. Cmd+stays the macOS window switcher. - Inside a focused terminal (any
TypingSurface, i.e. a terminal view) only Cmd+T and **Ctrl+** toggle: **Ctrl+T** reaches the shell as^T(transpose-chars) and **Alt+T** asESC t(transpose-words). A held chord that opened the terminal from outside keeps its repeats swallowed after the terminal takes the keyboard, so nothing is typed. The ⋮ menu and the shortcut cheatsheet say so (TerminalShortcutLabels.inTerminalNote`). - Ctrl+Tab / Ctrl+Shift+Tab, while the terminal is shown (panel,
window or narrow page), select the next / previous terminal tab, wrapping,
and focus it. This deliberately overrides the chat's Ctrl+Tab pane
cycling while the terminal is open (
TerminalActions.claimsTabKeys, checked bychat_screen_workspace.dart); hidden, Ctrl+Tab cycles chat panes as before. - Browsers keep some of these: a normal Chrome/Safari/Firefox tab
never receives Cmd+T (new tab) or Ctrl+Tab / Ctrl+Shift+Tab (switch
tabs), and outside macOS Ctrl+T is new tab too. The web build therefore
lists only Ctrl+T (macOS), Alt/Option+T and Ctrl+
in the button tooltip and the ⋮ menu (TerminalShortcutLabels`), and no tab keys; the handlers stay on, so an installed app window that does deliver a key still works. Native macOS/Linux/Android-with-keyboard builds get all of them and list them.
- Alt+T (Option+T), Ctrl+T, Cmd+T (Meta+T) and **Ctrl+
- Focus: whenever the terminal shows (shortcut, button, a reload that
restores it, a mode change, un-minimising, a tab change by pointer, key or
New terminal) the selected tab's emulator gets the keyboard: the body is a
FocusScopethe surface focuses after the frame, and the emulator autofocuses inside it (terminal_focus.dart). Hiding gives the keyboard back at once to what had it before opening (the composer, a field), if the terminal still has it; the narrow page's route restores focus itself. - Motion:
Motion.standard(200 ms,Motion.curvein, ease-in-cubic out), played on the app clock the animation-speed setting dilates, and zero under reduced motion (Motion.of). The bottom panel keeps its full height and slides up from the bottom edge with a slight fade (opacity 0.4 to 1) while the app above shrinks with it frame by frame (no jump, and the emulator is not resized during the motion); the floating window scales from 92 % and fades in its own place. During the hide motion the terminal stays mounted but takes no pointer or focus (terminal_stage.dart). - Bottom panel: opens at 40 % of the window, and at least 16 terminal
rows (
terminalPanelDefaultHeight), until the operator resizes it by dragging its top edge (the app'sAdaptiveResizeGrip; arrow keys too, slider semantics); the dragged height is remembered (panel_height; a layout saved with the old fixed 300 px default reads as never resized). The panel always leaves the app at least 160 px. The destination rail beside the app scrolls its tabs when the panel leaves it too little height, and below 240 px Settings scrolls with them instead of staying pinned, so rail items never overlap. - Floating window: dragged by its title bar, resized from its lower right corner, double-click or Maximise fills the app (8 px margin), Minimise collapses it to its title bar, × hides it. Frame and state are remembered.
- Narrow windows (< 600 px): the terminal opens as a full-screen page (Material/Cupertino route) with the chat terminal's key toolbar (Paste, Enter, Ctrl-C, Tab, Esc, arrows, and the typing field on Android/iOS).
- Tabs: one per terminal; the title is the shell's OSC 0/2 title
(followed by the emulator, also recorded by the server for the list),
else the start folder (
~for home). Ended terminals are italic and show why they ended with a Close tab button. With more than one machine connected (or tabs from several) each tab names its machine, and New terminal (+) asks which machine. ⨯ on a tab closes it, which kills the login or shell. - Open in terminal: the chat header's More menu (the chat's folder, on the chat's machine) and a folder's ⋮ menu in the Files panel open a new terminal there and show the surface.
- Permanence: the app's
TerminalHublives as long as the app; hiding or minimising never closes a shell. Reopening redraws the same emulator. The layout (mode, shown, height, frame) is saved per device, so a reload reopens the terminal, lists the machine's terminals and resumes each from its retained output. A dropped connection resumes after the last byte held. A restarted server lists the terminals as ended, with why. - Keyboard: a focused terminal gets every key (Ctrl-C, Esc, Tab, arrows,
Ctrl-letters, Ctrl+T, Alt+T) except Cmd+T, Ctrl+
and Ctrl+Tab while shown; paste is Cmd-V (Apple) or Ctrl-V/Ctrl-Shift-V. Clicking elsewhere moves focus away normally. Keys are encoded as xterm does; seechat-interactive-terminal.md(Keys). **Option as Meta** (Settings → Appearance → Terminal, Macs only, saved with the layout, default on): a Mac's Option sendsESC+ the key's character (Option+B =ESC b`) instead of typing its symbol (∫). On by default because the shell's Meta bindings (word motion, transpose, yank-last-arg) are used far more in a terminal than Option's symbols; turn it off to type them. Other platforms' Alt is always Meta. - No terminal request is sent until the terminal is first shown (or a
terminal is opened): each connection sends one request at a time, so the
first screen's read is never queued behind
terminal_list.
View features (round 2, 2026-11-26)
Shared by the permanent terminal and chat terminal cards
(ChatShellTerminalView); client-side only, no server change. The view's
own keys are answered before the key→byte mapping
(chatShellLocalKey, chat_shell_terminal_shortcuts.dart):
- Find in scrollback: Cmd+F (Apple) / Ctrl+Shift+F (elsewhere; Ctrl+F
stays the shell's forward-char) opens a find bar over the terminal's top
end, or focuses it. Typing searches the whole buffer, wrapped rows joined
(
chat_shell_terminal_search.dart, at most 1000 matches, "1000+"); every match is highlighted (controller highlights, the emulator's existing hook) and the current one more strongly, scrolled into view. It starts at the newest match; Enter / the down arrow is next, Shift+Enter / up is previous, wrapping; Aa toggles Match case; Esc or × closes it and gives the terminal the keyboard back. Output arriving meanwhile marks the result stale; the next step searches again. - Text size: Cmd (Apple) / Ctrl with
=/+and-zoom one point, with0back to the default; Settings → Appearance → Terminal → Text size too. Saved with the layout (font_size, 8–32). The view relays out at the new cell size, so the PTY is resized through the normal resize path. Note Ctrl+- is readline's undo (^_) in xterm; here it zooms. - Scrollback: Settings → Scrollback (1k, 5k, 10k default, 25k, 50k,
100k lines; saved as
scrollback). It applies at once to open terminals (Terminal.maxLinesis settable; shrinking drops the oldest lines). - Scrolling keys: on the main screen Shift+PgUp / Shift+PgDn scroll one screen (keeping a line), Shift+Home / Shift+End to the top / bottom, locally. On the alternate screen (less, vim) they reach the program.
- Context menu: a right-click offers Copy (with a selection), Paste
(live terminals), Select all (scrollback included), Clear scrollback
(this view's copy; the server keeps the output) and Find…. A program
that tracks the mouse gets the right button instead, unless Shift is
held. On the web the browser's own menu is suppressed while the pointer
is over the terminal (
ChatShellNoBrowserMenu, the chat links'suppressBrowserMenuOverLink). - Bell: BEL flashes the terminal's border in the accent colour (300 ms fade; held then gone under reduced motion). A bell while no view shows the terminal (another tab selected, or the terminal hidden) dots its tab until it is shown. Settings → Visual bell turns both off.
- Links: hovering an OSC 8 hyperlink (by its target,
hyperlinkAt) or a printed http(s) address shows a pointer cursor and underlines the link's cells; a click opens it as before. - OSC 52: a program setting the clipboard copies to the system clipboard and shows "Copied from terminal" (reads are never answered). OSC 7: the reported folder names an untitled tab and its tooltip. A replay (reload, reconnect) of old output neither copies nor rings.
- Cursor blink: a blinking DECSCUSR shape (odd Ps) blinks (530 ms phases) on a ticker that runs only while the terminal is focused and motion is not reduced; output or typing shows it again at once.
- Stale selection: a selection clears when its rows on screen are rewritten or erased, the screen is cleared, its lines drop out of the scrollback, or the program switches screens.
Evidence: tests test/features/chat/shell/chat_shell_terminal_{find, local_keys,menu,events,feedback}_test.dart, test/features/terminal/ terminal_tab_events_test.dart, test/features/settings/ settings_terminal_controls_test.dart, test/third_party_xterm/ scrollback_blink_test.dart. Chrome captures (capture kit, ?terminals=1 &terminal=panel, 1200x800): find bar with "2 of 2" PASS highlights,
context menu, Ctrl+= zoom, OSC 8 link hover underline; a synthetic
contextmenu event over the terminal is default-prevented, elsewhere not.
The capture kit gained rightclick=<target>.
Theme and layout polish (round 3, 2026-11-26)
- Colours (
chat_shell_terminal_palette.dart,chat_shell_terminal_theme.dart): the terminal's background is the theme's lowest surface (white in light, near-black in dark), the foreground the body text colour. Settings → Terminal → Colours offers Theme colours (the emulator's standard palette, default), Classic (Tango-like), Calm (Solarized-like) and Vivid (One-like), saved aspalette. Every palette is adjusted to the background by moving each colour's lightness only as far as needed: red to cyan at 4.5:1 on the background (bright ones 4.5:1 dark, 3:1 light, and lighter than their normal colour), bright black 3:1, white light and black dark in both themes so white text on red, blue and magenta (lssetuid, dialogs) and black text on green, yellow and cyan (setgid, sticky, status bars) keep 3:1. As in other terminals, white text on a light background and black on a dark one stay faint, and colour-on-colour pairs such aslsother-writable (blue on green) are not guaranteed. - Selection and find: selection is the accent at 35 %, find matches the tertiary colour at 20 % and the current match at 40 %; all are painted over the text and keep it at 4.5:1. The block cursor (accent) keeps 4.5:1 with the character it redraws in the background colour.
- Tabs (
terminal_tab_chip.dart): titles ellipsise at 220 px with the whole title, machine and folder in the tooltip; the selected tab is filled, outlined in the accent and bold; the close button is a standardIconButton(48 px on touch, 40 px on desktops). - Chat command cards: collapsed they keep 12 rows; Expand (shown
for a live terminal, or output longer than 12 rows) grows the terminal
to 60 % of the window's height (
kChatShellOutputExpandedFraction; a finished run only to its output), and Collapse returns. - Evidence: tests
test/features/chat/shell/chat_shell_terminal_palette_test.dart(contrast of every palette in both themes),test/features/terminal/ terminal_panel_layout_test.dart,test/shell/navigation_rail_test.dart(no overlap at 160-800 px),chat_shell_run_card_test.dart(Expand),settings_terminal_controls_test.dart(Colours). Capture fixture?terminalColors=1prints the palette, backgrounds andlspairs in the home terminal;?terminalPalette=classic|calm|vividpicks a palette.
Text input (round 3, 2026-11-26)
Shared by the permanent terminal and chat terminal cards; client-side only.
- IME, dead keys, emoji picker, dictation (desktop and web): the view
now uses the emulator's text-input path on every platform
(
hardwareKeyboardOnlyonly for a finished, read-only run), instead of hardware key events alone, which droppedinsertText. The key handler still runs first: special keys and chords it encodes (arrows, Enter, Backspace, Tab, Ctrl/Alt chords, the view's own keys) are handled, so the browser's default (inserting text) is prevented and the OS IME never sees them; a plain printing key is left to the text input, which types it. So no key is sent twice. Committed text goes throughTerminalView.onTextInput(chat_shell_terminal_text_input.dart): a line break is Enter (\r, or\r\nin line-feed mode), empty commits (a cancelled composition) send nothing. Composing text (CJK, a dead key's accent) is drawn underlined at the cursor, over the cursor, and sent only when committed; while composing, the IME keeps Enter and Backspace. The platform's editable is placed at the cursor (setEditableSizeAndTransformwith the cursor's offset), so IME candidate windows open there. If the platform closes the text input (a browser window losing focus), the next printing key is typed from the key event and the input reopened. - Web with semantics on (assistive technology, the capture kit): the
browser's text input is the terminal's semantics text field
(
CustomTextEditnow exposesSemantics(textField, focused)as a leaf, likeEditableText; the scroll view's semantics are excluded so the engine keeps that field focused). Typing, dictation and emoji work there, but Flutter's web engine does not report IME composition for a semantics text field, so a CJK IME's intermediate text is sent as typed in that mode only. - Capture browser keys (web): terminal ⋮ menu (panel/window) and the
terminal's right-click menu offer "Capture browser keys"
(
terminal_browser_keys{,_web,_stub}.dart): the page goes full screen and callsnavigator.keyboard.lock(), so Ctrl+W, Ctrl+T, Ctrl+N, Ctrl+Tab and the like reach the terminal. Holding Esc leaves full screen (the browser's rule; a short Esc still reaches the terminal), which ends the capture; the menu item is checked while it is on and releases it. Only where the API exists (Chrome, Edge); Firefox, Safari and native builds do not show the item. A refused lock says so in a snack bar. Alternatives documented in the menu note and the shortcut cheatsheet (web outside macOS): Alt+Backspace instead of Ctrl+W (delete a word), Ctrl+U, Alt+B / Alt+F. - Touch key row (narrow terminal page, chat terminal cards on a phone
or tablet;
chat_shell_terminal_key_row.dart): horizontally scrollable Ctrl and Alt (sticky: a tap holds one for the next key or typed character, tonal; a second tap within 400 ms locks it, filled with a lock icon; a tap on a held one releases it), Esc, Tab, arrows, Home/End, PgUp/PgDn,| ~ - / \, Enter, Ctrl-C, Paste and Line. Keys use the hardware encoder (chatShellSpecialKeyBytes: xterm modifier parameter, DECCKM/SS3, keypad mode); a held Ctrl maps the next typed character to its control code, Alt prefixes ESC; a held modifier also applies to a soft keyboard's key events (Backspace, Enter). The modifiers live on the session (ChatShellStickyModifiers), shared by its views. - Soft keyboard per key: tapping the terminal opens the soft keyboard
and each character, Backspace and Return reaches the process at once
(no line to submit):
deleteDetectionkeeps two placeholder spaces in the editing state on touch platforms, so a Backspace with nothing typed is still seen; Return's line break is Enter. The old line field is now behind the row's Line button (still with Hide typing) for typing a whole line or a token first.
Evidence: tests test/features/chat/shell/chat_shell_terminal_text_input_test.dart
(commits from IME/dead key/emoji/dictation on macOS, Linux, Windows;
composing drawn not sent, IME keeps Enter/Backspace while composing;
handled keys report handled and printing keys do not; reopen after the
platform closes the input; editable at the cursor; read-only attaches
none; Android per-key typing, Backspace via delete detection, Return as
Enter), chat_shell_terminal_key_row_test.dart (sticky state machine,
row bytes incl. DECCKM, one-shot/locked Ctrl and Alt on keys, typed
text and soft-keyboard key events, Line field),
test/features/terminal/terminal_browser_keys_test.dart (capture,
release, browser-ended, refused, unsupported, ⋮ and right-click menus),
terminal_shortcuts_test.dart, keyboard_shortcuts_cheatsheet_test.dart.
Existing desktop typing tests now type printing keys as a platform does
(test/features/chat/shell/terminal_typing.dart: key event first, its
character through the text input only if unhandled).
Chromium (headless, CanvasKit, capture kit, probe ?terminals=1 &terminal=panel, 1200x800), /tmp/r3-capture/:
ime-nosem/(--semantics false): key pressesecho, CDPInput.imeSetComposition"にほ" drawn underlined at the cursor and not sent, commit "日本" viaInput.insertText, dead key "´" composing then "é", emoji and:q!viainsertText, Enter one new prompt; the hidden input sits at the cursor (x 143→183 as text is typed, y of the cursor row). Result lineecho 日本 é 👍 :q!.sem/(semantics on): the focused element is the terminal's text fieldINPUT("Terminal, type to send input"); key presses andinsertTexttypeecho é 👍 日本 xyz; Ctrl+W and Alt+B add no text (sent as control bytes).ime/shows the semantics-mode composition gap.lock/: Chromium hasnavigator.keyboard.lock; ⋮ → Capture browser keys enters full screen (document.fullscreenElementset) with the snack bar; the item is then checked; choosing it again leaves full screen; the right-click menu lists it.touch/(--touch true, Android user agent, 560x1000, Alt+T opens the narrow page): key row under the terminal, per-keyinsertTexttyping, Ctrl tonal while held and released after one character, Alt locked with the lock icon after a double tap, the row scrolled sideways to Home/End/PgUp/PgDn. Not verified: a real OS IME (macOS/Windows/Linux), real dictation, Safari and Firefox, a real Ctrl+W in a non-headless browser while captured, and any phone or tablet (no device test ran). The capture kit gainedcompose=<text>,--semantics falseand--user-agent.
Protocol (server)
internal/protocol/terminal.go; documented in docs/cli.md ("Machine
terminals"). Body terminal_request {terminal_id?, cwd?, cols?, rows?, data?, after?}.
terminal_open {cwd, cols, rows}→terminalonce su's password prompt shows (subscribes the connection to its output first); refused when the login cannot ask for a password (below).terminal_list→terminals(running and ended, oldest first; live records carry their current title, size andstream).terminal_input {terminal_id, data, reply?, cols?, rows?}(UTF-8, ≤ 16 KiB, 64-request queue),terminal_resize {terminal_id, cols, rows, activate?}(clamped 20–500 × 4–200).- Several clients on one terminal (
terminal_viewers.go,terminal_active.go; chat terminal commands too): one active client owns the PTY size and is the only one whose emulator's automatic answers (reply: true: cursor position, device attributes) reach the shell, so a query gets one answer, not one per client. The opener starts active; typing (carrying the typist'scols/rows, applied before the input) or focusing a terminal view (terminal_resizewithactivate) makes a client active. Others' sizes are kept, not applied; when the active connection closes the next most recent client's size is applied. The client marks answers by what the emulator emits while drawing output (ChatShellTerminalSession.onReply). - Input latency:
PipelinesClient.callsendsterminal_input,terminal_resize,chat_shell_inputandchat_shell_resizeat once instead of behind the previous request's reply; the server reads them onto a per-connection terminal lane (terminal_lane.go) handled in order beside the ordinary loop, andterminal_openruns off the read loop.ChatShellInputPipestill keeps one request in flight per terminal (typing during it is coalesced; answers go in their own requests). terminal_output {terminal_id, after}→terminalwithoutput,output_start,output_end,stream; subscribes the connection.terminal_close {terminal_id}→ the closed record (runs off the read loop: it waits up to 3 s for the shell).- Pushed
terminal_event: output{terminal_id, output, offset, end}to subscribed connections, lifecycle{terminal_id, terminal}(opened, title, exited, closed) to every connection. Output flow is described under "Output flow" below; offsets are stream bytes, taken from the server (end,output_end), never from the text's re-encoded length.
Output flow (2026-11-25)
Server (terminal_flow.go, terminal_clients.go): each connection's
subscription is a cursor into the terminal's 1 MiB retained tail; the
connection's writer goroutine sends from it as soon as the PTY reader has
written (no tick), coalescing what arrived during the previous write and,
while output streams, letting a frame gather for at most 2 ms. The app asks
for flow: true on terminal_open/terminal_output; those replies carry
window (256 KiB) and the app sends terminal_ack {terminal_id, after}
each time it has drawn a quarter window. A flow subscription is sent at most
window bytes past its last ack, and while one is full the PTY reader stops
(the program blocks on its writes) instead of skipping. One that stays full
for 3 s without acknowledging stops holding the terminal; on its next ack it
gets a frame after a gap and re-reads. A gone connection drops its
subscriptions at once. A subscription without flow (an older app build) is
never waited for and keeps the old pacing (newest 64 KiB, one frame per
50 ms). terminal_open and terminal_output replies are written before the
frames that follow them, which start exactly at the reply's output_end.
Client: ChatShellTerminalFeed (shared with chat shells) writes output into
the emulator in slices of at most 16 Ki units and yields to the event loop
after 6 ms, so a 1 MiB replay or a burst never holds a UI frame; drawn is
the server byte end of what has been written, which TerminalTab
acknowledges. Round 3 (below) made the slices follow the measured speed,
the yields message tasks on the web, and the view's updates one per frame.
Chat shell runs (chat_shell_supervise.go) share the output buffer code:
output is pushed as it arrives, oldest first, while every watcher of the
chat has fewer than 8 queued frames; 256 KiB unpushed stops the reader. A
watcher behind for 3 s gets the old pacing (newest chunk per flush tick, a
gap) until it catches up. The DB snapshot every 2 s is unchanged.
Measured (PIPELINES_TERMINAL_MEASURE=1 go test ./internal/server -run TestMeasureTerminalStream -v, loopback, fast reading client; before = the
old server or a client without flow):
| workload | before | after |
|---|---|---|
seq 1 500000 (3.9 MB) |
3 frames, 3.69 MB skipped, 1.3 MB/s | 70 frames, 0 skipped, 27 MB/s |
cat 2.1 MB |
1 frame, 2.04 MB skipped | 34 frames, 0 skipped, 117 MB/s |
yes | head -1000000 (3.0 MB) |
5 frames, 2.67 MB skipped | 126 frames, 0 skipped, 12 MB/s |
| keystroke echo (median, 40 keys) | 43.3 ms | 0.17 ms |
| longest gap between frames while streaming | 50 ms | 2.5-4.2 ms |
Emulator (chat_shell_terminal_feed_test.dart, 896 KiB replay): one
synchronous write 160 ms; sliced, the same 161 ms over 20 turns, the
longest turn 12.5 ms. After round 3 (Linux, test JIT): one write 38 ms,
sliced 33 ms over 5 turns, the longest 11-12 ms (the first, cold, call).
Client throughput (round 3, 2026-11-26)
The emulator parsed about 1 MB/s of seq and 0.6 MB/s of yes on the web,
so the server's flow control held a flooding program to that. Hot spots
(CPU profiles of the VM and of the web build, tool/perf/terminal_stream_profile.mjs):
- every new line allocated a 4 KiB
Uint32List(256-cell capacity), 65 % ofyesin the VM; reusing a dropped line then cleared all 4 KiB; - each write decoded the string into a growable rune list;
- every character went through the parser's ByteConsumer, a torn-off
handler,
charset.translate, the width table andjoinPreviousCell, which built a String of the previous cell (cellContentText) for each; - C0 controls, ESC and CSI dispatch called torn-off closures (several times
a direct call in JavaScript); CSI reset
clear()ed three lists (setting a JS array's length, 20 % of a coloured stream);%in the circular buffer; - on the web the feed's zero-length timers were clamped to 4 ms after a few (a third of a burst idle), and every write notified the view, so a stream drew a frame per turn, each rasterised on the same thread.
Changes (vendored emulator, third_party/xterm README lists them; feed in
lib/features/chat/shell/):
- The parser reads the written strings directly; runs of printable ASCII
and C0 controls are handled straight from the string
(
EscapeParser._processPlain), a run written into the line in one call (Buffer.writeAscii,BufferLine.setAsciiCells) exactly aswriteCharwould (checked cell by cell inwrite_path_test.dart). - A line leaving a full scrollback (or a one-line region scroll) is cleared
and reused; a line with anchors (selection ends) still leaves detached.
Lines track the highest cell written since made or cleared, so a clear
touches only those (
getTrimmedLengthscans only those too). joinPreviousCellrejects characters that cannot join before reading the cell; the width table covers plane 1 (emoji) instead of searching ranges.- Switch dispatch for C0, direct calls for CSI and SGR, CSI parameters
emptied element by element, circular index without
%(IndexAwareCircularBuffer.insertnow keeps the start index wrapped). - Feed: on the web a turn yields through a
MessageChannelmessage task (chat_shell_terminal_yield_web.dart), not a clamped timer. Slices are cut to what the measured speed writes in the turn's remaining budget (first write 4 Ki units, at least 1 Ki, at most 16 Ki), so a turn ends near 6 ms for any output.Terminal.write(notify: false): the feed shows the state (notifyListeners) once everything queued is written, before a queued action, and while still behind after a turn at most every 32 ms. On the web (frames rasterise on the parsing thread) output written less than 32 ms after the last show is shown when the gap has passed, about 30 frames a second while streaming; output after a quiet spell (an echo) shows at once. Natively frames rasterise on their own thread, so written output keeps showing at once. Lines scrolled off between two frames are never drawn (the painter draws the visible rows of the final state).
Benches (same Linux machine, 16 cores, shared with other agents; load
average noted; before = the base commit e526150b with the same bench):
-
tool/perf/terminal_parse_bench.dart(16 MB per workload intoTerminal.writein 16 Ki slices, 158x48, best of three). Dart VM (dart run, JIT), after; and the same compiled withdart compile js -O4(what the web build uses) in node/V8:workload VM before VM after V8 before V8 after seq2.2 31.5 3.4 37.4 yes0.9 27.4 1.4 28.3 unicode lines 4.9 13.7 7.6 16.1 coloured lines 6.1 33.6 9.1 39.4 screen10.2 73.0 15.6 65.1 progress9.6 93.6 16.0 73.7 (MB/s; before and after run back to back at load average 19-23, the machine busy with other agents' builds. At load 2-4 the VM reached about 55 MB/s for
seqand 31 foryeswith an earlier state of these changes.) -
tool/perf/terminal_stream_bench.dart(profile web build, headless Chromium, CanvasKit software raster, 1280x800, 8 MB per workload; the producer now follows a 256 KiB flow window past what is drawn in 32 KiB frames, at up to 100 MB/s; "parse" is MB per second spent insideTerminal.write; "MB/s" is the whole stream, frames included; two interleaved runs each, load 2-4):workload parse before parse after MB/s before MB/s after after, a frame per write seq2.4 54-60 1.25 20.8-22.1 12.6-13.8 yes1.2 38-42 0.66-0.69 18.4-18.9 11.5-12.9 unicode lines 7.4 23-25 2.4-2.5 7.6-8.0 6.5-7.0 coloured lines 9.7-10.0 57-61 3.6 25.1-25.7 14.0-15.1 screen18.2-18.3 105-115 6.2-6.3 27.6-27.9 17.9-21.9 progress18.4 124-135 6.3-9.0 24.8-28.6 20.4-22.3 Frame times at the same output rate (0.5 MB/s, both builds keep up): build p50/p90 and raster p50/p90 equal or lower after (e.g.
seq1.4/1.9 and 8.2/8.9 ms against 1.5/2.0 and 8.2/9.1). While flooding, a stream draws 11-16 frames for 8 MB instead of 250-470; with so few frames the p90 is the start-up frame (max raster 48 ms in both modes). Page rAF p50 stays 16.7 ms. The rendered final screens match the base (/tmp/terminal-round3/shots/).
The end-to-end rate is now bounded by frames (each software-rasterised frame costs 8-14 ms of the page's one thread) and by the 256 KiB flow window (a frame of 30 ms leaves at most 256 KiB to parse after it). A larger window on the server, or GPU raster, would raise it further.
Screen state across reloads (2026-11-26)
The server keeps each machine terminal's state, not only its bytes, so a client that attaches late is brought to the exact current screen.
internal/termstateis a headless xterm-compatible emulator (own code; see "Why not a library" below).terminal_process.gofeeds it every PTY read underp.mu, the same lock as the 1 MiB tail, so its state always belongs to the tail's end;applySizeresizes it with the PTY.terminal_outputwhoseafteris before the retained tail (the newest 1 MiB; a missingaftercounts as 0) getsoutput_snapshot: true:outputis the emulator's snapshot andoutput_start == output_endis the offset it describes; the frames that follow start there, and the flow window counts from it as from any reply (terminal_screen.go). A read inside the tail (an ordinary resume, or a stream not longer than 1 MiB) is raw bytes as before.- The snapshot (
termstate.Snapshot) is an escape stream for a reset terminal:RIS+ED 3, the title (OSC 2), the inactive alternate screen if it holds anything (?47h…?47l), the last 1000 scrollback lines and the main screen row by row (soft wraps wrap again), then, if the alternate screen is in use, the main screen's saved cursor and?1049h(so the program's exit restores it) and the alternate screen drawn row by row; then the saved cursor(s), tab stops, scroll region, origin mode, the cursor (a pending wrap is recreated by rewriting the last cell; the cell before the cursor is rewritten when it holds the last character, for REP), modes (DECCKM, DECKPAM, autowrap, IRM, LNM, reverse video, cursor blink/visibility/shape, mouse tracking 9/1000-1003 and encoding 1005/1006/1015, focus 1004, bracketed paste 2004, 1007), G0/G1 character sets and SO, the pen (SGR incl. 256/RGB colours and underline styles) and the start of an unfinished escape sequence or OSC string. An unfinished UTF-8 character is left out (output_endis before it; the next frame carries it whole). - Client:
TerminalTab._readresets its held copy and replays when the reply is a snapshot (TerminalStream.snapshot,ChatShellRun.snapshot: no "earlier output was dropped" line).ChatShellTerminalSession.replaynow writes RIS before any replay, so a raw replay no longer inherits stale mouse/paste/alt-screen modes either. - Chat shell interactive commands are not covered: their readbacks come from the run record (DB snapshot every 2 s of the raw tail) on a separate path; they get only the RIS-on-replay change.
Why not a library: github.com/charmbracelet/x/vt v0.1.0 (MIT, active)
keeps scroll region, pen and modes private and scrolls by copying cells:
measured 0.2-1 MB/s for seq and 4.5 MB/s for wrapping text, 33 MB/s for
redraws. github.com/vito/midterm v0.2.5 (MIT): 1-4 MB/s scrolling,
ignores keypad and most modes. github.com/hinshun/vt10x: unmaintained
since 2022, no scrollback or bracketed paste. termstate moves rows by
pointer, keeps blank cells implicit and recycles evicted scrollback rows.
Measured (go test ./internal/termstate -bench ., Ryzen 7 5800X, 8 MB
each, 32 KiB writes): seq 190 MB/s, coloured full-screen redraws 160-165
MB/s, wrapping mixed text 172-180 MB/s, at 80x24 and 200x50; a snapshot of
1000 full 200-column scrollback rows: 2 ms, 229 KiB (seq: 9 KiB; a 40-row
TUI: 4-39 KiB). Cells: 230 KiB per terminal for seq, up to 5.9 MB at
200 columns with 1000 full rows. End to end (TestMeasureTerminalStream,
same machine, two runs each, before → after): seq 20.8/22.8 → 25.0/25.3
MB/s, cat 80/102 → 80/76 MB/s, yes 10.4/11.4 → 10.4/10.7 MB/s, echo
median 0.36/0.41 → 0.48/0.38 ms: no measurable cost.
Known gaps: origin mode with the cursor outside the scroll region (a DECRC can leave it there) is not recreated; hyperlinks (OSC 8), palette changes (OSC 4/10/11), DECSLRM and kitty keyboard modes are not tracked; DECSC's origin flag is not saved (as in the app's emulator); scrolled-in rows are blank in the default colour (as in the app's emulator, not xterm's BCE). The server emulates at the PTY size; a client drawing at another size gets the snapshot at the PTY's.
Unicode, glyphs and drawing (2026-11-26)
All in the vendored emulator (third_party/xterm, README lists the patches)
plus the view's style (chat_shell_terminal_theme.dart).
- Widths follow glibc
wcwidth(what tmux, readline and ncurses lay out with) on Unicode 16 tables generated bythird_party/xterm/tool/gen_unicode_tables.pyfrom Python'sunicodedataandemoji-data.txt; every assigned code point was compared with glibc 2.44 and the few differences (prepended concatenation marks, Hangul fillers, U+3248-324F) are pinned to glibc. Combining marks and format characters 0, East Asian Wide/Fullwidth (every default emoji) 2. - Graphemes: a zero-width character (combining mark, variation
selector, ZWJ, tag, Hangul medial/final jamo) joins the cell before the
cursor; a pictograph after a ZWJ, a skin tone after a modifier base and a
second regional indicator join too. The cell keeps the cluster interned
(
CellContent.clusterFlag+ an index into one shared table, capped at 65,536 clusters of at most 32 UTF-16 units), so cells stay four words and reflow/scrolling copy them unchanged. The painter draws the whole cluster; copy (getText) returns it whole. A zero-width character with nothing before it on the line is dropped (it takes no column). A wide character never starts in the last column (it wraps whole). - Choice where terminals disagree: U+FE0F after a text-default emoji (❤️, keycaps) and a flag make the cell two columns, as kitty, WezTerm, foot, Ghostty and iTerm2 do. A flag is also 2 under wcwidth (1 + 1), but wcwidth gives U+FE0F 0, so a program measuring with wcwidth counts ❤️ as one column; a ZWJ family is one two-column cell here but 6 columns to wcwidth (2 + 0 + 2 + 0 + 2). Inside tmux, which redraws with its own widths, such emoji can still shift the rest of that line by a column.
- Glyphs: box drawing (U+2500-257F: light, heavy, double, dashed,
rounded, diagonal), block elements (U+2580-259F) and Powerline separators
(U+E0B0-E0BF) are geometry that fills the cell (
ui/cell_glyphs.dart), with half-pixel bleed across cell sides and inner edges on whole pixels, so they join across cells and rows at any line height. Other Nerd Font icons come from the bundled subset of Symbols Nerd Font Mono (568 KiB, MIT;fonts/README.md), first in the terminal's fallback families and registered on first use (lib/ui/text/terminal_symbols_font.dart). A glyph wider than its columns (a full-em icon or symbol from a fallback font) is scaled down to fit; a narrower one (emoji, CJK) is centred. - Line height 1.1, rows rounded up to whole pixels (about 1.13 at the default 13.3 px), was 1.3. Roboto Mono has no italic: italic stays synthesised (a bundled italic was not added).
- Drawing: backgrounds are one rectangle per run of a colour with
whole-pixel edges. Each line is a picture reused until the line changes
(
BufferLine.version) or the painter's style, theme or fonts change, so a frame records only changed lines. A new line draws its text from the per-character paragraph cache; a line drawn unchanged in two frames is re-recorded "settled", its plain text laid out as one paragraph with a span per style (glyphs advance one cell each; checked against the grid, cell by cell otherwise), at most 8 lines per frame. Measured on CanvasKit, laying out a paragraph per new line cost more than it saved while output streams (every visible line is new each frame), so new lines never pay for it.TerminalStyleandTerminalThemecompare by value, so a view rebuild no longer clears every cache.
Bench: tool/perf/terminal_stream_bench.dart (the app's style, theme and
sliced feed; profile web build) driven by tool/perf/terminal_stream_bench.mjs
in headless Chromium (CanvasKit, software raster, 1280x800, 8 MB per
workload, generated at up to 30 MB/s; the emulator's parsing is the
throughput limit). Medians of two interleaved runs on a shared, loaded
machine (frame ms; screen redraws all 48 rows with colours each chunk,
progress rewrites one status line under a static screen):
| workload | before build p50/p90 | after | before raster p50/p90 | after | before MB/s | after |
|---|---|---|---|---|---|---|
seq |
1.0/1.5 | 1.5/2.3 | 7.6/8.7 | 7.7/8.8 | 1.05 | 1.01 |
yes |
0.9/1.3 | 1.2/1.7 | 7.6/8.8 | 7.4/8.2 | 0.59 | 0.66 |
| unicode lines | 1.4/1.9 | 2.7/3.6 | 8.6/9.6 | 10.5/12.0 | 1.92 | 1.98 |
| coloured lines | 1.5/1.9 | 2.1/2.6 | 8.7/9.6 | 8.9/9.9 | 2.23 | 2.58 |
screen |
4.1/4.8 | 3.4/4.0 | 13.0/14.6 | 11.4/14.0 | 2.77 | 3.82 |
progress |
2.7/2.9 | 0.9/3.2 | 11.2/11.8 | 8.6/10.3 | 3.79 | 3.94 |
Streaming plain lines is unchanged within noise (+0.5 ms build for the pictures); full-screen redraws and mostly static screens are cheaper; the unicode workload (six procedural glyphs per line, paths rasterised in software) costs about 2 ms more raster. Runs on this machine vary by about ±20 % between repetitions.
Login and lifetime (server)
internal/server/terminal_login.go. A terminal runs, in its PTY,su -l <user> -c '<script>'for the server's own account (user.Current): su from PATH, else/usr/bin/su(macOS) or/bin/su,/usr/bin/su(Linux), withLC_ALL=Cso the prompt is English. macOS su passes the arguments after the login name to the shell; util-linux su takes-c. PAM asks for the account's password even though the server already runs as that user (checked on this Mac:/etc/pam.d/suispam_rootoksufficient, thenpam_opendirectory). After the login the account's shell runs the script: it prints the marker OSCESC ] 6973;pipelines-login BEL(emulators ignore it), cds to the start folder (home when that fails) andexec "$SHELL" -l(su -l's own login shell has read the profile once already, so the login profile runs twice).terminal_openreplies only once the output shows "password" (within 5 s). It is refused with a reason, and never listed, when su is missing, the server runs as root (pam_rootokwould skip the password), the marker arrives before any prompt (an account without a password), su exits first (its last line is quoted, e.g. no terminal), or nothing asks in time. There is no fallback to an unauthenticated shell.- A wrong password: su prints
su: Authentication failed(macOS) and exits 1; the tab is ended with "The login did not complete (wrong password, or the prompt was cancelled)..." and the exit code. Close it and open a new terminal to try again. - No tmux: a terminal is a direct child of the server and ends with it. A
stop records "The Pipelines server stopped..."; on start, records still
running(a crash, or a stop whose save lost the race with the store closing) become ended with "The Pipelines server restarted and this terminal ended with it... run tmux inside a terminal...". The tmux backing, reattach and the record'stmuxfield are gone; the DB'stmuxcolumn stays (additive schema) but is no longer written. - Leftovers:
cmd/pipelines-servercallsserver.EndLegacyTerminalTmux()at start: ontmux -L pipelines -f /dev/nullonly, it kills sessions namedpipelines-term_*(what earlier servers created); any other session there and the operator's own tmux servers are untouched. - DB table
terminals: id, title, cwd, shell (<su> -l <user>), created_at, status, ended_at, exit_code, reason, cols, rows. Ended records beyond 16 are pruned. Output stays in memory (1 MiB tail per terminal).
Security
- Only reachable through the authenticated
/connectwebsocket, like chat shell commands, and each terminal then needs the machine account's password (su), a second barrier. Any connection of that server may list, type into or close its terminals, including a logged-in one. - The start folder must exist inside the operator's home after resolving
symlinks (the Files panel's containment);
~,~/suband absolute paths are accepted,~userand relative paths refused. - Input is never logged or stored: the server skips its request log line
for
terminal_input/terminal_resize, nothing is written to the DB, and the client's input pipe (ChatShellInputPipe, shared with chat shells) keeps nothing once sent. The password is typed into the PTY with echo off, so it is in neither the output nor the retained tail.
Limits and known gaps
- 8 running terminals per machine; 1 MiB retained output per terminal.
- Terminals end when the server restarts; persistence is tmux inside the logged-in shell, by hand.
- Linux su was not run: the arguments follow util-linux su; only this Mac's
/usr/bin/suwas checked for real. - The client transport sends one request at a time per connection, so a keystroke waits behind any slower request on the same machine (as chat shell input already does).
- Opening a terminal elsewhere (another device) adds its tab here too: the tabs are the machine's terminals.
- Mobile (narrow page, touch key row, per-key soft keyboard typing) is verified by widget tests and narrow Chromium captures with an Android user agent only; no device test ran.
- On the web with semantics on, IME composition is not reported to the app (Flutter web engine limitation for semantics text fields), so a CJK IME's intermediate text is sent; without semantics it is a preedit. Android/Linux builds were not run.
test/applicationandtest/features/settingshave 51 failures that are identical on the base commit8f06f12d(pendingLaunchUpdateCheckertimers etc.); none is new.
Files
- Server:
internal/protocol/terminal.go,message.go;internal/pipeline/terminals.go,store.go;internal/server/terminal_{manager,supervise,process,login,legacy_tmux,clients,title,cwd,handlers,flow,screen}.go,internal/termstate/(headless emulator and snapshots; testssnapshot_test.go,random_test.go,bench_test.go),terminal_screen_test.go,websocket.go,cmd/pipelines-server/main.go; teststerminal_ws_test.go,terminal_login_test.go,terminal_lifetime_test.go,terminal_legacy_tmux_test.go,internal/pipeline/terminals_test.go;docs/cli.md. - App:
lib/features/terminal/(terminal_{info,stream,tab,hub,listing,machines,layout,scope,surface,stage,focus,shortcuts,panel,float,float_frame,page,body,tab_strip,tab_chip,menu,toggle_button,open_action}.dart),lib/application/app_terminals.dart,pipelines_app.dart,bootstrap.dart,lib/shell/adaptive_shell.dart(barActions),lib/features/settings/settings_terminal_section.dart(+ screen/topic pages),lib/features/chat/conversation/chat_thread_view.dart(Open in terminal),lib/features/chat/files/files_panel.dart(folder action),lib/features/chat/shell/chat_shell_terminals.dart(ChatShellInputPipemade public),lib/features/chat/chat_screen_workspace.dart(Ctrl+Tab yields to a shown terminal). Teststest/features/terminal/. Probe fixturetool/perf/terminal_fixture.dart(?terminals=1,?terminal=panel|float, showcases?terminalAttrs=1,?terminalUnicode=1,?terminalColors=1,?terminalPalette=). Colours:lib/features/chat/shell/chat_shell_terminal_{theme,palette}.dart; rail:lib/shell/navigation_rail.dart. - Emulator Unicode and drawing:
third_party/xterm/lib/src/utils/unicode_{width,tables}.dart,core/buffer/{graphemes,grapheme_join}.dart,ui/{cell_glyphs,text_runs,row_pictures,painter}.dart,third_party/xterm/tool/gen_unicode_tables.py; teststest/third_party_xterm/{grapheme,glyph_paint}_test.dart. Symbols fontfonts/symbols-nerd-font/,lib/ui/text/terminal_symbols_font.dart. Benchtool/perf/terminal_stream_bench.{dart,mjs}. - Client throughput (round 3): feed
lib/features/chat/shell/chat_shell_terminal_{feed,yield,yield_stub,yield_web}.dart; emulatorthird_party/xterm/lib/src/core/escape/parser.dart,core/buffer/{buffer,line,grapheme_join}.dart,utils/{byte_consumer,circular_buffer}.dart; teststest/third_party_xterm/write_path_test.dart,test/features/chat/shell/chat_shell_terminal_feed_test.dart; benchestool/perf/terminal_parse_bench.dart(VM or V8),tool/perf/terminal_stream_profile.mjs(CPU profile of the web bench).
Verification
Go 1.x / Flutter 3.44.6, macOS host, tmux 3.7c (/opt/homebrew/bin/tmux).
-
go test ./internal/protocol ./internal/pipeline ./internal/server -count=1:ok …/protocol 0.188s,ok …/pipeline 8.193s,ok …/server 69.120s. Terminal tests: open/list/input/resize/output-resume/close over the websocket with two clients; shell exit status; cwd containment, input bounds, unknown ids, the 8-terminal limit; tmux survives a manager restart (list running, screen redrawn, shell variable kept, close kills the session); a killed tmux client is replaced; without tmux the stop and a crashed record are listed as ended with their reasons; OSC titles.-race -count=4on the terminal tests: ok. Each tmux test uses its own socket and removes it.go vet,gofmt -l: clean.GOOS=freebsd go build ./internal/server,GOOS=linux go test -c: ok. -
tool/memwatch/full.sh test/features/terminal:PASS: 15 passed(hub: lazy activation, ordered output + gap re-read, reconnect resume and new-stream re-read, open/select/close, foreign open/close frames, titles and ended reason, input, multi-machine, refusals; surface: Ctrl+` and button toggle while the terminal has focus, hiding keeps shells, panel drag-resize remembered and app shrinks, float drag/resize/ minimise/maximise, tabs select/close/new, mode switch from the menu, Settings mode choice, narrow full-screen page with key toolbar). -
tool/memwatch/full.sh test/features/chat:PASS: 1137 passed, 0 failed. -
test/application test/shell test/features/settings: 129 passed, 51 failed — the same 51 failing tests as the base commit (compared by name). -
tool/analyze.sh: clean.flutter build web: built.FLUTTER_XCODE_ARCHS=arm64 flutter build macos: built (35.0MB). -
Real Chrome (
tool/capture, probe?terminals=1, 1280x820), inspected:/tmp/terminal-panel/panel-{light,dark}/01-panel.png,03-panel-three-tabs.png,04-panel-taller.png(dragged up 200 px);/tmp/terminal-panel/typed-{light,dark}/01-panel-tab2-typed.png(second tab,pwd+Enter typed as key events, focused cursor);/tmp/terminal-panel/float-{light,dark}/01-float.png,02-float-moved-resized.png,03-float-minimised.png,04-float-maximised.png;/tmp/terminal-panel/settings-light/0{1,2,3}-*.png(Appearance → Terminal, choosing Floating window, then the bar button);/tmp/terminal-panel/narrow-light/01-narrow-page.png(560 px page with key toolbar);/tmp/terminal-panel/cupertino-dark/0{1,2}-*.png(Cupertino, two machines: tabs name their machine, New terminal asks which);/tmp/terminal-panel/chat-open/02-chat-opened-terminal.png(chat More → Open in terminal opened/workspace/demo). -
Scratch server end to end (
go build ./cmd/pipelines-server;env -iwith HOME, XDG_DATA_HOME, DB andTMUX_TMPDIRunder/tmp/term-e2e, OS-chosen loopback port,SHELL=/bin/bash; Node websocket driver/tmp/term-e2e/drive.mjs, script/tmp/term-e2e/run.sh; server stopped and tmux server gone afterwards):opened term_c76697ebb5a10ce7 cwd=/tmp/term-e2e/home shell=/bin/bash tmux=pipelines-term_c76697ebb5a10ce7 size=100x30 typed command ran: before-restart-42 seen server 94915 stopped tmux sessions while the server is down: pipelines-term_c76697ebb5a10ce7 pane_pid=94934 tmux scrollback while the server is down: line-1 / line-2 / line-3 / before-restart-42 server pid 94951 port 62223 list after restart: term_c76697ebb5a10ce7 running tmux=pipelines-term_c76697ebb5a10ce7 stream=e5cca0de2a86 reattached output (1463 bytes) has earlier lines: line-1=true line-3=true before-restart-42=true shell state survived: KEEP=kept-across-restart close: terminal_close status=closed list after close: 0 terminals tmux sessions after close: no server running on /private/tmp/term-e2e/tmux/tmux-501/pipelines input lines logged: 0 KEEP in log: 0
Toggle shortcuts, focus and motion (2026-11-09)
- Fixed on the way: the previous Ctrl+
handler was aHardwareKeyboardhandler, which does not stop the focus tree, so a focused terminal also received the backquote. The shortcuts are nowFocusManagerearly key handlers; a widget test asserts noterminal_input` for each chord and no input from a held chord's repeats. tool/memwatch/full.sh test/features/terminal:PASS: 38 passed(each of Alt+T, Ctrl+T, Cmd+T, Ctrl+toggling the panel and the window from a text field and from inside the terminal; Option+T (†) by key position; Shift / second modifier ignored; held chord toggles once; focus on show, on reload restore and on pointer tab change; focus back to the field on hide; Ctrl+Tab / Ctrl+Shift+Tab cycling and wrapping only while shown; auto-start of a terminal when none; narrow page open/close/focus/ Ctrl+Tab; panel slide with the app shrinking mid-way, window scale+fade, hide keeps it mounted, animation-speed dilation, reduced motion instant; labels per platform; withChatScreen`: Ctrl+Tab cycles panes when hidden, terminal tabs when shown, and the composer gets the keyboard back).tool/memwatch/full.sh test/shell:PASS: 128 passed.tool/memwatch/full.sh test/features/chat:PASS: 1144 passed, 0 failed.tool/analyze.sh: clean.flutter build web: built.FLUTTER_XCODE_ARCHS=arm64 flutter build macos: built (35.1MB).- Real Chrome (
tool/capture, probe?terminals=1, 1280x820; the kit's film step gainedfilm=press:<chord>to film a key press), inspected:/tmp/terminal-toggle/panel/02-panel-show-sheet.png,/tmp/terminal-toggle/panel-warm/01-panel-show-warm-sheet.png(269 ms frame: panel half way up, app above shrunk),panel/07-panel-hide-sheet.png(183 ms frame mid-slide),panel/03-focused-after-alt-t.png,panel/04-typed.png(pwdtyped straight after Alt+T),panel/05-ctrl-tab.png,panel/06-ctrl-shift-tab.png;/tmp/terminal-toggle/float/02-float-hide-sheet.png(178 ms, scaled and faded),float/04-float-show-sheet.png(164 ms),float/05-float-focused.png,float/06-menu-shortcuts.png(web on macOS lists "Show or hide: Ctrl+T, Option+T, Ctrl+", no tab keys);/tmp/terminal-toggle/chat/0{1..4}-*.png(composer "draft ", Alt+T,lstyped in the terminal, Ctrl+Tab to~, Alt+T,oklands in the composer: "draft ok", no strayt/†`). - Not verified: CDP key events are delivered to the page directly, past the
browser's own shortcuts, so the captures cannot show which chords a real
browser keeps; the list above follows the browsers' documented reserved
shortcuts (Cmd+T, Ctrl+T outside macOS, Ctrl+Tab, Ctrl+Shift+Tab). OS-level
keys via
osascript/System Events were not permitted (it waited on the automation permission), so neither real Chrome nor the native macOS build's Cmd+T was driven by real keystrokes; native behaviour is verified by widget tests only.
Login prompt instead of tmux (2026-11-10)
The tmux results above (restart survival, client replacement, the
/tmp/term-e2e run) describe the removed tmux backing.
-
go test ./internal/protocol ./internal/pipeline ./internal/server ./cmd/pipelines-server -count=1:ok …/protocol 0.190s,ok …/pipeline 8.169s,ok …/server 70.840s,ok …/cmd/pipelines-server 0.217s.go test -race -run Terminal -count=3 ./internal/server: ok.go vet,gofmt -l: clean;GOOS=linux GOARCH=amd64 go vet+go test -c,GOOS=freebsd go build ./internal/server: ok. Terminal tests use a fakesuon PATH (printsPassword:, reads a line with echo off, accepts onlytest-password; modes for no prompt, silence and no terminal), so no real password is ever needed: login args per OS and refusals (root, no su, no user, other systems), refusal without su on PATH or in the usual directories, the prompt in a real PTY, wrong password ended with its reason and exit 1, right password gives a shell in the start folder with the password absent from the output, unprompted/silent/failing logins refused and never listed, ended on stop and on restart with their reasons, no tmux in the record, leftover-session cleanup on a test socket (onlypipelines-term_*killed), and the websocket open/input/resize/resume/ close, exit status and limits tests logged in through the fake. -
tool/memwatch/full.sh test/features/terminal:PASS: 48 passed, 0 failed(newterminal_first_open_test.dart: first show opens exactly one terminal in the panel and in the window, and six toggles open no more and close none; closing every tab then toggling opens none; a running terminal from before is shown, not added to; only ended ones (server restarted) → one new login; a hand-opened one counts as first and New terminal still opens another; three quick taps open one; the narrow page opened three times opens one).tool/analyze.sh: clean. -
Real
/usr/bin/suon this Mac, as the same non-root user, in a PTY (/tmp/su-probe/probe.py):Password:; a wrong password →su: Authentication failed, exit 1. The operator's password was never typed. -
Scratch server live check (
/tmp/term-login-e2e/run.sh, driverdrive.mjs):env -i, HOME, XDG_DATA_HOME, DB andTMUX_TMPDIRunder/tmp/term-login-e2e, OS-chosen loopback port,PIPELINES_MDNS=off; two sessions planted on the scratchtmux -L pipelinesfirst:leftover sessions planted on the scratch tmux -L pipelines: mine pipelines-term_leftover server pid 43971 port 50492 scratch tmux sessions after start: mine opened term_f04cd8ac8c198a09 status=running shell="/usr/bin/su -l alan" cwd=/tmp/term-login-e2e/home tmux=(none) output of term_f04cd8ac8c198a09: "Password:" su processes under the server: 43987 su server 43971 stopped su processes left: 0 list after restart: term_f04cd8ac8c198a09 exited reason="The Pipelines server restarted and this terminal ended with it. Terminals end with the server; run tmux inside a terminal to keep work across restarts." opened term_add0f7930d880b69 status=running shell="/usr/bin/su -l alan" cwd=/tmp/term-login-e2e/home tmux=(none) output of term_add0f7930d880b69: "Password:" close: terminal_close status=closed terminals table: (empty after closing both) input requests logged: 0 terminal: ended 1 tmux session(s) an earlier Pipelines server left on tmux -L pipelinesThe stop's own save lost the race with the store closing (
terminal save …: sql: database is closed, as before this change), so the restart recorded the end instead. The scratch server's opencode stage service outlived it and was killed by hand. -
Not verified: logging in for real (needs the operator's password), Linux su, and the app against a live server in a browser (widget tests only).
Terminal input and resize fixes, round 1 (2026-11-25)
- Resize: live terminals run with
reflowEnabled: false; the old blank-row-trimmingresizeoverride now applies only to finished (reflowing) output, and narrowing erases cells past the new width. Tests:test/features/chat/shell/chat_shell_terminal_resize_test.dart(long lines shrink/grow with the prompt on the cursor row, shell redraw and command output after shrinking, no stale text after widening, cleared screen and scrollback stay cleared, a view whose box shrinks and grows). - Keys: xterm encoding for Alt/Meta, Ctrl symbols, modified special keys,
DECCKM and DECKPAM (
chat-interactive-terminal.md, Keys); Option as Meta setting. Tests:chat_shell_terminal_input_test.dart(key event to bytes, Linux and macOS variants, setting on and off, toolbarkeyInput),chat_shell_terminal_test.dart(keys through the real view, Ctrl-V paste intact),terminal_surface_test.dart(setting saved and restored, hidden off Apple platforms). - Shortcuts: inside a terminal Alt+T and Ctrl+T reach the shell; Cmd+T
and Ctrl+
still toggle (terminal_shortcuts_test.dart`). - Not verified: bytes against a real PTY in a browser or native build after the change (widget tests only), real macOS Option events (native and browser logical-key shapes are assumed as the tests model them), AltGr on a real non-US Linux/Windows layout.