fix(tray): emit config-changed on auth_lost so Paired-as UI updates#137
Merged
Conversation
After a real device-revoke 401, `clear_persisted_device_token` (in the drain_lane / fetch_me_check paths) blanks `access_token` and `claimed_handle` on disk. The sync worker then sees `auth_lost=true` on its next iteration, exits, and emits `sync-paused` — which the Settings pane uses to flip the health pill to PAUSED. What was missing: a `config-changed` emit. The React-side config state stays at whatever `setConfig(...)` last received, so even though disk says "unpaired", the SettingsPane reads `isPaired = !!access_token && !!claimed_handle` from React state and keeps the "Paired as TheCodeSaiyan" card mounted. The user had to click Unpair manually to force a refresh before they could enter a fresh pairing code. Now: after emitting `sync-paused`, also `config::load()` the freshly-cleared config and emit `config-changed`. App.tsx's existing listener (`setConfig(e.payload)`) propagates the empty remote_sync block down to SettingsPane, which naturally transitions from the "Paired as" card to the "enter pairing code" input. Surfaced 2026-05-29 on the live `tray-v1.8.12` build (PR #132 shipped today). User test confirmed PAUSED state fires correctly but the pair UI didn't transition without manual Unpair. `clear_persisted_device_token` itself doesn't emit because it's called from drain_lane / fetch_me_check contexts without `AppHandle` in scope. Plumbing the handle through would touch every caller; the simpler move is to make the spawn_lane auth_lost branch (which already has the handle) responsible for the user-visible emit. No tests added — the existing fixture surface doesn't reach the spawn_lane loop, and the emit itself is unit-untestable without mocking Tauri's event bus. The change is exercised end-to-end on the next user-facing repro.
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.
Summary
Follow-up to PR #132. Surfaced today on the live
tray-v1.8.12build: when the tray actually hits a real device-revoke 401,clear_persisted_device_tokenblanksaccess_token+claimed_handleon disk, but noconfig-changedis emitted. React state stays at the old paired values, so the SettingsPane's "Paired as TheCodeSaiyan" card stays mounted even though the health pill correctly flips to PAUSED. User has to click Unpair manually before they can enter a fresh pairing code.Fix: after emitting
sync-pausedinspawn_lane's auth_lost branch, alsoconfig::load()the cleared config and emitconfig-changed. App.tsx's existing listener propagates the emptyremote_syncblock down to SettingsPane → isPaired flips false → pair-code input replaces the "Paired as" card. No manual Unpair click needed.Test plan
cargo test -p starstats-client --bin starstats-client→ 210 passed.cargo fmt -p starstats-client --checkclean.cargo clippy -p starstats-client --bin starstats-client --tests -- -D warningsclean.Compatibility
No API contract change. The emit re-publishes whatever is currently on disk; React's existing
config-changedlistener handles it identically to any other config update.Related