Skip to content

feat(account): leave, sign out, and disconnect a lost device from every PC - #2856

Closed
devswha wants to merge 12 commits into
feat/account-joinfrom
feat/account-devices
Closed

devswha wants to merge 12 commits into
feat/account-joinfrom
feat/account-devices

Conversation

@devswha

@devswha devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Stacked on #2851 (join, remote approval, migration).

What

The account's devices (docs/account.md, rules 4-5, "Account members"):

  • Remove this device from your account (front page, signed in, asks once more): a remove for this device's own account key, signed by it, goes to the mailbox of every PC of the account; the sign-in ends, and this device forgets the pairings on those PCs. A pairing with the account key on a PC the account does not list is kept and named, since no remove reached it. Each PC revokes the device when it collects its mail.
  • Sign out keeps every pairing, as one made by QR code is kept; only the sign-in ends.
  • Disconnect from all PCs (Settings > Phone & devices, on another member's row of the account this browser is signed in to; two taps, as Revoke): a remove for that member's account key, applied at once on the PC this window is in (POST /api/account/records) and left in every other PC's mailbox.
  • Notices: the paired notice names the device that approved a new one remotely (approved_by), and a new removed notice says when a device left this PC and by whom (device-removed: revoked on this PC, or removed through the account by a named device).

Tests

src/lib/account/join.test.ts, against real servers (createServer, mkdtemp state, port 0, real RelaySession and Noise) and the in-repo fake account service:

  • a member leaves: both PCs revoke it from their mailbox, and the device forgets the key and its pairings;
  • a lost device is disconnected: at once on the PC the window is in, from the mailbox on the other, and the disconnecting phone stays in on both;
  • leaving keeps a pairing on a PC the account does not list, and says which.

Enrolling a new PC with the account's other devices is left out: taking them from another PC's device list breaks rule 6 (a signer adds only keys it checked itself). Follow-up: #2855.

Validation

  • bun run check fast at 08ceb08: ok (typecheck, build, unit tests).
  • Reviews: Codex (gpt-6.1-terra, xhigh, adversarial) ran before opening; its findings and their resolution are in the first comment.

…ost one, enroll a new PC

- Remove this device from your account (front page, after a confirm): a remove
  for this device's own account key goes to the mailbox of every PC of the
  account, the sign-in ends, and this device forgets its account key and the
  pairings that used it. Sign out only ends the sign-in; every pairing stays.
- Disconnect from all PCs (Settings > Phone & devices, on another member's
  row, while signed in): a remove for that member's account key, applied at
  once on this PC and left in every other PC's mailbox.
- A PC that just got its first member from this device is enrolled with the
  account's other members this device saw on its other PCs' device lists.
- The paired notice names the device that approved a new one remotely.

(cherry picked from commit 92b5cf8441b2475da336170d6bad00ec7f2939c7)
…outcome and account, and drop enrolling for now
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review findings before opening, and how they were resolved (08ceb08)

Codex (gpt-6.1-terra, xhigh, adversarial) at the first version:

Severity Finding Resolution
HIGH Enroll signed adds for keys taken from another PC's device list: a PC could inject keys Enroll removed from this PR (breaks rule 6); follow-up #2855
HIGH The enroll cache outlived removals and account switches Removed with enroll
HIGH Enroll turned a watch member into drive Removed with enroll
HIGH Leave forgot pairings on PCs the account does not list, which no remove reached Leave forgets only pairings on PCs the remove went to, keeps the others and names them
MEDIUM A PC's refusal of a removal was taken as success; the action could target another account's row The record's outcome is read; Disconnect shows only on rows of the signed-in account and refuses another
MEDIUM A failed sign-out during leave left pairings behind The removes are queued before sign-out; the account key is kept while any pairing is unconfirmed
MEDIUM Leaving one account forgot another account's pairings Only pairings on this account's listed PCs are forgotten
MEDIUM The removed notice claimed removal from every PC from a local event It says "removed from this PC", naming who
MEDIUM Enroll ran on the session of the old key Removed with enroll

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

…ame the PCs it cannot reach, and finish leaving when the sign-out is unconfirmed
# Conflicts:
#	src/lib/account/join.test.ts
#	src/lib/i18n/relay.ja.ts
#	src/lib/i18n/relay.ko.ts
#	src/lib/i18n/relay.zh.ts
#	src/lib/relay/shell.tsx
…ce a member, and report pending links as unconfirmed
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Second review round (300a4cd)

omo at 625c1bf: one reproduced HIGH, fixed with a failing-first test:

  • HIGH Disconnect and leave counted a PC as reached because this device held the account key there, without the PC having confirmed it a member: they now count only pairings the PC confirmed for this account, and report the others (and links whose answer was lost) as not reached.

Reproduced MEDIUMs left for a follow-up: #2878 (a watching device's own remove is refused). The others (the not-reached note cleared by the pairing-code poll, the key kept after a partial leave, a direct-address hereId) are noted there as lower.

Validation: bun run check fast ok at the new head.

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Third and fourth review rounds (2af3882, ca988fc, a628f57)

Fixed, each with a test that failed first:

  • HIGH A disconnect passed over a PC this device is linked on that the account does not list: it is now named as not reached.
  • HIGH A remove sent only to a PC's mailbox was shown as done, though a PC that revoked this device refuses it: those PCs are now named as sent, with what to do if the device still shows there.
  • MEDIUM A failing account service (429, 5xx, offline) aborted the disconnect before the PC in view applied it: the PC in view now goes first, and PCs whose post failed are named as not reached.
  • MEDIUM Leaving with a pairing the account does not list kept the account key, which the account's PCs tombstone, so the device could never join again: the key is always forgotten on leaving (the kept pairing holds its own copy).

Left for follow-up #2878 (not reproduced, or not reachable through the app): a watch-role member's self-remove, the not-removed note cleared by the pairing-code poll, a late /v1/pcs answer after sign-out, and PCs off for more than the mailbox's 30 days.

Validation: bun run check fast ok at a628f57.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying ovis with  Cloudflare Pages  Cloudflare Pages

Latest commit: 448fb47
Status: ✅  Deploy successful!
Preview URL: https://516191e3.ovis.pages.dev
Branch Preview URL: https://feat-account-devices.ovis.pages.dev

View logs

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Landed as part of #2867 (the whole account stack was merged there in one squash).

@devswha devswha closed this Nov 5, 2026
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