Persistent daemon + thin networked client #9
Reference in New Issue
Block a user
Delete Branch "feat/daemon-client-split"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Persistent daemon + thin networked client
Turns patterm from a single foreground process into a persistent background daemon that owns all process/project state, plus a thin client that renders and forwards input. A client on another LAN device can attach, navigate projects via the command palette, detach, and reconnect — with child processes surviving client disconnects.
Design source of truth:
docs/daemon-client-plan.md(Phases 0–4 implemented).What's included
internal/protocol(frame taxonomy,Transportinterface, JSON-linesConnTransport, loopback transport that crosses the sameSend/Recvboundary); semanticchromeModel,ClientView, and a bounded backpressure-safeclientSubscriberkept separate from daemon-internal listeners;internal/ptynow setscmd.Dirand tears down the whole process group.ProjectRegistry(implements the fullmcp.ToolHost, daemon-wide identity routing); palette Switch/Open project…; two clients can view different projects at once; scratchpad MCP ops route to the caller's project.patterm daemonover a unix socket with pidfile/lock + stale cleanup; defaultpatterm [dir]auto-starts the daemon and attaches as the thin client;patterm daemon stop/patterm ls; processes survive client disconnect; reattach repaints from a fresh snapshot. Detach is Ctrl-] (Ctrl-D stays shell EOF).--in-process/PATTERM_NO_DAEMON=1escape hatch.patterm daemon --listen HOST:PORTwith a lightweight bearer token (stored0600under$XDG_DATA_HOME/patterm/clients/token, printed for pairing);patterm connect --host HOST:PORT [--token TOKEN]. Unix-socket attaches stay token-exempt. Transport kept pluggable for future TLS.Decisions baked in
ClientView). 4. Auto-start on demand. 5. "Persistent" = survive client disconnect while the daemon lives (no resurrection of live PTYs across daemon death). 6. Trusted-network auth: localhost default, opt-in LAN, simple token, no TLS yet (pluggable). 7. Detach via explicit gesture, not Ctrl-D.Known limitations / deferred
Testing
go build ./..., fullgo test ./...(incl. the real-socket harness), andgo test -race -run 'Daemon|NetClient|Owner' -count=5 ./internal/app/all green, verified in an environment with unix sockets/PTYs enabled.ConnTransportconcurrent-send race, plus a pre-existingPTYRead/Close race now hit routinely by daemon shutdown.Orchestrated build: parallel investigation (sub-claude + sub-codex), synthesized plan, codex peer-review, then phased implementation by codex with the orchestrator verifying every checkpoint against real sockets.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.