User guide: Continue a terminal session anywhere. Starting a session from another device: Session start.

Shape

The Gizzi TUI (src/cli/ui/ink-app) runs its own agent loop. It does not hand turns to the engine. Instead it attaches to the engine on the same computer (Desktop’s on 127.0.0.1:4096, or gizzi serve; GIZZI_ENGINE_URL overrides) and mirrors itself into an ordinary engine session: Surfaces need no new client contract. They keep using the routes and event feeds they already use for engine sessions.

The session row

POST /v1/terminal/sessions creates the row, or adopts the existing one for the same terminal session id (a resumed TUI session keeps its row):
The row is a normal Session.Info with:
  • surface: "code", so it lists under Code on Desktop and in the phone drawer;
  • sourceRef.harness: "gizzi-tui" and sourceRef.sessionId set to the TUI session id. This is the Terminal badge signal: allternit-api transform_session and the engine’s /api/v1/agent-sessions facade both pass metadata.sourceRef through;
  • directory set to the terminal’s folder, while the row lives in the engine’s default project, where Desktop, the web app and the phone list and stream sessions. /v1/session/<id>/… requests for a terminal row stay in the default instance (sessionDirectory in server.ts);
  • defaultModel set to the terminal’s model, used if the engine continues the session later.

Names

A terminal row’s title is the first real prompt. Until one exists the engine stores a default name, New session - <ISO time>. No surface shows it raw. The web app, phone and Desktop use src/lib/sessions/session-display-title.ts (first prompt, else “New session · Nov 17”); the Gizzi session list and picker (cli/commands/session.ts) and getLogDisplayTitle apply the same rule.

Terminal → engine

TerminalMessage is the transcript already in engine terms. There is one user message per prompt and one assistant message per turn. Tool results are folded into their tool part:
Engine ids come from the terminal keys (msg_/prt_ plus a time prefix and a hash), so re-sending a message updates it in place. The TUI sends only messages whose content changed, debounced by 120 ms. What does not sync. Terminal-only local commands (/remote, /model and the like) and their output (<local-command-stdout>, shell escapes, caveats) are never sent, so they cannot become a prompt or the session title. A prompt-type slash command the model runs (/review diff) is sent as readable text, /review diff, once the model answers it (or at once while the turn is busy). The title comes from the first real prompt. Re-attach. When the inbox (re)connects, which includes the first connect and a restarted engine, the terminal forgets what it already sent and pushes the whole transcript and the real busy/idle status at once, then the open approvals again. A failed push retries after 2 s without waiting for the next message. If the engine has no row for the session any more (its data was reset), the terminal adopts it again by its terminal id and listens on the new session id.

Engine → terminal: the inbox

GET /v1/terminal/sessions/:id/inbox?host=&pid= is a server-sent event stream. While it is open the session is live: TerminalLive.attached(id) is true and session.terminal { sessionID, attached, host, cwd } is published on attach and detach. GET /v1/terminal/sessions lists live terminals. Remote Control state. The engine keeps an rc value per session, { state, since }, and publishes session.rc { sessionID, rc } when it changes. state is connected while the inbox is open, reconnecting for 10 s after it drops (the terminal re-opens it after 2 s), offline for a terminal session with no terminal, and off for an ordinary engine session. since is when the state began (ms), or null when the engine never saw it change (after an engine restart, a terminal row reads offline since its last update). GET /v1/remote-control/sessions and GET /v1/remote-control/sessions/:id return it as rc beside session and status. The web maps rc.state to metadata.rcState. A prompt typed on a surface is only the person’s text: for a terminal session the web app skips memory recall, project and connector context and the answer manuals (the engine hands the terminal just the text, so building them only added serial round trips before the prompt was posted, which is seconds over the phone relay). On a live row SessionPrompt.prompt never starts an engine turn. It returns an unsaved user message right away. A noReply note is not forwarded. When the inbox closes (the terminal exits or loses the engine), the row goes idle and becomes an ordinary engine session. A later prompt runs on the engine with workdir set to the terminal’s folder.

Remote surfaces

Nothing new on the backend. The phone, the web app and the PWA reach a computer’s sessions through the paired-runtime relay (/api/v1/runtime-devices/:runtimeId/proxy → that computer’s allternit-api → the engine), and cloud computers run the same engine. /remote builds https://m.allternit.com/?runtime=<runtimeId>&session=<sessionID> (and the same on ai.allternit.com) from runtime-device.json and shows it as a QR code. /desktop opens allternit://session?id=<sessionID>. Desktop’s main process turns that into the app’s allternit:open-session-link event (surfaces/allternit-desktop/src/main/unified-main.ts).

Surfaces

Approval cards name what the tool acts on: the engine permission carries patterns (the file, command or URL) and metadata.input; the composer bar on the phone and PWA shows it under “Permission required”. A tool that is running or waiting for approval reads as running: the session API reports a message with no completed time as ending when it started, so the web transcript treats a recent unfinished turn with a running or pending tool as still being written. The terminal footer’s context meter ignores an all-zero usage record left by a stopped turn and keeps the last real report.