Repository navigation
feat: run agents on a Gentle Shell server (native thin client of gentle-shell serve) - #255
Draft
ismaelosuna7824 wants to merge 74 commits into
Draft
ismaelosuna7824 wants to merge 74 commits into
ismaelosuna7824 wants to merge 74 commits into
Conversation
Address normalization, server error wording, SSE framing, the stream cursor (seq, snapshot-required, resync, dialogs shown once) and the dedupe of the stream's serve-rpc responses, with tests.
PiProcess::serve follows a server session over HTTP and SSE: commands POST to /rpc in order, answers read as stdout, 202 pending settled from the stream, reconnects after the last seq with backoff and a 45 s silence limit, snapshot-required as Incoming::Resync (the tab reads its state again). shutdown stops the session (DELETE); detach leaves it running. pid() is None for a server session. Cargo: pi-rpc now uses gentle-core and ureq 3 (already locked by the app).
Configuration pairs with a server (POST /api/pair) and keeps its device token in an owner-only server-tokens.json. Server tabs start or reattach to sessions, persist the server session with the pane and stay running when the app quits; closing a tab stops its session. Files, git, terminals, Tower, Setup installs and Providers' terminal say they're not available on a server yet; the palette opens a typed server folder.
A server tab whose session ended (the server stopped, or the session was stopped there) only read 'gentle-shell stopped, Exit code 0' with no way back short of reopening the tab. It now reads 'Disconnected from <server>' and offers Start again, which opens a new session there on the same conversation; a start that couldn't reach the server offers it too. The stopped card also fits a pane narrower than 560px instead of being cut off.
Configuration's Gentle Shell server option takes the connection code gentle-shell serve share prints (gsc1.…): pasting it looks for the server at every address in the code at once (GET /.well-known/gentle-shell), pairs with the first that answers as that server and saves that address. The address and pairing code fields stay under Enter address manually. - gentle_core::serve: decode_connection_code (CodeError), identity, search - pi_rpc::serve: locate (1.5 s per address, 4 s in all), pair_code; ServeError carries the server's error code - tests: decoder and search in core; locate and pair_code against the fake server in pi-rpc
…ough
Configuration's Gentle Shell server field is now Code (XXXX-XXXX): it takes
the 8-character pairing code gentle-shell serve share shows, or the long
gsc1. code it prints as a fallback. For the short code the app broadcasts
{"t":"gentle-shell/discover","v":1} over UDP (255.255.255.255 and each
interface's directed broadcast, ports 8787-8796), checks every answer at
/.well-known/gentle-shell on the address it came from, then pairs with the
one server found, lists several to pick from (name and address), or says
to check the Wi-Fi and firewall (sudo ufw allow 8787) or paste the long code.
- gentle_core::serve: read_code (Entered), short_code, discover_query,
read_announce, directed_broadcast, discovery_targets, Nearby, pick
- pi_rpc::serve: nearby (one ephemeral UDP socket, 1.5 s, verified),
pair_nearby
- app: interfaces from sysinfo's network feature (no new crates)
- tests: core rules; nearby and pairing against a UDP responder on 127.0.0.1
- set_host_tools and host_tool_result requests with the contract's limits (names, labels, descriptions, schemas, guidelines; 8 MiB result content), per-method request caps (1 MiB / 9 MiB) - host_tool_call / host_tool_cancel event decoders, and their answers - PiProcess::desktop: a server session sends both through POST /api/sessions/:id/desktop - the serve stream reads a re-sent host_tool_call frame as a record
- a tab on a Gentle Shell server that takes set_host_tools offers open_page, browser, screen and (beside a canvas) canvas_read/edit/shot, with the guidance from the app's instructions and extensions as each tool's description and guidelines; again after a reconnect - calls run where the app's commands run them (window browser driver, gentle-screen in-process, the open canvas in-process) and answer through the server's /desktop; cancels drop the call, failures answer isError - local, WSL and command tabs keep their instructions and extensions - gentle-device, themes and gentle_ui stay out (docs/integrations.md says why)
gentle_core::genui::host runs what the app's gentle-ui.ts extension does, for an agent on a Gentle Shell server, which doesn't load the app's extensions: - normalize: each kind's spec through its own gentle_core parser and wire JSON (the rules the extension mirrors), in the extension's 'invalid <noun> spec' list; absolute refs inside the session folder made relative, ones outside it refused; review before/after texts diffed into hunks (Myers, 3 lines of context); html checked as normalizeHtml. - patch: the extension's per-kind patch merges. - summary: what the model reads of each kind, run-plan and dispatch instructions, review decisions, page context. - guide: the tool's description, parameters (examples in the spec description) and per-mode rules packed into 16 x 512 guidelines. - Engine: ids, versions, show/update/close, wait-for-decisions reviews, the /gentle-ui:event handling (edits, inserts, docs, html messages and context, mode), outcome lines, host context, state rebuilt from the conversation's details.
A server tab whose Gentle Shell takes host_message and set_host_context offers gentle_ui (with the Agent UI mode's rules; re-offered on a mode change, withdrawn when Off) and runs it with gentle_core::genui::host: - pi-rpc: host_tool_result carries details; host_message and set_host_context requests and answers, capability-gated (unknown capability methods such as set_host_activity are ignored). - The result's details are the surface, so the transcript draws it unchanged; the surfaces' /gentle-ui:event commands are answered in-app and reach the agent as host.gentle-ui.event messages (drawn as gentle-ui.event), with the outcome fed to the surface as the extension's widget would. - Html pages' shared context and the Off rule go as the host context, cleared once a run starts. - A wait: true review shows on its running call and is answered with the decisions. - State follows the transcript: rebuilt when it is replaced. Also registers the device and app_theme host tools (Call::Device/Theme, HostToolRequest::Device, the device panel request) next to them.
integrations.md: gentle_ui among the host tools, host_tool_result details, host_message and set_host_context in the method table, and how the app runs gentle_ui for a server session (tool, calls, events, context, waiting reviews, state). README: Agent UI works on a server.
ServeClient::forward (POST /api/sessions/:id/forwards) and ::tower (POST /api/tower), ServerInfo.home; gentle_core::serve::server_page sorts a server's URLs (loopback → forward), tab_folder picks a new tab's folder on a server, and error_text reads the forward and tower errors. Fake-server tests.
…les and Usage read its Gentle Shell Server pages on its loopback (design canvas, open_page, dev-server URLs, /web, browser open/goto) open through forwards, with a refused card showing the server's words; Tower tabs run Tower on the server; first run offers Connect to a Gentle Shell server and skips installs; new tabs and workspaces start in the server's home, Open folder on <server>… in ⌘K All, and a missing folder offers the home. Docs. On a server, Configuration, Profiles and Usage never touch this computer's Gentle Shell home: they ask the server over Desktop RPC (through a tab on that server, or a hidden control session in its home, stopped when the screen closes), and say 'Do this on <server>: run …' for what has no RPC. Where agents run's code field becomes ServerConnect, shared with onboarding.
gentle-term-host keeps PTYs alive for a Gentle Shell server: a Unix socket speaking JSON Lines (open, list, write, resize, close, forget, attach/detach with replay from an offset or an ANSI snapshot, shutdown), a headless alacritty Term per PTY for the snapshot, a 2 MiB replay ring, per-connection 8 MiB backpressure, and idle exit.
…n a Gentle Shell server
…hell server - Git and the file-system choke point (backend::git, backend::fs) go through the server for its folders. - Files tree, editor, search and folder browser on a Gentle Shell server. - Persistent server terminals that reattach after a relaunch.
…am through a forward
A server terminal opened (or reattached) at the emulator's initial 80x24, or at the size of a window still taking its saved bounds: a new shell drew zsh's partial-line mark and a reattached full-screen program (top) kept a shifted, garbled screen. It now opens once the laid-out size has held for the resize settle time.
… when nothing is highlighted The explorer highlighted its first entry on every listing, so Cmd+Enter opened that subfolder rather than the folder shown. Nothing is highlighted now until the arrows, a click or the filter pick an entry (going up still highlights the folder left), matching a folder picker's Open; the folder being read is the one shown from the start, so a slow server's listing doesn't open the previous folder.
…er resolved locally Cmd+O (and the other workspace keys) did nothing when no pane had focus: the workspace now takes the keyboard when nothing in the window has it. Workspace roots, find_root and gsd <folder> canonicalized server paths on this computer; a server's folder is now normalized by its text alone (gentle_core::serve::folder_key) and marks its workspace as the server's.
…pace for the folder - The typed server folder went through create_server_workspace and made a new workspace every time; it now opens like a browsed folder (show_server_folder → space_for) and switches to the existing one. - space_for / workspaces::find_root match a workspace by server and root (folder_key on a server, canonical here): a workspace of this computer or of another server at the same path is no longer taken over. - PaletteAction::CreateWorkspaceAt → ShowServerFolder.
Switching (⌘K, the sidebar, a menu) to a workspace with no tabs left the keyboard on the previous workspace's hidden pane, so the nothing-focused fallback never ran and ⌘K, ⌘O and ⌘T did nothing until a click. focus_active now focuses the workspace itself when the shown workspace has no pane, and switch_workspace calls it for an empty target.
integrations.md's Gentle Shell server section becomes a reference by area (pairing, transport, sessions and reattach, host tools with a table, forwards, Tower, folders, files, git, terminals, attachments, sessions, memories, Configuration, first run, limits) with diagrams of the pieces, pairing and reattach. architecture.md describes the server boundary (backend::fs, backend::git, terminal/remote.rs, pi_rpc::serve, crates/term-host). The README gets the steps to connect with serve share and a code.
A server session's serve_dialog_resolved record, and the 409 dialog_answered the server gives an answer that came second, close the dialog in every other tab following the session, with a quiet note in the conversation. The live Desktop RPC test pumps skip dialog-resolved records.
The host now builds and runs on Windows: ConPTY through alacritty_terminal's tty, and a --tcp transport (127.0.0.1, a system-picked port) whose port and random token go to <state-dir>/term-host.json, owner-only (0600 / a protected owner-only DACL). Over TCP a connection's first line must be {"op":"auth","token"}; anything else is refused with unauthorized and the connection closes. --tcp works on Unix too, which is how its tests run everywhere.
A server folder's commit message goes to POST /api/print { cwd, prompt } when the server offers print: the server's gentle-shell --print runs the same prompt a local folder gets, and its text is read the same way.
…ents - `DesktopEvent` and `Snapshot` decode the server's optional `epoch` (a non-empty string; absent from older servers). - `DesktopSession` keeps the epoch its baseline counts in. An event of another epoch is a numbering that restarted at 1 (a reload or a switch on the server), not a replay: seq 1 is accepted, a later first seq is a gap that resyncs from a snapshot. A snapshot of another epoch is the new baseline even when its sequence is smaller. - Within one epoch, and for servers without one, duplicates and stale snapshots are still refused. Before this, after a server-side reload (a package install) every event of the tab was dropped as a duplicate and `package_finished` never arrived.
…pair it on the server - Workspaces and saved tabs name a Gentle Shell server by its server id (server::key; an address saved before ids were kept reads as the id once a pairing knows it, migrated at load), so pairing the same server again at another address keeps its workspaces and lets restored tabs reattach their sessions. - Pairing a known server again (by id, or by pinned certificate for a pairing older than ids) replaces the earlier pairing in place: new token and address, old addresses kept; the server replaces the earlier device (POST /api/devices/self/replace) so its terminals are the new pairing's, and the window's agents and terminals on it follow the new pairing. - Unpair asks the server to remove this device first (DELETE /api/devices/self), then forgets the token; the window's tabs let go of their sessions (left running there, picked up by a later pairing) and terminals say what became of them. An unreachable or older server: forgotten here, and Configuration says the server still lists the device with the command to remove it. - A server tab keeps its session while starting and after losing its stream, so Start again reattaches instead of opening a new one. - core: ServerSession.server_id, without_ticket; pi-rpc: ServeClient::unpair/replace. Tests for the keying, in-place pairing, unpair wording and the client calls.
- The card header shows the local proxy address without the single-use gs_ticket the forward trades for a cookie (it answers with a 303 to that address).
- The folder explorer's Open Gentle Shell here (⌘↵) showed the folder's workspace but opened no agent, on a server's folders too: it now opens an agent tab there, as its terminal counterpart opens a terminal tab.
- Desktop RPC config stores model_defaults, custom_models and mcp_servers (global and project, ConfigWriteTarget::Project), with their typed writes. - ServeClient::setup/setup_stream: POST /api/setup and its stream, the upgrade's events. - serve::WRITE_LIMIT: the server's 64 MiB per file write.
- Models › Model defaults on a server reads and writes the model_defaults store: default model (from the control session's models), effort, all models; refused writes say why. - Models › Custom models and Integrations › MCP servers list and edit the server's models.json and mcp.json (global, and a trusted project's) as JSON over Desktop RPC, saved over the revision they were opened at; secrets stay as •••; Pi's validation shows. - The Providers screen of a server folder opens Configuration › Models, whose Sign-ins sign in there. - Older servers keep saying "Do this on <server>".
- With the setup capability and the admin scope, Setup (welcome, onboarding, Configuration) offers Run setup on <server>: POST /api/setup, its output streamed, then the server is checked again.
… there - Drop files or folders from the file manager on a server's Files tree to upload them (PUT /api/fs/write, folders recursively, links and files over 64 MiB skipped); names already there ask once: Replace (folders merge), Keep Both, Skip. - Download… saves a server file or folder here (files through a temporary sibling, folders copied recursively); a strip shows progress with Cancel, one transfer at a time. - /export in a server tab writes the HTML there and downloads the file export_html names (gentle_core::transfer::server_file) to the chosen path, or to Downloads with a path given. - gentle_core::transfer: upload plans, conflict choices, free names, local paths, progress words, with tests.
On a server that lists the capability desktop, Configuration, Profiles and Usage ask POST /api/desktop and follow GET /api/desktop/events (PiProcess::serve_desktop) instead of starting a hidden session; older servers keep the hidden session. Models come from the new Desktop RPC method list_available_models where there is no Pi RPC (and once advertised on a session's channel).
…ge says where open_page (and gentle-open) put the page's card hidden in the tray, as a URL an agent only mentions: a hidden card has no web view, so on a server nothing reached the forward until the user clicked the eye. Its result also said only "Opened … for the user", which agents turned into "in your browser". - An explicit open (open_page, gentle-open) shows its card at once inside the app, or opens the user's browser per Devices › Browser; URLs picked out of tool output and the design canvas still wait in the tray. - The window answers open_page once it knows: "in the Gentle Shell app's browser", "in their own web browser", or the server's reason as an error.
…forward Closing a forwarded page (× in the Pages menu, its card, a Tower tab) closed this computer's proxy, but the server kept the forward listed in GET /api/forwards until it went idle (12 h). When the last web view holding a proxy lets go, the proxy now also asks the server to close the forward (DELETE /api/forwards/:id, which covers session, server-level and Tower forwards), off the UI thread. Another card or tab still showing the page keeps its hold, and both stay open.
Tabs shrank in proportion to their whole width, so a tab with more of its own parts (the pane count, the hidden close button) lost its title first: next to a server terminal whose shell titles itself "user@host:~/folder", an agent + editor tab showed only "…" or nothing beside its "2", and a restored "Terminal · folder" read "Te…". Each tab now starts at the width of its own parts and grows to at most its whole title (measured in the interface font), so the room left goes to the titles evenly and a long title ends in … before a short one loses its letters. The pane count and close button no longer shrink, and on tabs other than the active one the close button floats over the tab's end on hover instead of keeping an invisible slot.
Setup on a Gentle Shell server only checks that the server answers, yet Node.js, Companion setup, Git and Engram wore a green "Ready" badge while their line said "not checked from here". A new Status::Unchecked shows a neutral "Not checked" chip and an empty circle, in faint color, and still holds nothing up (Continue, Install everything and the first-run sequence treat it as nothing to do).
…iffs keep CRLF The diff records its body size while painting and asks for a frame to widen its rows to it, but GPUI drops a request made mid-frame, so rows stayed as wide as their text until something else redrew (a hover). The viewer now redraws once after the diff appears or changes size. An untracked file's synthesized patch split lines with `str::lines`, dropping the CR of CRLF lines; it keeps them now, as git's patches do.
… screen choices gentle_core::machines: which workspace folder holds a path (owner), what a workspace saved before machines runs on (saved_machine, workspaces.json version 2), the machines Configuration and Open folder offer (choices, pick) and their names. Tested.
…achine, paired servers listed - The default (Agents run on) only decides where a new workspace goes; each workspace saves its own machine (server id, or its WSL/command backend) and its tabs, terminals, files and git follow it (backend::set_workspaces, for_tab by folder). Mixed windows work; changing the default moves nothing. workspaces.json v1 migrates to where the default ran then. - server::paired lists every pairing (name kept beside the token, migrated from settings.json); choosing this computer forgets none. Where agents run lists them (name, address, status, Unpair each) with Pair another server; Agents run on is the default for new workspaces. - ⌘O / Open folder… / Open folder on <server>… browse a chosen machine (explorer machine row); the folder opens as a workspace there. - Pairing on first run opens the server's home as its own workspace, named after that folder, instead of moving the shown one (fixes H). - Onboarding/Setup act on an explicit machine (backend::on). - Settings for at the top of Configuration (this computer, its environment, every paired server; the active workspace's first). Every page reads and writes that machine; its control session asks the active tab only when it runs there (fixes F: General showing another machine). Switching reopens Configuration for it on the same page. - Integrations › Gentle Tower on a server says whether it offers Tower and opens it (fixes E).
…hen they don't fit In a narrow window (747 pt, four tabs) every tab's own parts filled the title bar's room, so each title read only "…", and the active tab kept an empty slot for its hidden close button. - A tab is never narrower than its parts and its title's first eight letters (the whole title when shorter); the room left grows the tabs evenly up to their whole titles. Tabs that still don't fit scroll sideways (the wheel scrolls the strip), and the active one scrolls into view when it is picked, opened, shown with another workspace or the strip's room changes. - The close button floats over the end of every tab while the pointer is on it, the active tab's too: no tab keeps an empty slot for it. - The new-tab button stays next to the tabs, outside the scrolling strip. - The width bounds are one pure function (`tab_span`, `title_floor`), tested.
- The Pages (globe) menu listed a forwarded page as 127.0.0.1:<port>/?gs_ticket=…; it now shows the address the card header shows, without the single-use gs_ticket (same rule as the header, now one `BrowserPanel::address`).
…ts version - The local Gentle Shell card lists Runs on (This Mac, This PC, WSL · …) and Version (from the launcher's existing `--version` probe) next to Home, as a server's card does, so both machines read Runs on / Home / Version alike.
The file viewer's fix (redraw once after the diff measures itself, since GPUI drops the frame the diff asks for while painting) applies to every gpui_kit diff: the Agent UI review panel's rows stayed as wide as their text until a hover too, also after its hunks changed. - shared::diff_fit::DiffFit: the size the diff had in the last frame and the canvas after it that redraws the owner once when it changes; reset for a new diff in the same place. - The file viewer and the review panel use it (the review's viewer gets a new one each time it is rebuilt). - Test: a view drawing a diff with the fit draws once more than one without after the diff shows and after new files, and not while its size holds.
Gentle Shell unified its config stores: `mcp` replaces `mcp_servers` and
`pi_settings` replaces `model_defaults`; `claude_bridge` is a read-only
display store.
- pi-rpc: ConfigStore speaks the thirteen stores (Mcp, PiSettings,
ClaudeBridge); a `pi_settings` write is a PiSettingsPatch of the four
model keys (`null` removes, omitted keeps, any other key refused); an
`mcp` write stays `{ source, document }`; `project_untrusted` is a
config error code.
- Model defaults send only the keys a pick changed, so a value from the
project's settings.json is never copied into the global file.
- MCP servers list the `servers` Pi loads (disabled ones marked off, a
cut list marked); each layer's document comes from `documents`, and the
project file is offered only when the store lists a project layer.
Configuration on a server names the `pi_settings` and `mcp` stores and the patch write; Limits replaces "Trusted network only" (plain HTTP) with pinned HTTPS and the pairing proof on the network, `--no-tls` only for a network that encrypts by itself, and the relay from outside.
ismaelosuna7824
force-pushed
the
feat/remote-serve-backend
branch
from
November 26, 2026 06:57
b6fc4aa to
2565147
Compare
20 tasks
gentle-shell serve)
- Profiles and Usage headers name the machine shown (machines::screen_label, ui::screen_machine) and, with more than one, switch it with the same picker as Configuration's "Settings for" (ui::machine_picker, now shared with it). They open on the workspace's machine, or the "Settings for" one; switching reopens the screen for it (Usage keeps its tab, Profiles asks to save unsaved edits first).
- Use in this repo, Publish to repo, Clear session binding and Use in this session name what they act on ("<folder> on <machine>", machines::project_target) and are off, with the reason, on any machine but the open workspace's.
- machines::Shown holds the choice; tests cover the default, switching and which actions are on per machine.
- Profiles takes its route pickers' models from the session it asks on the machine shown (ControlSession: a tab there, else a server's /api/desktop list_available_models or hidden session), following its models_rev, never the active tab's from another machine. - Profiles and Usage ask a tab on the machine shown (remote::ask_tab: the active one when it runs there, else another tab there), so This Mac's lists come from a tab here while the active one is on a server. - "Used in this session" only for the open workspace's machine. - Tests: the source per machine (tab there, server without one, This Mac with or without a tab here).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #247
Summary
The app can now use a Gentle Shell server (
gentle-shell serveon another computer: a Linux box, a Mac mini, a Windows PC) as a machine where agents run, side by side with this computer. The server owns the agent sessions, the project folders, git and the terminals, and they keep running while the app is closed. The app is a native thin client: it pairs with one short code over pinned TLS, opens the server's folders in workspaces of their own, shows their files, diffs, branches and terminals, configures the server's Gentle Shell, and on relaunch reattaches every agent tab and terminal pane to the session and shell it had. The tools that need this computer (in-app browser, screen control, simulators and emulators, Maestro, themes, canvas, Agent UI) keep working for agents on the server: they run here as host tools the server's agent calls.Nothing changes for workspaces on this computer, WSL or a command backend, except where noted in Impact on existing users.
Size: 72 commits, 194 files, +41.9k / −1.5k lines. Every commit builds on its own (
cargo check --workspace --all-targets --locked, checked commit by commit).Contents
Architecture
flowchart LR subgraph Here["This computer: Gentle Shell GPUI"] direction TB WS["Workspaces<br/>(each keeps its machine)"] Views["Tabs, Files, editor, Changes,<br/>Branches, Git pane, terminals,<br/>Configuration"] Choke["Choke points:<br/>backend::fs · backend::git ·<br/>terminal/remote.rs · PiProcess"] Tools["Host tools: open_page, browser, screen,<br/>device, maestro, app_theme, canvas_*, gentle_ui"] Proxy["Local pinned proxy<br/>127.0.0.1:random"] Client["pi_rpc::serve (ServeClient)<br/>pinned TLS / relay"] WS --> Views --> Choke --> Client Tools <--> Client Views -. web cards .-> Proxy --> Client end subgraph Relay["optional: gentle-shell relay"] R["splices ciphertext"] end subgraph There["Server: gentle-shell serve"] Api["HTTP API + SSE<br/>gentle-shell.serve/v1"] Pi["gentle-shell --mode rpc<br/>sessions + Desktop RPC"] Term["gentle-term-host<br/>(persistent PTYs)"] Fwd["Forwards to the<br/>server's loopback"] Disk[("Folders, git, uploads,<br/>config, Engram, Tower")] Api --> Pi & Term & Fwd & Disk end Client -- "Bearer token, HTTPS pinned to the certificate" --> Api Client -. "same pinned TLS, end to end" .-> R -.-> ApiWhere a request goes. Every view that touches a project's files, git or a shell asks one of three choke points (
backend::fs,backend::git,terminal/remote.rs) which side to use, and agent tabs are aPiProcesslike any other (child process, WSL, command, or now a server session). The answer comes from the workspace the path belongs to (backend::for_tab,gentle_core::machines::owner), so a window can hold a workspace on this computer and one on a server at the same time.flowchart TD P["path / tab / pane"] --> O{"machines::owner:<br/>workspace whose folder<br/>holds the path"} O -->|"this computer / WSL / command"| L["Fs::Local · git child · local PTY ·<br/>PiProcess child (unchanged code)"] O -->|"server id"| S["Fs::Server · POST /api/git ·<br/>server terminal · PiProcess::serve"] S --> C{"server offers it?<br/>(capabilities + scopes)"} C -->|yes| API["ServeClient → serve"] C -->|no| U["“upgrade Gentle Shell there” /<br/>“Do this on the server: run …”"]What ships, by area
1. Pairing and reaching the server
sequenceDiagram participant U as User participant S as Server (gentle-shell serve) participant A as App U->>S: gentle-shell serve share S-->>U: XXXX-XXXX (5 min, single use) + long gsc1.… code U->>A: Code → Connect alt short code A->>S: UDP discover → broadcast, ports 8787–8796 S-->>A: {id, name, port, tls, fp} (hint only) A->>S: GET /.well-known/gentle-shell (serverId must match) A->>S: POST /api/pair/proof {nonce} S-->>A: proofs — one must equal HMAC(scrypt(code, salt‖fp), fp‖nonce) else long code gsc1.… Note over A: id, name, port, addresses, fp, relay A->>S: /.well-known at every address and through the relay, pinned to fp end A->>S: POST /api/pair {code, name} (pinned connection) S-->>A: device id + token Note over A: settings.json: address, device, name<br/>server-tokens.json (0600): token, fp, relay, serverId, addresses, homeXXXX-XXXX, Crockford base32; case, spaces, dashes, O/0, I/L/1 forgiven) finds the server by UDP broadcast on the LAN, verifies every answer at/.well-known/gentle-shell, and pairs with the one found or lists several to pick from. Interface broadcast addresses come fromsysinfo'snetworkfeature.gsc1.…(base64url JSON: server id, name, port, addresses, pairing code, certificate fingerprint, relay) connects by itself when pasted: every address is tried at once (1.5 s each, 4 s overall).serve paircode; a typedhttp://address moves tohttps://once the server says it speaks TLS.--no-tls).fp ‖ noncekeyed by scrypt(code,"gentle-shell/pair-proof/v1"‖ fp; N=2^15, r=8, p=1). A machine that merely answers discovery never sees the code. Known-answer vector shared with the server's tests.gsr://host:portrelay (in the long code, or remembered when the paired addresses stop answering) reaches a server outside the LAN: one hello line naming the server by fingerprint, then the same pinned TLS end to end; the relay only sees ciphertext.<host>,<host>.local), checks/.well-knownnames the sameserverIdand pinned certificate, saves where it answers now and retries there; every clone of the client follows.POST /api/devices/self/replace) so its terminals belong to the new pairing; open agents and terminals follow.DELETE /api/devices/self), then forgets the token. Tabs let go of their sessions (left running there for a later pairing). Unreachable or older server: forgotten here, and Configuration says the server still lists the device and how to remove it.2. Sessions over serve
PiProcess::serve: commandsPOST /api/sessions/:id/rpcin order (one unanswered after 2 s lets the next go, soabortnever waits behindbash), answers read as stdout,202 pendingsettled from the stream; events on SSE resumed byseq, 45 s silence limit, backoff reconnect;snapshot-required→ the tab reads its state again.GET /api/sessions/:id, thenget_messagesrebuilds the conversation without replay), or starts a new session resuming the Pi conversation by exact id. A canvas's floating agent reattaches the same way.epoch; a new epoch is a restart, not a replay, so events after an install are no longer dropped as duplicates. Within one epoch (and with servers without one) duplicates and stale snapshots are still refused.serve_dialog_resolvedand409 dialog_answeredclose the dialog everywhere else with a quiet note.sequenceDiagram participant A as App participant S as gentle-shell serve participant T as gentle-term-host Note over A: ⌘Q: detach (nothing stopped) Note over S,T: agent session and shell keep running A->>S: GET /api/sessions/:id alt still running A->>S: events?after=seq · get_state · get_messages else gone (stopped, server restarted) A->>S: POST /api/sessions {cwd, sessionId} (resumes the conversation) end A->>S: GET /api/terminals/:t/stream S->>T: attach T-->>A: snapshot (screen as it is), then output from the offset3. Several machines side by side
workspaces.jsonversion 2, migrated from version 1 to where the default ran then). Its tabs, terminals, files and git follow it. Agents run on is only the default for new workspaces; changing it moves nothing./pathin ⌘K is offered on each server. The folder opens as a workspace on that machine; Open Gentle Shell here opens an agent tab there.folder_key); a workspace matches by machine and root. Pairing on first run opens the server's home as its own workspace named after that folder.4. Host tools
The tools that need this computer are offered to the agent as host tools (
set_host_tools); the server routes each call only to the device that registered it.open_pagebrowser,screengentle-screenin-processcanvas_read/edit/shotdevice,app_themeagent-device; the app's themes foldermaestrogentle_uigentle_core::genui::host): specs, patches, summaries, reviews that wait, events, host contextset_host_tools/host_message/set_host_context), and offered again after a reconnect, a session switch or an Agent UI mode change. Pi-rpc carries the contract's limits (names, schemas, 8 MiB result content, per-method request caps). dc5ce85servegets the same host tools over stdio instead of the app's--append-system-prompt/--extensionarguments. Detected with<launcher> serve --helponly (5 s, cached per launcher build), because an older launcher would forward any otherserve …to the model. Older launchers keep the instructions and extensions. 1593b31host_tool_progress, each tab sends a beat every 60 s for each call still running (agentle_uireview waiting for decisions, a browser wait, a Maestro flow); stops on answer, cancel,unknown_call/already_answered, or backend exit. Older servers keep the 9-minute review fallback. 13f0cef5. Forwarded pages, local pinned proxy, Tower
open_page,/web, a URL in tool output) open through the server's authenticated forward, never as this computer'slocalhost. 46a6425, 302a955127.0.0.1:<random>that carries every connection over the pinned TLS (or the relay). HTTP/1.1 keep-alive, SSE and WebSocket pass through; a foreignHostgets421(DNS rebinding); a changed certificate gets a502with the message. ebf36f8open_page,gentle-open) shows its card immediately instead of hiding it in the tray (a hidden card has no web view, so nothing reached the forward); the tool result says "in the Gentle Shell app's browser", "in their own web browser", or the server's reason. c8014b0gs_ticketis never shown: not in the card header, not in the Pages menu. e5bab57, 9785d9bPOST /api/tower) and opens through the same proxy; Integrations › Gentle Tower says whether the server offers it. 46a6425, 302a955, f600c9c6. Files, git and terminals
backend::fschoke point: tree (with/api/fs/watchlive updates, ignored files dimmed via server git), editor with etag-guarded saves (Changed on the server), new/rename/delete/copy, ⌘K Files, search, Markdown images, folder browser.backend::gitsendsPOST /api/git {cwd, args, env}: Changes, Branches, Git pane and actions, palette branches, Review. Commit messages are written on the server (POST /api/print).gentle-term-hostcrateTermper PTY for snapshots, 2 MiB replay ring, 8 MiB per-connection backpressure, idle exit. Unix socket on Unix; loopback TCP with a random token (owner-only token file:0600/ protected DACL) everywhere, the only transport on Windows (ConPTY).gentle-term-hostwhen the server's platform/arch match this build (beside the executable, in the macOS bundle, or a dev build's target folder), a file the user picks, or the build command. The pane shows the SHA-256; the upload carries it and the server checks it. Nothing is downloaded.7. Uploads, downloads, export
POST /api/uploads) and the server path goes into the prompt; images stay inline. 903eda0PUT /api/fs/write, folders recursively, links skipped, the server's 64 MiB per-file limit respected); existing names ask once: Replace (folders merge), Keep Both, Skip. Download… saves a server file or folder here, with progress and Cancel./exportin a server tab writes the HTML there and downloads it. 78a95d08. Configuration on a server
All through Desktop RPC, each method only when the server advertises it; anything without a remote method says Do this on <server>: run ….
/api/desktopdesktopcapability these screens use the session-lessPOST /api/desktop+GET /api/desktop/eventsinstead of a hidden control session; models come from the newlist_available_modelsmethod. Older servers keep the hidden session.models.jsonandmcp.json(global, and a trusted project's) edited as JSON over the Desktop RPC config stores for MCP servers, model defaults and custom models; the MCP card lists the servers Pi actually loads; secrets stay•••; Pi's validation errors show.loginKinds: OAuth/device login runs on the server; its page opens in a browser card that catches the loopback redirect (redirectPrefix) and hands it to the server instead of loading it; device codes with Copy; API key (masked, cleared at once); Remove.9. First run and Setup on a server
10. UI fixes from the live tests
gs_ticketNot checkedstatusDesign decisions and alternatives
gentle-shell serve(server owns sessions, folders, git, PTYs)sshjoins its arguments into one remote command line; (c) loses the native tools (screen, simulators, canvas).PiProcessmachines::owner)gentle_uigentle_core::genui::host)/.well-knownsysinfo'snetworkfeature lists interfaces); the long code covers networks where broadcast doesn't reach.127.0.0.1gentle-term-hostbinary with snapshot + offset resumeserverestarts and upgrades; alacritty's headlessTermgives a correct screen snapshot to reattach.epoch/api/desktopDiffFitredraw in the appgpui-componentdiffImpact on existing users
serve(probe:<launcher> serve --help, 5 s, cached per build), local tabs start without the app's--append-system-prompt/--extensionarguments and get the same tools as host tools. Older launchers are unaffected. Maestro is then a host tool, not an MCP server (a previously registeredmaestroMCP still shows so Disconnect can remove it).open_page/gentle-opennow show their card at once (or open the user's browser per Devices › Browser) instead of hiding it in the tray; URLs merely mentioned in tool output still wait in the tray.workspaces.jsonv1 → v2 (each workspace gets the machine the default ran on then); a pairing's name moves fromsettings.jsonbeside the token; URL-keyed server references become server ids once known.gentle-term-hostnext to the app binary (never run by the app; only offered for upload to a server of the same platform).--no-fail-fast); releases gain fivegentle-term-host-*assets.Code Owner review: Cargo, CI, release, packaging
Cargo (
Cargo.lock: +41 lines; onlyscryptandsalsa20are new downloads):Cargo.tomlcrates/term-hostcrates/corescrypt 0.11(default-features = false)scrypt 0.11.0,salsa20 0.10.2crates/corehmac 0.12,sha2 0.10,base64 0.23hmac/sha2 0.10viapbkdf2)crates/pi-rpcrustls 0.23(ring,std,tls12; no default features)ureq)crates/pi-rpcureq 3(default-features = false),sha2 0.11,base64 0.23,gentle-core(path)crates/appsysinfo 0.31: featurenetworkadded tosystemcrates/term-host(gentle-term-host, binary only, not linked into the app)alacritty_terminal 0.26,base64 0.23,serde_json,polling 3;libc 0.2(unix);windows-sys 0.59(windows; Foundation, Security, Authorization, Cryptography, FileSystem, Threading)CI (
.github/workflows/ci.yml):cargo test --workspace --locked→cargo test --workspace --locked --no-fail-fast, so the term-host's tests (TCP + ConPTY on Windows, Unix socket on Linux/macOS) report on all three systems even when another binary fails. Actions, pins and the read-only token unchanged.Release (
.github/workflows/release.yml): a newterm-hostjob (matrix: linux-x64 and linux-arm64 static musl, macos-arm64, macos-x64 cross-compiled, windows-x64 static CRT viapackaging/windows/cargo-config.toml), each checked for--version == gentle-term-host $VERSION(when not cross-compiled) and static linking on Linux, uploaded as artifacts;releasenowneeds: [version, build, term-host]and requires the fivegentle-term-host-<os>-<arch>[.exe]assets (listed inSHA256SUMS). Actions pinned by SHA,persist-credentials: false, no Rust cache for these builds.Packaging (
packaging/macos/bundle.sh): builds-p gentle-term-hostwith the app and copies it toContents/MacOS/gentle-term-hostwhen present (GENTLE_TERM_HOST_BINoverrides whenGENTLE_BINis given; left out when neither exists). Nothing else underpackaging/changes.Security review checklist
server-tokens.json(0600, written beside and renamed in), never insettings.json, logs orDebugoutput.set_api_keyandlogin_completepayloads are left out ofDebug; the API key field is masked and cleared at once./.well-known(sameserverId; pinned certificate on rediscovery).127.0.0.1on a random port; requests whoseHostisn't127.0.0.1:<port>/localhost:<port>get421(DNS rebinding); foreignOriginpassed through so the server refuses it; closes with its last holder, when the forward is gone, or after 12 h idle.provideris this device's id; eachcallIdonce; results capped (8 MiB), requests capped (1 MiB / 9 MiB).redirectPrefix(scheme/host case-insensitive) are caught and handed to the server;open_urlprompts must be http(s).adminscope and the server capability; terminals need theterminalscope.0700) directory, bound under umask077; TCP on loopback only, random token in an owner-only file (0600/ protected DACL), first line must authenticate or the connection closes.ENGRAM_URLfor a server workspace.Tests
cargo fmt --all -- --check✔ ·cargo clippy --workspace --all-targets --locked -- -D warnings✔ ·cargo test --workspace --locked: 1,598 passed, 0 failed, 8 ignoredgentle-coreunitgentle-shell-gpuiunit (incl. GPUI headless view tests)gentle-term-hostunitgentle-term-hosttests/protocol.rs(real PTYs, Unix socket)gentle-term-hosttests/tcp.rs(loopback TCP + token)pi-rpcunitpi-rpctests/desktop_rpc.rspi-rpctests/desktop_rpc_accounts.rs(sign-in, packages)pi-rpctests/desktop_rpc_live.rspi-rpctests/desktop_stdio.rs(host tools over stdio)pi-rpctests/serve.rs(+serve/relay.rs,serve/local_pages.rs)pi-rpctests/serve_api.rspi-rpctests/serve_live.rs(needs a real server)Ignored tests need a running server:
serve_live.rs(GENTLE_SHELL_CHECKOUT=… cargo test -p pi-rpc --test serve_live -- --ignored: realserve --relayandrelayin a temp home; pairing over pinned TLS with the proof; a wrong fingerprint refused; sessions and a forwardedpython3 -m http.serverpage through the local proxy, directly and through the relay) andlive_registration_on_a_server(registers every host tool on a realserve).Stand-ins:
tests/serve.rsruns the session transport against a fake server behind a TLS front made with the server's own certificate code;tests/serve/relay.rsadds a fake relay;tests/serve/local_pages.rschecks the proxy (keep-alive, ticket → cookie, redirects, HEAD, chunked, SSE, WebSocket, Host/Origin, changed certificate, relay, closed forward, cleanup);tests/serve_api.rsfiles, git, uploads, forwards, terminals;tests/desktop_stdio.rslocal host tools over stdio; term-hosttests/protocol.rs(real PTYs over the Unix socket) andtests/tcp.rs(TCP + token, ConPTY on Windows).Live evidence
All runs used temporary app homes and data dirs; the maintainer's own data and apps were not touched. Screenshots and API dumps were kept for every step.
macOS ↔ macOS, end to end (server from #3529 in a temp home)
68QK-WPHDpaired;https://…:8791with the certificate fingerprint pinned; Configuration shows the https addresstopservewith tabs opentopkept updatingtoppid)/web http://127.0.0.1:18920/)gsc1.code with decoy addresses paired through the relay (gsr://…), session opened; relay log shows spliced connections409is covered by the server's tests; no real upgrade rundesktop_stdio.rs, probe and args-stripping tests); not run livehost_tool_progressadvertised and usedEarlier macOS runs: pairing by short and long code (invalid code, no computer found, damaged code, unreachable server messages), quit/relaunch with the same session (
seq138) and terminal (offset159,941 → 193,120 while the app was closed), Disconnected + Start again after stopping the server.Issues found there and fixed in this PR: Desktop RPC events dropped after a server reload (cd0bef2), re-pairing at a new address orphaning work and unpair only forgetting locally (69cfbbc), Open Gentle Shell here opening no agent (e382e6d), upgrade permission cached per screen (1c02f4b).
macOS app ↔ the maintainer's Omarchy server (Arch Linux x86_64, real LAN)
https://192.168.100.92:8787, identity fingerprint equals the pinned one; non-admin device gets403on/api/devicesas expectedM hello.txt +2 −1with its diff; branchmasteruname -a→Linux ismael 7.2.15-1-omarchy … x86_64;topliveopen_page→ server forward + local proxy, page loaded;gentle_uichecklist round trip without another prompttopkept updating/home/ismaelo, 5.0.0), model defaults, sign-ins,models.json/mcp.jsoneditors, packages; Setup/Upgrade hidden for a non-admin deviceIssues found on Omarchy, and their fixes in this PR:
open_pagedidn't show the page until the eye was clicked\ LFrow is the diff library's marker for a line-ending-only change)Re-verification on Omarchy (build at c011ded): Settings for, Where agents run, ⌘O on both machines (Mac and server folders in one window: Files, terminal, Changes), Not checked, diff full width ~0.3 s after opening,
open_pageshown at once ("Opened … in the Gentle Shell app's browser"; oneGET / 200on the server), closing the card emptied/api/forwardswithin 2 s and stopped the local proxy — pass. Horizontal tabs still read "…" in a 747 pt window and the Pages menu still showed the ticket: fixed afterwards in 2023a85 and 9785d9b and checked on screen in an isolated copy (titles readable, active tab scrolled into view, wheel scrolls the strip).Limits and follow-ups
gentle-term-hostyet (onlybundle.shdoes); a Linux/Windows server takes a chosen file or the build command.gentle_uiwaiting reviews on servers withouthost_tool_progressgive up after 9 minutes.exitor ⌘W does.Questions for reviewers
--extension/--append-system-promptarguments with host tools for launchers that supportservethe right default, or should it sit behind a setting for one release?gentle-term-hostin the macOS bundle: acceptable size/signing cost, or should it only be offered as a chosen file?gentle-term-host-*(the app never downloads them; they serve servers installed by hand), or drop the job?sysinfonetworkfeature for interface broadcast addresses vs. a small dedicated crate (the feature adds no new crate).How to try
gentle-shell serve share(firewall:sudo ufw allow 8787and8800:8899/tcpfor forwarded pages). Add--relay gsr://host:portto reach it throughgentle-shell relay.cargo build --release -p gentle-term-hostfrom this branch on the server and pick it under Install terminal support, or put it in<agent home>/serve/bin. A Mac server of the same architecture can take the app's own build.cargo run -p gentle-shell-gpui(use a freshGENTLE_SHELL_GPUI_DATA_DIRto keep your data apart).open_page//webon a dev server, uploads by drag and drop.serve: they reconnect.