Repository navigation
fix(account): give a sign-in saved without an id one when it is read - #3513
Conversation
A sign-in stored by 0.5.1 or earlier has no sign_in_id. Its first refresh changes the refresh token and gives it an id, so a copy read before that refresh no longer counts as the same sign-in (sameSignIn), and a call bound to it (forSignIn, used by the account reads and an enrollment since #3511) refused its own sign-in: Settings read twice, an enrollment read the directory blind or was recorded failed. AccountService.session() now writes an id to such a session in the store's own update, so every reader holds the same one before any refresh. What was read stays the answer when another sign-in is stored meanwhile. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
Merged with these checks red, none of them required: ssh;
|
…rectory answer (#3519) Follow-up to #3511 and #3513: the MEDIUMs a Codex review (Terra 6.1, team proxy) of the merged commits reproduced, and what three review rounds of this PR found. ## Change - **A session is read and named in one update of the store** (`src/lib/account/service.ts`). #3513 read the stored sign-in and then gave one saved without `sign_in_id` an id in a second step. Another tab could name and refresh it in between; a sign-out bound to the stale copy then took the refreshed sign-in for another one and left it stored (the page said signed out, a reload signed back in). `session()` is now a single `store.update` with no read before it, and the id of a saved sign-in is a SHA-256 digest of its refresh token (`@noble/hashes`, already in the bundle), so tabs of this build agree. An id another tab already stored is kept. A store that takes no write is read as before. `session()` therefore writes on every read (a readwrite transaction where there was a readonly one). - **The hosted app's list belongs to one sign-in** (`src/lib/relay/accountController.ts`). A directory answer that lands after another tab stored another sign-in is dropped and read again as that one; the rows on screen are dropped before a read when they were another sign-in's (`shownFor`), so a failed read cannot draw them again; a failed read with nothing kept lists this device's paired PCs instead of the loading skeleton. Client only, no contract change. ## Validation - New tests in `account.test.ts` and `accountController.test.ts`, each failing on main: one-update read and naming, a kept stored id and a store that takes no write; a late directory answer; no rows of the earlier account when the new one's read fails. - `bun test ./src/lib/account/ ./src/lib/relay/ ./src/components/AccountSection.test.ts`: 424 pass. - `bun run check fast`: pass (unit 14390 pass, 0 fail). - Skipped: `bun run check full`, browser regressions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <[email protected]>
Follow-up to #3511 (the LOW both merge reviewers reproduced there).
Change
A sign-in stored by Ovis 0.5.1 or earlier has no
sign_in_id(the field came with #3284). Its first token refresh changes the refresh token and gives it an id, so a copy read before that refresh no longer counts as the same sign-in (sameSignIn). Since #3511 the account reads and an enrollment act throughforSignIn(copy), which then refused its own sign-in once: Settings read the account twice, and an enrollment that spanned the refresh read the directory blind or was recorded failed.AccountService.session()now gives such a session an id when it reads it, inside the store's own update so two tabs agree on one id. If another sign-in (or none) is stored between the read and the update, that one is left alone and the session that was read is returned as it was.Client only, no contract change.
Tests
laterSignInhelper inaccountController.enrollment.test.tsbuilt "a sign-in made later" by copying the stored session and changing its tokens. The stored session now carries an id by then, so the copy counted as the same sign-in and two tests failed. A real later sign-in gets its own id from the service's answer (sessionOf), so the helper now gives it one. Those two tests also caught a bug in the first version of this change (a sign-in stored during the update was returned in place of the one read), fixed before pushing.Validation
bun test ./src/lib/account/ ./src/lib/relay/ ./src/components/AccountSection.test.ts: 420 pass.bun run check fast: pass (unit 14382 pass, 0 fail).bun run check full, browser regressions.🤖 Generated with Claude Code