Repository navigation
feat(update): reliable update signal and a blue update dot on the tray - #5765
Conversation
Diff-level roadmap for update-available signalling: package cache refresh and async checks, desktop updater snapshot and tray blue dot, desktop update page, and the npm Windows tray indicator. Architect reflection ALIGNED and independent audit PASS are recorded in 000_plan.md.
Service installs never refreshed ~/.opencodex/version.json because the refresh only ran behind the interactive ocx start prompt, so the sidebar update badge stayed dark. The proxy now owns a refresh scheduler for npm, pnpm and Bun installs: it checks after bind when the cache is missing or older than 20 hours, rechecks hourly, coalesces per channel and backs off after failures. OCX_DISABLE_UPDATE_CHECK=1 turns it off. /api/update/check and /api/update/run now await an asynchronous registry lookup (pnpm owner discovery runs in a worker) instead of spawnSync on the request loop, and a successful check writes through to the cache. The badge GET stays read-only and reports unknown when the cache is older than 40 hours.
The desktop app's GUI asked the compiled sidecar for update state, but the sidecar classifies itself as a source build, so the sidebar orb never lit inside the app. The Tauri updater now publishes a bounded snapshot per desktop session to POST /api/update/desktop-snapshot (admin-token principal only, in memory, 180 s receipt TTL, 32 sessions, no install authority), and the embedded dashboard reads it with GET /api/update/badge?surface=desktop&session=<id>. Ordinary browsers keep the package badge. While an update is pending the tray shows a blue dot: macOS keeps the template glyph and draws the dot in an NSView on the status button; Windows and Linux swap to a generated dotted PNG. Native checks are ordered by a check generation so an older result cannot clear a newer one, and tray setters run outside the state gate.
Inside the desktop app the GUI's update button started the npm package update flow, which cannot update the app. In the desktop shell both the sidebar button and the dashboard update entry now navigate the main window to a bundled app-origin page, desktop/ui/update.html, which reads the native updater state, checks on request and installs through four narrow Tauri commands that only that page origin may call. The proxy served dashboard gains no updater capability. Tray and page installs share one gated claim: InstallClaim verifies a pending update under the check gate before committing, so a stale click cannot orphan an in-flight check, and the tray install arm no longer takes the pending update outside the gate. A superseded page check reports checking until a newer check settles.
The PowerShell tray that npm installs on Windows had no update signal. It now probes a new hidden, read-only `ocx __update-badge` command every 60 seconds (12 s timeout, 16 KiB output cap per stream, killed and reaped across ticks so the Forms tick never waits) and switches to a dotted variant of its online, warning or offline icon while the cached package badge reports an installable update. The safety colour keeps precedence, a stale answer expires after three minutes, and an "Update available" menu item opens the dashboard. The three dotted .ico files carry the same nine frames as the base icons and are produced by scripts/generate-windows-tray-update-icons.ts (--check compares bytes locally); the general test suite checks their structure without a renderer.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (119)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0e657dc24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const timer = setTimeout(() => { | ||
| child.kill(); | ||
| finish(null); |
There was a problem hiding this comment.
Reap timed-out registry child processes
When a registry command exceeds the deadline, this resolves the lookup immediately after merely sending the default termination signal. On Unix, a stuck or signal-ignoring npm/pnpm child is not guaranteed to exit, so the scheduler removes the flight and subsequent retries or explicit checks can spawn additional children while the old one remains alive. Wait for close after termination and use a bounded forced-kill fallback before considering the lookup finished.
Useful? React with 👍 / 👎.
The dev branch gained post_desktop_snapshot (lidge-jun#5765), a POST whose server route accepts only the admin-token principal. Keep the re-confirming authorised_token for that one write while reads stay on single-use capabilities, format the capability signature, and keep the Method::POST literal out of the file so the exit-ownership source assertion holds.
…bilities (#5759) * fix(desktop): attest proxy before sending admin token Rebased onto dev's RuntimeBinding flow: the attestation challenge and proof now ride the same /healthz round-trip that re-confirms the bound identity, and the MAC is keyed with the Base64URL text's UTF-8 bytes to match the server primitive. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(desktop): authorize management reads with a single-use capability The attested /healthz and the credential-bearing request were separate round-trips, so a process could take the port in between and receive the admin token. The token is also a reusable credential: once it left the client, the holder could replay it for anything. Requests now carry the existing local-read capability instead of the token: a single-use HMAC over the nonce, method, path+query, recorded pid and port, and a ten-second expiry, keyed by the attestation secret only the recorded runtime can read. A listener that took the port after the bound child exited cannot satisfy it, a captured grant is useless for any other request, and the admin token never leaves the client. The read contract widens to the desktop management paths and signs the query into the grant rather than refusing query-bearing requests, so a capability minted for one range cannot be replayed against another. A pid that no longer matches the record reports Foreign instead of Unauthorized, matching the widget's not-our-instance state. * fix(desktop): keep the auth test file under the size cap The added query-binding cases pushed server-management-auth.test.ts over the repository's 2000-line ratchet. The block is condensed to the same assertions in fewer lines. * fix(desktop): allowlist tray config and active-auth reads for local capabilities * fix(desktop): rebase on dev, restore token path for the snapshot publish The dev branch gained post_desktop_snapshot (#5765), a POST whose server route accepts only the admin-token principal. Keep the re-confirming authorised_token for that one write while reads stay on single-use capabilities, format the capability signature, and keep the Method::POST literal out of the file so the exit-ownership source assertion holds. * style(desktop): rustfmt the capability vector assertion * fix(desktop): sign the parsed URL target so a bare query marker does not break the capability CodeRabbit on #5759: the capability retry signed the raw path, but the server verifies pathname + url.search, which drops a bare ?. timeline(") produced exactly that shape and failed the capability check with Unauthorized. Derive the signed target from the parsed URL and cover bare ?, a populated query, and percent-encoding in tests. * fix(desktop): bind snapshot writes to single-use body capabilities Remove the remaining reusable admin-token transport from ProxyClient. Use a separate exact-route POST grant bound to raw body SHA-256, nonce, PID, port and ten-second expiry. Consume once and validate the bounded body before parsing or storing. Preserve read-v1 and existing admin publishers; reject GUI/origin writers. Add 22 regression cases and update the desktop/management contracts. Validation: 26 cases passed under a Node compatibility harness using the actual admission, route and badge-store code; unrelated dependencies stubbed. Bun/full project typecheck, privacy/structure gates and Rust build/tests were unavailable locally and require CI. * fix(desktop): complete tray grants and repair review gates Restore PATCH in the OAuth pool API documentation and document the query-bound native tray reads. Allow the actual OAuth-account and provider-key GET routes while preserving exact queries and read-only scope. Add six regression cases for admission, replay, selector/method binding, native source coverage, and removal of unused admin loading. Repair the digest-to-subtle Cargo.lock dependency edge without changing any package version, fix the two rustfmt failures, and remove the now unused reusable-token loader after checking for remaining callers. Validated the identical source tree 08d56be on isolated GitHub Actions: 106 native Bun tests passed across four files; project typecheck, privacy scan and structure checks passed. The helper workflow is absent from this tree and from this commit's ancestry. --------- Co-authored-by: luvs01 <[email protected]> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
Update availability was effectively invisible outside an interactive
ocx start. A proxy running as a launchd/systemd service never refreshed~/.opencodex/version.json(the refresh only ran behind the TTY prompt), so the sidebar's existing blue update orb never lit. Inside the desktop app the GUI asked the compiled sidecar, which classifies itself as a source build, so the orb could not light there either, and the update button started the npm package flow, which cannot update the app. The tray icons had no update signal at all.This PR makes the signal reliable on every install type and puts a blue dot on the tray icon itself. It is five ordered commits:
feat(update)). A refresh scheduler in the proxy checks npm/pnpm/Bun installs after bind when the cache is missing or older than 20 h, rechecks hourly, coalesces per channel and backs off after failures (OCX_DISABLE_UPDATE_CHECK=1turns it off; the test preload sets it)./api/update/checkand/api/update/runnow await an asynchronous registry lookup instead ofspawnSyncon the request loop, and a successful check writes through to the cache. The badge GET stays read-only and reportsunknownonce the cache is older than 40 h.feat(desktop)). The signed Tauri updater stays the authority. It publishes a bounded per-session snapshot toPOST /api/update/desktop-snapshot(raw admin-token principal only, refuses anyOrigin, in memory, 180 s receipt TTL, at most 32 sessions, no install authority); the embedded dashboard readsGET /api/update/badge?surface=desktop&session=<id>, while a normal browser keeps the package badge. While an update is pending the tray shows a blue dot: on macOS the template glyph is kept and the dot is anNSViewon the status button; Windows and Linux swap to a generated dotted PNG. Native checks carry a generation so an older result cannot clear a newer one, and tray setters run outside the state gate.feat(desktop)). In the desktop shell the sidebar and dashboard update entries open a bundled app-origin page,desktop/ui/update.html, with four narrow Tauri commands callable only from that page. The loopback dashboard gains no updater capability. Tray and page installs share one gatedInstallClaim(a stale click with nothing pending cannot orphan an in-flight check), and a superseded page check shows "checking" until the newer check settles.feat(tray)). The PowerShell tray probes a new hidden, read-onlyocx __update-badgeevery 60 s (12 s timeout, 16 KiB cap per stream, kill-and-reap across ticks) and switches to a dotted variant of its online/warning/offline icon; the safety colour keeps precedence, a stale answer expires after 3 min, and an "Update available" item opens the dashboard. Installs from before the dotted icons keep their registration and pick the new icons up on the nexttray install.devlog/_plan/260924_update_indicator/(docs only).Screenshots (
pr-assetse9a5936):The macOS image renders the shipped
UpdateDotViewcode fromapp/Sources/NativeTray/Popover.swifton realNSStatusItems throughcacheDisplay; the page screenshot is the bundled page in headless Chrome with a stubbedinvokereturning a pending update.Out of scope and left as follow-ups: an automatic-install policy; Windows
POST /api/update/runstill launches the installer through a bounded (15 s) synchronous PowerShellStart-Process(pre-existing, one-shot before restart); a light/dark base glyph for the Windows Tauri tray; npx/Volta/Yarn/Homebrew install detection.Verification
Run on macOS at the PR head unless noted.
bun run typecheck,bun run structure:check,bun run privacy:scan,bun run skill:surface:check: exit 0.__update-badge, Windows tray, desktop update surface, desktop runtime identity, layout, file-size ratchet, Lab boundary): 464 pass, 0 fail.bun run lint,bun run lint:i18n,bun run build,gui/tests/desktop-shell.test.ts5 pass.cargo test147 pass,cargo clippy --all-targets -D warningsclean,bun run icons:check19 match; SwiftNativeTrayTests(26 assertions) andbun run test:macospass; Windows ICO generator--checkmatches.docs-sitebuild, 505 pages.bun run testfrom a detached checkout outside~/.codex(this worktree's test-home guard breaks unrelated suites): 26 failures, 25 of which reproduce on thedevbase or pass in isolation (a live proxy on port 10100 makes the launcher/service fixtures step aside; parallel contention). The one branch-caused failure (desktop-runtime-identitypinned the old"tauri" => trueorigin arm) is fixed in commit 3.pwshhere; they run in the dispatched Windows legs), live Windows/Linux tray rendering, and packaged cross-origin navigation to the update page on Windows/Linux.Checklist