-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(desktop): respawn host-service on every Electron auto-update #4218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dc00534
docs(desktop): plan to pin host-service adoption to bundled version
Kitenite f83da66
docs(desktop): commit to strict-equality version pin in host-service …
Kitenite 416d2b8
feat(desktop): pin host-service adoption to bundled version
Kitenite 6e2fea8
docs(desktop): align done/ plan step 1 with what shipped
Kitenite beaa55b
refactor(desktop): derive host-service version from package.json
Kitenite 791316c
chore(host-service): bump to 0.8.1 to force respawn on next release
Kitenite bb094c6
feat(desktop): respawn host-service on every Electron auto-update
Kitenite 7039c52
refactor(desktop): drop redundant host-service version pin
Kitenite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
apps/desktop/plans/20260507-host-service-bundled-version-pin.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Pin host-service adoption to bundled version | ||
|
|
||
| ## Problem | ||
|
|
||
| Today `host-service-coordinator.tryAdopt()` adopts any running host-service whose version satisfies `>= MIN_HOST_SERVICE_VERSION` — a manually-bumped floor in `packages/shared/src/host-version.ts`. After an Electron auto-update, the new desktop happily adopts a stale host-service as long as it clears the floor, so non-breaking host-service changes (patches, additive features) never reach users until someone remembers to bump the floor. | ||
|
|
||
| We want auto-updated desktops to always end up running the host-service binary that shipped with them. | ||
|
|
||
| ## Why respawn is safe | ||
|
|
||
| Pty-daemon — the only process holding durable session state — has its own manifest + supervisor (`packages/host-service/src/daemon/DaemonSupervisor.ts`) and is adopted independently. Killing host-service drops only: | ||
|
|
||
| - tunnel-client WebSockets (auto-reconnect) | ||
| - the in-memory terminal sessions Map (rebuilt on re-attach via daemon-client) | ||
| - cached env | ||
|
|
||
| Real PTY state stays in the daemon across the swap. | ||
|
|
||
| ## Change | ||
|
|
||
| Replace the floor check with an equality check against the host-service bundled into this Electron build. Reuse the existing kill+respawn path. | ||
|
|
||
| 1. Inject `BUNDLED_HOST_SERVICE_VERSION` into the desktop main bundle at build time (read `packages/host-service/package.json` version), mirroring the `EXPECTED_DAEMON_VERSION` pattern at `packages/host-service/src/daemon/expected-version.ts`. | ||
| 2. In `apps/desktop/src/main/lib/host-service-coordinator.ts:289-308`, replace | ||
| ```ts | ||
| !semver.satisfies(version, `>=${MIN_HOST_SERVICE_VERSION}`) | ||
| ``` | ||
| with | ||
| ```ts | ||
| version !== BUNDLED_HOST_SERVICE_VERSION | ||
| ``` | ||
| (or `!semver.gte(version, BUNDLED_HOST_SERVICE_VERSION)` if we want a newer dev daemon to win — see open question). | ||
| 3. Keep `MIN_HOST_SERVICE_VERSION` only for the renderer-side **remote** host gate at `apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/hooks/useRemoteHostStatus/useRemoteHostStatus.ts:91`. We can't kill remote hosts — a floor is still the right shape there. | ||
|
|
||
| Everything else is unchanged: `detached: true` spawn, manifest re-adoption on next start, crash circuit breaker, daemon lifecycle. | ||
|
|
||
| ## Behavior after change | ||
|
|
||
| - **Auto-update ships new host-service version** → next Electron launch: adoption check fails, manifest PID gets SIGTERM, fresh host-service spawns from the bundled binary. One brief tunnel reconnect. | ||
| - **Auto-update ships same host-service version** → adoption succeeds, no respawn. | ||
| - **Pty-daemon** → never killed by this path; survives across host-service swaps as designed. | ||
|
|
||
| ## Open questions | ||
|
|
||
| - **Strict equality vs `>=bundled`?** Strict equality means a dev build pointing at a locally newer host-service would get killed on Electron start. `>=bundled` avoids that but lets a hand-rolled newer daemon stick around indefinitely. Default to strict equality unless dev-flow friction shows up. | ||
| - **Drain before SIGTERM?** Today line 304 is a hard kill. If respawn cadence becomes user-visible (tunnel reconnect storms), add a short drain — stop accepting new connections, wait N seconds — before SIGTERM. Not needed in v1. | ||
|
|
||
| ## Out of scope | ||
|
|
||
| - Pty-daemon version pinning (already handled by `DaemonSupervisor` + `EXPECTED_DAEMON_VERSION`). | ||
| - Changing `MIN_HOST_SERVICE_VERSION` semantics for the remote-host renderer gate. | ||
| - Any auto-update lifecycle changes — host-service and pty-daemon still must not be torn down by the auto-updater itself; the respawn happens on the *next* launch via the existing adoption path. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify “newer daemon” wording to avoid pty-daemon confusion.
At Line 45, “hand-rolled newer daemon” reads as pty-daemon, but this section is about host-service adoption. Please rename to “newer host-service” to prevent implementation ambiguity.
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Section was removed when we committed to strict equality (the open-questions only retains the drain-before-SIGTERM bullet now). No-op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kitenite, understood — since the team committed to strict equality and the "Strict equality vs>=bundled?" bullet was dropped entirely, my concern is already moot. Thanks for the clarification!