Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pi-gui-artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The model composes a visual from Aiden's own component catalog instead of writin

A chat hosted by the headless server (`packages/cli`) has no window to draw in, so it reuses the snapshot shapes above (`packages/cli/src/server-visuals.ts`), with no Remote protocol change:

1. **HTML visuals.** `render_artifact` runs the same HTML check, keeps the export page in `<agentDir>/artifacts`, then draws the visual with an installed Chrome or Chromium found only at fixed paths (`/Applications/Google Chrome.app` and `/Applications/Chromium.app` on macOS; `/usr/bin/google-chrome-stable`, `/usr/bin/google-chrome`, `/usr/bin/chromium` and `/usr/bin/chromium-browser` on Linux; never a `PATH` lookup, a variable or a download). The browser is looked for only when a visual is drawn. It runs headless with its sandbox on, a new temporary profile that is deleted afterwards, a minimal environment, a proxy at a closed local port, host resolution off, every request failed through DevTools on the page and its frames, and the network emulated offline; the visual is the guest frame inlined in a host page under the export CSP, in the light theme at 720 px (column) or 1024 px (wide) and twice the pixel density, with its libraries inlined. Drawing waits for the page to stop changing size, takes at most 15 s, and runs one at a time. The picture (PNG, JPEG over 2 MiB, at most 4 MiB) is stored on the reply with the visual's `htmlArtifacts` entry, its placement and its reserved `visual-snapshot_<sha256>` attachment, so phones and paired desktops show it like a Mac's snapshot. With no browser, as root (where Chrome would need its sandbox off), when drawing fails, or when the reply already carries 20 pictures or 16 MiB, nothing is stored for the visual.
1. **HTML visuals.** `render_artifact` runs the same HTML check, keeps the export page in `<agentDir>/artifacts`, then draws the visual with an installed Chrome or Chromium found only at fixed paths (`/Applications/Google Chrome.app` and `/Applications/Chromium.app` on macOS; `/usr/bin/google-chrome-stable`, `/usr/bin/google-chrome`, `/usr/bin/chromium` and `/usr/bin/chromium-browser` on Linux; never a `PATH` lookup, a variable or a download). The browser is looked for only when a visual is drawn. It runs headless with its sandbox on, a new temporary profile that is deleted afterwards, a minimal environment, a proxy at a closed local port, host resolution off, every request failed through DevTools on the page and its frames, the network emulated offline, and the sandboxed guest frame kept in the page's process (`IsolateSandboxedIframes` off, since Chrome 158 crashes on setting the page with it on); the visual is the guest frame inlined in a host page under the export CSP, in the light theme at 720 px (column) or 1024 px (wide) and twice the pixel density, with its libraries inlined. Drawing waits for the page to stop changing size, takes at most 15 s, and runs one at a time. The picture (PNG, JPEG over 2 MiB, at most 4 MiB) is stored on the reply with the visual's `htmlArtifacts` entry, its placement and its reserved `visual-snapshot_<sha256>` attachment, so phones and paired desktops show it like a Mac's snapshot. With no browser, as root (where Chrome would need its sandbox off), when drawing fails, or when the reply already carries 20 pictures or 16 MiB, nothing is stored for the visual.
2. **Native visuals.** `render_ui` compiles the markup and stores the `uiVisuals` entry. Its fallback text writes each chart's data (a scatter chart without `x` keeps every numeric column), a heatmap's cells and a sparkline's values, and writes every table row as one plain line of labelled values (`Customer: Acme · Revenue: $1.2M`) rather than Markdown pipes or padded columns, since phones draw the text as-is in a proportional font. Cells, and chart, sparkline and heatmap labels, lose control and text-direction characters and characters drawn as nothing (zero-width spaces, word joiners and invisible operators, the BOM, interlinear annotation marks and lone surrogate halves; the zero-width joiner and non-joiner stay, for emoji and Persian or Indic spelling), before they are clipped and never in the middle of a character, and a line or paragraph separator reads as a space (a label is one line of at most 120 characters), a plain row is cut at 400 characters, and a sparkline of more than 32 values keeps its first value and its latest 30 with the count, so its `…` always stands for at least two values. Phones and paired Macs show that text, since Remote projects no markup: a paired Mac draws it as plain lines where the tool call ran, with nothing to tap and no Keep in Artifacts. The Mac drops the same control, text-direction and invisible characters from each line and the title (a tab stays, and a line or paragraph separator reads as a space) before it cuts the text at 4,000 UTF-16 units and a title longer than 120 with an ellipsis, never in the middle of a character, and titles a visual with no visible title "Visual", so an odd title never hides the visual. A visual a Mac host pictured shows as its picture instead. The per-reply and per-chat visual limits apply. If the browser's temporary profile cannot be deleted, it is left in the temp folder and the drawn picture is still kept.
3. **What Aiden is told.** Each tool result begins with what the person sees: "Shown as an image" (a still picture that does not move or respond to taps), "Shown as text" (phones and paired Macs show the text that follows), or "Not shown" with the reason and a request to give the key facts as text or a table.
4. **Clients.** The server does not offer the visual viewer (`chat-visual-viewer-v1`), so phones show the picture or text only. iOS (`AidenChronologicalTranscript.swift`) and Android (`aidenVisualDisplay`) already draw a visual's snapshot, else its fallback text, else its title.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The login service is shared by this OS user, even when different `AIDEN_CODING_A

Phones and Macs paired with the server see its workspaces, chats, Bots, scheduled tasks and files. Chats run on the server through Pi's SDK with a headless tool set: workspace tools under the workspace's access tier, memory, todo, MCP, web search, advisor, and inline visuals (see below). The advisor runs only when the request names both the reviewer's provider and model, because the server cannot show the desktop's model chooser. Image display (`display_image`) and `ask_user_question` are not available on the server. Server sessions don't load codemode and declare MCP tools directly.

- **Inline visuals.** In a workspace chat, `render_artifact` checks the HTML exactly as the desktop does, saves an offline export page in `<agentDir>/artifacts`, and then draws the visual once as a still picture (PNG at twice the pixel density, 720 px wide or 1024 px for `layout: "wide"`) that paired phones and desktops show in the reply, as they show a Mac's visual snapshot. The server draws with an installed Chrome or Chromium found only at fixed paths: `/Applications/Google Chrome.app` or `/Applications/Chromium.app` on macOS, and `/usr/bin/google-chrome-stable`, `/usr/bin/google-chrome`, `/usr/bin/chromium` or `/usr/bin/chromium-browser` on Linux. It never searches `PATH`, reads no variable to find one, and downloads nothing; the Docker image ships no browser. The browser is looked for only when a visual is drawn, runs headless with its sandbox on, a new temporary profile (deleted afterwards), every network request refused and a 15-second limit, and draws one visual at a time. A server running as root does not draw visuals, since Chrome would need its sandbox off there. Without a browser, or when drawing fails, the person sees no visual and Aiden is told so and asked to give the facts as text. `render_ui` visuals reach the phone as their text rendering, with each chart's, heatmap's and sparkline's data written out and each table row as one plain line of labelled values (`Customer: Acme · Revenue: $1.2M`), since the server has no component renderer; a Mac paired to the server shows the same text. Every tool result says exactly which of these the person sees. A visual is never interactive on the server: phones are not offered the visual viewer.
- **Inline visuals.** In a workspace chat, `render_artifact` checks the HTML exactly as the desktop does, saves an offline export page in `<agentDir>/artifacts`, and then draws the visual once as a still picture (PNG at twice the pixel density, 720 px wide or 1024 px for `layout: "wide"`) that paired phones and desktops show in the reply, as they show a Mac's visual snapshot. The server draws with an installed Chrome or Chromium found only at fixed paths: `/Applications/Google Chrome.app` or `/Applications/Chromium.app` on macOS, and `/usr/bin/google-chrome-stable`, `/usr/bin/google-chrome`, `/usr/bin/chromium` or `/usr/bin/chromium-browser` on Linux. It never searches `PATH`, reads no variable to find one, and downloads nothing; the Docker image ships no browser. The browser is looked for only when a visual is drawn, runs headless with its sandbox on, a new temporary profile (deleted afterwards), every network request refused and a 15-second limit, and draws one visual at a time. The visual's sandboxed frame stays in the page's own process (Chrome's `IsolateSandboxedIframes` is off): with it on, Chrome 158 crashes when the page is set, and the extra process slowed drawing on small machines. A server running as root does not draw visuals, since Chrome would need its sandbox off there. Without a browser, or when drawing fails, the person sees no visual and Aiden is told so and asked to give the facts as text. `render_ui` visuals reach the phone as their text rendering, with each chart's, heatmap's and sparkline's data written out and each table row as one plain line of labelled values (`Customer: Acme · Revenue: $1.2M`), since the server has no component renderer; a Mac paired to the server shows the same text. Every tool result says exactly which of these the person sees. A visual is never interactive on the server: phones are not offered the visual viewer.
- **Forks.** Paired phones fork server chats with the Remote `chat-fork-v1` feature; the fork's journal is seeded from the copied visible messages, so tool results before the cut are not carried. The server does not offer Fork with summary (`chat-fork-summary-v1`).
- **Paired desktops.** A Mac or Linux desktop paired to the server lists its chats in the sidebar and the Inbox. The server serves the host feed (`GET /host/events`), live-run observation and run control (Stop and approvals), shared read markers (`POST /chats/{id}/read`), and the Inbox's Pin, Done and Snooze (`POST /chats/{id}/triage`), with the same `inbox-signals-v1` row times, last assistant message ID and Inbox bucket as the desktop. Mark read acknowledges the reply displayed on the paired device. Read markers and triage are kept in `chat-read-markers.json` and `chat-triage.json` in the server's data directory, and snoozes end on a timer that runs with `aiden serve`. A desktop paired before this server version doesn't need to pair again: it picks up the host grants on its next connection after Aiden starts (relaunch Aiden if it was already connected). Approvals from a paired device apply once; the server keeps no "always allow" approvals and refuses one. A paired device that negotiates `approval:cards` (contract revision 61) gets the same typed approval card the desktop sends and can allow only what that card offers; the approval mode and rules routes, Bot settings changes, suggestions and Templates are desktop-only. The server's runs don't take questions or mid-run input, so a paired desktop shows Stop and approvals on them but no Steer. The server's Bot rows carry no Needs you, Failed or last-reply signals, so its Bots appear in a desktop's Inbox only while they are open.
- **Joining a running chat.** Revision 58 clients can request a bounded snapshot of the server’s public reply, reasoning and activity when they attach or reconnect. Saved messages are available through the usual chat history.
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/server-visuals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ export function serverBrowserArguments(profileDir: string, platform: NodeJS.Plat
"--disable-crash-reporter",
"--disable-domain-reliability",
"--disable-client-side-phishing-detection",
"--disable-features=Translate,MediaRouter,OptimizationHints,AutofillServerCommunication,CertificateTransparencyComponentUpdater",
// IsolateSandboxedIframes would put the sandboxed guest frame in a process
// of its own. Setting the host page then crashes Chrome 158 ("Check failed:
// has_site_"), and on slow machines the extra process can cost most of the
// 15 s limit. The frame stays sandboxed, offline and fully blocked either way.
"--disable-features=Translate,MediaRouter,OptimizationHints,AutofillServerCommunication,CertificateTransparencyComponentUpdater,IsolateSandboxedIframes",
"--metrics-recording-only",
"--no-pings",
"--mute-audio",
Expand Down
Loading