fix(extension): popup shows live connection state instead of stale expiresAt#32
Merged
Conversation
…piresAt
The popup's connection-status display was checking bootstrap.expiresAt > now
to determine pairing status. Since expiresAt equals issuedAt + 5min (the
pairing code's claim window TTL), the popup falsely showed 'Not paired'
after 5 minutes — even while the WebSocket connection remained active.
The background ws-client correctly ignores expiresAt (connection lifetime is
governed by the daemon's active extension token, not the bootstrap envelope
freshness).
Fix: the popup now queries the background service worker for live WebSocket
badge state via chrome.runtime.sendMessage({ type: 'status.query' }) and
uses the response to drive the status display:
- connected → 'Paired with local daemon' (green)
- connecting → 'Connecting…' (muted)
- disconnected/error + has token → 'Disconnected' (muted)
- no token → 'Not paired' (muted)
Falls back to bootstrap-presence heuristic when the SW is unreachable.
Closes #31
…Popup - status-query.test.ts: verifies message matching, response shape, all badge states, and non-matching message passthrough. - initialize.test.ts: exercises initializePopup with injected deps and minimal DOM mocks — covers all state×bootstrap combinations plus storage failure graceful degradation.
|
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
Fixes #31 — Extension popup shows "Not paired" after ~5 minutes while the WebSocket connection is active.
Root Cause
The popup checked
bootstrap.expiresAt > Date.now()to determine pairing status. SinceexpiresAtequalsissuedAt + 5min(the pairing code claim window TTL, not the session validity), the popup falsely showed "Not paired" after 5 minutes.The background ws-client correctly ignores
expiresAt— connection lifetime is governed by the daemon's active extension token.Fix
The popup now queries the background service worker for live WebSocket badge state via
chrome.runtime.sendMessage({ type: "status.query" }):connectedconnectingdisconnected/errordisconnected/error/ nullFalls back to bootstrap-presence heuristic when the SW is unreachable.
Changes
extension/src/entrypoints/background.tsstatus.querymessage handler returningclient.getState()extension/src/entrypoints/popup/main.tsexpiresAtcheck with live SW query; refactoredgetConnectionStatusViewModel(liveState, hasBootstrap)extension/src/entrypoints/popup/__tests__/presentation.test.tsextension/src/entrypoints/popup/__tests__/initialize.test.tsinitializePopupintegration test with DIextension/src/background/__tests__/status-query.test.tsVerification
pnpm checkpasses (typecheck, format, lint, arch, deadcode)pnpm test— 887 tests pass across all workspacesVersion
Bumped to 0.9.2.