Files
t3code/packages/client-runtime
Theo BrowneandClaude Opus 5 b462ae5f2f fix: clean up the remote server update reconnect flow
Clicking "Update server" on a relay-connected server showed a spinner,
then a disconnected banner with a raw transport error, then hung until
the page was refreshed. Three separate causes:

1. The boot-service (systemd) update path ran `systemctl --user restart`
   synchronously inside the RPC handler, so the process died before the
   acknowledgement flushed. Every successful update reached the client as
   an interrupt, which ServerUpdateAction released quietly — no success
   toast, and nothing told the connection layer a restart was coming.
   The restart is now deferred like the respawn path. Rollback and the
   in-flight reset move onto the detached fiber and log instead of
   failing the (already-acknowledged) RPC.

2. Reconnect backoff escalates to 16s, so the client was frequently
   asleep exactly when the server came back; refreshing reset the
   failure count, which is why refreshing "fixed" it. A restart-expected
   overlay is now armed before dispatch and retries on a flat 2s cadence
   while it is active, and only while the supervisor is sleeping in
   backoff so a live attempt is never interrupted. It expires on its own
   after 90s and is withdrawn on an explicit RPC failure, which proves
   the server stayed up.

3. Two consecutive websocket-ticket failures evicted the cached DPoP
   token, forcing a full relay bootstrap and token exchange during
   reconnect. Eviction is now limited to failures suggesting a stale
   endpoint; plain unreachability (network/timeout) — the shape of a
   restart — keeps the token.

Also stops piping raw transport messages (which embed internal endpoint
URLs) into the composer banner: presentation maps each failure reason to
a stable summary and carries the reason for callers, while the raw
message remains on the supervisor state for diagnostics.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-07-24 16:35:49 -07:00
..

Client Runtime

Shared client behavior for web and mobile. Public APIs are organized by package subpath. The package intentionally has no root export.

Public subpaths

Subpath Responsibility
authorization Bearer and DPoP authorization plus token persistence contracts
connection Targets, catalog, supervision, retries, registry, and onboarding
environment Environment identity, descriptors, endpoints, and scoped keys
errors Shared client error inspection
operations Multi-step application workflows
operations/projects Multi-step project creation workflows
platform Platform capability and persistence service contracts
relay Managed relay API and environment discovery
rpc HTTP/RPC clients, protocol, sessions, and subscriptions
state/<domain> Focused shared state, retention, reducers, and Atom constructors

Dependency direction

Platform applications provide platform services. connection composes those capabilities with authorization, relay, and rpc to supervise environment sessions. Independent state modules consume the connection registry and expose focused state or Atom constructors to application-owned runtimes.

Applications should import the narrowest relevant subpath. There is no broad state export: use domain paths such as state/shell, state/threads, state/terminal, or state/vcs. Subpath indices and explicitly exported domain files are public API boundaries; all other files remain implementation details.