fix(web): show server update progress through reconnect (#4903)

This commit is contained in:
Theo Browne authored and GitHub committed 2026-07-30 04:45:04 -07:00
1 parent 5c9358acaa
commit 197d348711
21 files changed
+1080 -372

No files matched your search

+32 -22
View File
@@ -13,8 +13,9 @@ The feature has three boundaries:
## Detection and Presentation
`ExecutionEnvironmentDescriptor` includes the server version and an optional
`capabilities.serverSelfUpdate` value. The client compares that version with `APP_VERSION` after
loading server config.
`capabilities.serverSelfUpdate` value. Progress-capable servers also advertise
`capabilities.serverSelfUpdateProgress`. The client compares the server version with `APP_VERSION`
after loading server config.
The optional capability is intentionally backward compatible. An older server does not know about
the field, so a missing value means the client must offer a manual relaunch instead of sending an
@@ -28,6 +29,10 @@ The shared `ServerUpdateAction` is rendered in both user-facing version-drift su
Both surfaces target the client's exact version. When the reconnected server reports that version,
the mismatch and action disappear.
The operation state lives in `packages/client-runtime`, keyed by environment. Both web surfaces read
the same `downloading`, `installing`, or `resuming` state, so route changes do not own or cancel the
operation.
## Capability Selection
The server resolves its capability once at startup and publishes it in the environment descriptor.
@@ -51,20 +56,25 @@ flowchart TD
A[Client detects different versions] --> B{Advertised update path}
B -->|desktop-managed| C[Update desktop app on server machine]
B -->|missing| D[Copy exact manual relaunch command]
B -->|boot-service or respawn| E[server.updateServer]
E --> F[Install exact t3 version in pinned runtime]
F --> G[Run version preflight]
G -->|fails| H[Remove failed runtime and keep current server]
G -->|passes| I{Handoff method}
I -->|boot-service| J[Rewrite and restart T3 systemd unit]
I -->|respawn| K[Start delayed replacement and exit current process]
J --> L[Client reconnects]
K --> L
B -->|boot-service or respawn| E{Progress capability}
E -->|present| F[server.updateServerWithProgress]
E -->|missing| G[server.updateServer fallback]
F --> H[Download exact t3 version]
G --> H
H --> I[Install and run version preflight]
I -->|fails| J[Remove failed runtime and keep current server]
I -->|passes| K{Handoff method}
K -->|boot-service| L[Rewrite and restart T3 systemd unit]
K -->|respawn| M[Start delayed replacement and exit current process]
L --> N[Reconnect with fresh backoff]
M --> N
N --> O[Replacement publishes ready at target version]
```
`server.updateServer` requires the environment's `orchestration:operate` authorization scope. Its
Both update RPCs require the environment's `orchestration:operate` authorization scope. Their
payload accepts only an exact npm version, including an exact prerelease version; dist-tags such as
`latest` and `nightly` are rejected.
`latest` and `nightly` are rejected. The unary `server.updateServer` method remains available so a
new client can still repair skew with an older server.
The update service permits one update at a time. It installs `t3@<version>` under
`<baseDir>/runtime/versions/<version>` and writes an install-complete sentinel only after npm exits
@@ -89,20 +99,20 @@ authorization; it does not uninstall the host service.
## Process Handoff
For `boot-service`, the server atomically rewrites the T3-managed user unit to point at the verified
runtime, reloads systemd, and restarts the unit. Reload and restart failures restore the previous
unit before returning an error.
runtime and reloads systemd. It acknowledges the handoff, then restarts the unit after the same
short grace period used by foreground respawn. A rejected deferred restart restores the previous
unit and is logged by the still-running process.
For `respawn`, the server starts a detached, delayed replacement that replays the original CLI
arguments. It then acknowledges the request and schedules the current process to exit. The delays
give the acknowledgement time to cross direct or relayed connections before the socket closes.
There is no separate progress stream. The update request remains pending while npm installs and the
client shows a disabled update action. A restart can interrupt the request normally; the connection
runtime keeps the environment registered and reconnects through its usual retry path. After an
acknowledged foreground handoff, the UI keeps the action pending until version sync removes it or a
safety timeout releases it. If a boot-service restart closes the connection before acknowledgement,
the UI releases the interrupted action without reporting a false update failure and lets reconnect
and the next version check determine the result.
Progress-capable servers emit `downloading` before installing the pinned runtime and `installing`
before preflight and handoff. A terminal stream event acknowledges that restart is scheduled. The
client then enters `resuming`, waits for the replacement lifecycle stream to publish `ready` with
the target version, and only then completes the operation. It watches for the intentional
disconnect's first backoff state and requests one fresh retry, which clears historical backoff debt
without adding a separate reconnect loop.
## Release Invariant
+9 -4
View File
@@ -31,6 +31,11 @@ The update does not remove saved threads, settings, or project files.
The available action depends on how that server was started. T3 Code does not update connected
servers silently in the background.
After selecting **Update server**, the warning becomes a three-step progress rail:
**Download**, **Install**, and **Resume**. The same progress appears in the conversation and in
Connections, so navigating between them does not lose the update. A failed step remains visible
with its error and an option to retry.
If the server uses the T3 Code background service, you can also update it directly on the host:
```sh
@@ -42,11 +47,11 @@ commands.
## After the Update
Keep the web or desktop app open while the server restarts. When it reconnects with the matching
version, the warning and update action disappear.
Keep the web or desktop app open while the server restarts. The update completes only after the
replacement server reports the requested version and is ready to accept commands. The warning and
progress rail then disappear.
If the client reports a timeout, the server may still be finishing the update. Wait a minute, then
reconnect or open **Settings** → **Connections** again. If the warning remains:
If a step fails:
1. Retry the offered action once.
2. Make sure you updated the machine named in the warning, not only the device you are using.