Skip to content

fix(account): give a sign-in saved without an id one when it is read - #3513

Merged
devswha merged 1 commit into
mainfrom
fix/account-name-old-sign-in
Nov 10, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/account-name-old-sign-in

Conversation

@devswha

@devswha devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner

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 through forSignIn(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

  • New: a sign-in saved without an id gets one on read, two reads agree, and a call bound to the copy read before its first refresh still works. Fails on main.
  • Changed: the laterSignIn helper in accountController.enrollment.test.ts built "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).
  • Skipped: bun run check full, browser regressions.

🤖 Generated with Claude Code

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]>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed repeated account reads so saved sessions retain a consistent sign-in identity.
    • Fixed a PC enrollment failure that could occur during the first access renewal after signing in with Ovis 0.5.1 or earlier.

AccountService.session() now assigns an ID to older stored sessions that lack sign_in_id. The change checks the refresh token before storing the ID. Tests cover stable IDs and enrollment using an earlier session copy after token refresh.

Changes: Legacy session identity

Layer / File(s) Summary
Assign and verify legacy session IDs
src/lib/account/service.ts, src/lib/account/account.test.ts, src/lib/relay/accountController.enrollment.test.ts, changelog.d/account-old-sign-in-id.md
session() generates and persists an ID for a stored session without sign_in_id only if its refresh token still matches the value read at entry. Tests cover stable IDs, use of an earlier session copy after token refresh, and later-session test setup. The changelog describes the reported account-read and PC-enrollment issues.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Possibly related PRs

  • devswha/ovis#3088: This PR adds the new-PC account join flow and enrollment from an already-accounted device. This change addresses the missing session ID that can affect enrollment after token refresh.
  • devswha/ovis#3087: This PR implements account-device enrollment, including enrollOnPc. This change addresses missing session identity in a pre-refresh sign-in copy used during enrollment.
Merge Risk: Minimal · up to 04b35

The legacy sign-in fix appears ready to merge after normal checks; no outstanding behavior issue was established.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly describes the fix: assign a missing sign-in ID when the saved session is read.
Description check Passed The description explains the problem and resulting behavior, links the follow-up to #3511, and reports tests, validation results, and skipped checks.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8363b40 and 04b3537.

Files selected for processing: 4

  • changelog.d/account-old-sign-in-id.md
  • src/lib/account/account.test.ts
  • src/lib/account/service.ts
  • src/lib/relay/accountController.enrollment.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@devswha
devswha merged commit 6fa11f4 into main Nov 10, 2026
13 checks passed
@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 04b353779296 as 6fa11f403f39 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
claude-standin CLEAR

Merged with these checks red, none of them required: ssh;

  • Reviewers: a fresh Claude agent and a Claude stand-in (Codex unavailable), both CLEAR at 04b3537. Both ran the new test's scenario against main's service.ts (it fails there) and judged the laterSignIn helper change a faithful model of a later sign-in; with the old helper the two enrollment tests fail because the copy inherits the stored id.
  • LOW, reproduced, not fixed: when another tab names and refreshes the sign-in between this read's get and its update, the copy returned still has no id, with the same outcome as on main (a narrower window).
  • LOW, reproduced, not fixed: where the store refuses writes (storage full), session() now rejects for a sign-in without an id, where main could still read it. Making the naming best-effort (return what was read when the update fails) would close it.
  • LOW, not run: an 0.5.1 tab open beside this build strips the id again on its refresh.
  • CodeRabbit did not review this head.

@devswha
devswha deleted the fix/account-name-old-sign-in branch November 10, 2026 03:04
devswha added a commit that referenced this pull request Nov 10, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant