Repository navigation
Terminal
nodemode-ai edited this page Nov 19, 2026
·
2 revisions
The window has a terminal dock: shell tabs, Claude Code tabs, Codex and Cursor tabs when the engine finds those programs, and a Chat tab, with an ask bar at its foot. It sits at the bottom of the window or in a column at the right (the side button in its head switches; side, size and open state are remembered). The engine owns every process; the window draws output and sends keys. The dock is the family's shared module, at 2.0.1 here.
| Source path | What lives there |
|---|---|
backend/app/services/terminal.py |
PTY sessions: ptyprocess on macOS and Linux, pywinpty (ConPTY) on Windows; a 256 KiB scrollback per session; resize, restart and close; the read-only Claude session has no process, Claude Code's shell calls are written into it |
backend/app/routers/terminal.py |
/api/terminal: list, open, resize, restart and close, and a WebSocket at /api/terminal/{id}/stream (text frames are output, binary frames are control messages). origin_ok refuses any Host that is not a loopback name and any Origin that is not a configured CORS origin, a loopback or Tauri one, because WebSockets are not covered by CORS |
backend/app/services/claude_code.py, routers/claude_code.py
|
Finds claude (FORMVIS_CLAUDE_BIN, then the path), reports installed, version and signed in, starts it in stream-JSON with the project's .mcp.json and the chosen permission mode (Ask, Auto-accept edits, Plan), streams its messages on a WebSocket and answers Ask-mode permissions |
frontend/src/dock/ |
The family's shared dock module, the same bytes in every app and never edited here (MANIFEST.json holds each file's SHA-256). dock.ts: a tab per session, the head buttons, the More agents menu (Codex, Cursor, Outside agents, Show me around), the ask bar, a grip to resize; terminal.ts: xterm.js 6 with the fit addon, the only file that imports it, loaded with the first terminal; placement.ts: bottom or right, sizes, the stored state; keys.ts: keys typed in the dock stay in the dock; consent.ts: the outside-agent question, a native modal dialog; tour.ts: the first-run guide; chat.ts: the Chat tab (status line, tool chips, mode select, Allow and Deny, Stop, New Chat, Continue in Claude Code); strings.ts, icons.ts, dock.css (only --dock-* and --z-* tokens); adapter.ts, the DockAdapter type; CONTRACT.md, what an engine must provide for each adapter function |
frontend/src/dock-adapter.ts, frontend/src/styles/dock-tokens.css
|
formvis's own side: its words, storage key and sizes, routes, host classes, t() (which fills {app}, {noun} and {start} before looking the English sentence up in the language tables), the theme signal, the dock's chord and the keys that may leave the dock (F1, the Preferences chord, the Assistant chord), the terminal channel, and outsideAgents, which shows each waiting question, sends the answer for that one request, stores Always allow as that agent's policy and keeps Blocked with the engine; and the map from --dock-* onto formvis's tokens. app.ts constructs the dock and mounts it. Window > Terminal (terminal.toggle, Mod+J), Window > New Terminal (terminal.new), Window > Claude Code (agent.claude.open) and Window > Chat with Claude (agent.chat) stay in app.ts
|
frontend/src/styles/terminal.css, frontend/index.html
|
Layout, and the boot script that writes data-ft-dock, data-ft-dock-side, data-ft-dock-h and data-ft-dock-w on the root element before first paint, so a dock left open opens in place without moving anything |
- Process control belongs to the engine or the Tauri shell, never to page code; the page reaches the engine only through
frontend/src/io/api.ts. - A terminal is remote code execution, so every route and socket passes
origin_ok, and only the formvis window gets in: opening, resizing, restarting and closing a terminal need the window key inX-Formvis-Window-Key(403 "Only the formvis window can do this" without it), and the terminal, Claude Code and agent sockets must send{"type": "key", "key": ...}as their first message (backend/app/core/window_key.py). An agent's permission request is never answered for the person. - Terminal output is appended to xterm's own nodes, never rebuilt, and xterm's scrollbar elements are hidden by
terminal.css(the global sheet does not name them). - Every child ends when its tab closes, the window goes away or the engine exits.
- Keys typed in the dock, its dialog or its guide stay there: B in a terminal does not pick the Brush. Only the dock's chord (Ctrl+J, Cmd+J on a Mac) and the keys the adapter's
passKeynames leave it.
- With Outside agents on Ask, a request from an outside agent opens one dialog in the middle of the window: "Allow an agent calling itself NAME to make changes in formvis?", what it asked to do, and Deny, Allow once and Always allow any agent named NAME. Several waiting requests are shown one at a time ("Request 1 of 2").
- An answer covers only the request shown. Allow once runs that one call and the next call asks again. Deny refuses it, and formvis then refuses that agent for ten minutes without asking; other agents are still asked. Escape is Deny.
- Always allow is kept for that one agent name (its policy becomes Allow in Agent Connect); another name is still asked. The name is the agent's own claim: any program on this computer can give any name, so a standing yes is a yes to everything that calls itself that.
- A request can be withdrawn: when the caller hangs up or the question times out (three minutes), the dialog closes unanswered and nothing runs. After a reload the window shows the questions still waiting.
- Blocked is held by the engine, not by the page: it refuses outside agents and the tool calls of formvis's own Claude Code tabs and Chat at once, with or without a window, and stays after a restart. A plain shell tab still opens; it is the person's own.
- The choice is under Preferences > Plugins, Outside agents (Ask, Allowed, Blocked), also reached from the dock's menu; only the window can change it.