Repository navigation
Offer updates in a window, and install without cutting anyone off - #28
Merged
Merged
Conversation
Checking for updates is now on by default. When there is a newer version, a small window says so instead of a notification that disappears; what it offers depends on how the app was installed. Downloaded from the web: one press installs. The app downloads, verifies the signature, waits for the gateway's in-flight requests to finish, replaces itself, and restarts, then says which version it came from. Waiting is the point: a restart cuts every stream still producing output, so a Claude Code task mid-response would lose that output and have to send the request again. The count comes from core 0.1.1's `in_flight`, is polled until it reaches zero, and is capped at three minutes so an update still happens under continuous load. The download comes first and the bundle is replaced last, so the files on disk never belong to a different version than the one running while it waits. Installed with Homebrew: the window gives the command and copies it, and the app never replaces itself. It asks the tap rather than the release page whether there is something newer, because the release page knows first — prompting then would give a `brew upgrade` with nothing to install. The command starts with `brew update`, since `brew upgrade` refreshes taps at most once a day on its own. The copy happens in Rust: the web clipboard API is refused in some webviews, and refused means a copy button that silently does nothing. A dismissed version is offered again after a day, not at the next six-hour check. A newer version is offered immediately. Development builds do not check on their own. Closing the update window no longer turns the app back into a menu-bar accessory while the main window is still open. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Running the update end to end on a real bundle showed the restart race:
the app exited, the new app started and spawned a core, and the old core
was still holding the lock — it only notices its parent is gone about a
second later. The new core failed twice ("已经有一个 twcore 在跑") before a
third attempt stuck. The gateway was down a second longer than it needed
to be, and every update left two error blocks in the log.
`Supervisor::stop_and_wait` sends SIGTERM and waits for the child to
actually exit, with a SIGKILL fallback, before the app restarts.
That needed a way to say "stopped on purpose, do not start another".
`run_once` returned a bool, and `false` meant "go to safe mode" to the
supervise loop — a deliberate stop would have started a safe-mode core
to fight over the lock and brought the main window up over a restarting
app. It now returns `Next::{Again, SafeMode, Stop}`, and the stop check
comes before any crash accounting.
Same scenario after the fix: SIGTERM, core exits 0 within 8 ms, the new
app's first core binds the port under a second later, nothing fails.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks for the PR. One thing before review: this targets
No need to close and reopen: click Edit next to the PR title and change the base branch to See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract. |
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.
What this changes
Status.in_flight; the bundled core follows automatically.Why
Waiting for in-flight requests is the point of the one-press install. A restart cuts every stream still producing output: a Claude Code task mid-response loses that output and has to send the request again. The app polls core's new
in_flightcount and restarts in the gap between requests. The wait is capped at three minutes, so an update still happens under continuous load. The update is downloaded first and installed last, so while it waits, the files on disk never belong to a different version than the one running.Homebrew installs ask the tap, not the release page.
latest.jsonknows about a release the moment it is published, while the cask only follows once the tap's bump job runs (now hourly). Prompting as soon as the release page changes would hand users abrew upgradewith nothing to install. The command starts withbrew updatebecausebrew upgraderefreshes taps on its own at most once a day (HOMEBREW_AUTO_UPDATE_SECS, default 86400 — read from Homebrew's source).The copy happens in Rust (
tauri-plugin-clipboard-manager, behind a command that can only copy that one string). The web clipboard API depends on the webview granting permission, and when it is refused the button silently does nothing. Tested in the preview:writeTextwas refused, and nothing happened. If the native write ever fails, the window selects the command and says to press ⌘C.Prompt pacing. A new version is offered immediately. A version dismissed with 稍后 is offered again after a day, not at the next six-hour check. Development builds don't check on their own.
Two bugs fixed along the way:
Supervisor::stop_and_waitstops the core and waits for it to exit first.run_oncenow returnsNext::{Again, SafeMode, Stop}— with a bool, a deliberate stop would have been read as "go to safe mode".How it was checked
End to end on a real bundle (built at 2026.9.1 with this code, updating to the published 2026.9.2). Temporary, uncommitted patches shortened the first check to five seconds and pressed the window's real button from its own page.
message_stopat +33s — not cut. The restart came 23 seconds after the wait began; the bundle became 2026.9.2.brew update && brew upgrade --cask thinkwatch-liteon the system clipboard. The bundle stayed at 2026.9.1. (The clipboard was empty before and was emptied again after.)brew update && brew upgrade --cask thinkwatch-liteupgraded this machine's Homebrew install from 2026.9.1 (zip) to 2026.9.2 (disk image) — no quarantine attribute, andcodesign --verifypasses.The window, visually. Rendered in a browser with Tauri's IPC mocked, at the real 480px width, in light and dark: idle, downloading, waiting, failed, Homebrew, copied, and copy-failed. That pass found that the command was truncated inside an input with an embedded button (
…--cask thinkwatc), so copying moved to the action row and the window widened from 460 to 480px. Measured: no overflow.Tests:
update.rs: prefs default on, and an explicitfalsestill reads back asfalse; the cask version parser against the real cask format; numeric version comparison (2026.9.10 > 2026.9.9); prompt pacing; the command starts withbrew update.supervisor: a core stopped for exit is not restarted, including a SIGTERM round trip against a real child process; a requested restart still comes back. Removing the stop check fails withRestarting { attempt: 1 }.updateFlow.test.ts: no install button for Homebrew or dev builds; step text never invents a total size.Gates:
cargo fmt --check,cargo clippy --all-targets -D warnings,cargo test(77),pnpm typecheck,pnpm test(68),pnpm build.Related
Status.in_flight, released as v0.1.1.brew styleinspects something.🤖 Generated with Claude Code