Skip to content

feat(account): add a PC to the account with one approval on a device already in it - #3088

Merged
devswha merged 25 commits into
mainfrom
feat/account-one-tap-ui
Nov 6, 2026
Merged

devswha merged 25 commits into
mainfrom
feat/account-one-tap-ui

Conversation

@devswha

@devswha devswha commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Follows #3087 (merged).

What

Adding a PC to the account takes one approval on a device already in it, instead of every device
pairing with the new PC. The design follows WhatsApp's linked devices and Tailscale's Tailnet Lock:
an existing device approves once, and the server only carries messages.

  • On the new PC (Settings → Phone & devices → Account, signed in, PC in no account):
    Add this PC to my account lists the PC in the account's directory and opens a pairing window
    with POST /api/relay/link and the header x-ovis-local-only: 1. What comes in under that window is decided on this PC
    only: it is never listed to account members (remote-pairings) nor approvable by one, and that
    is fixed when the phone asks, so a window closing before the digits show changes nothing. The
    screen keeps the window open while it waits and stops once the PC is in the account. An entry
    older than the card's ten minutes is listed anew, which rings the account's devices again.
  • On a device already in the account, a PC new in the directory shows as a card, Add {name}
    to your account?
    Adding it from the card asks for the six digits the new PC shows, typed (not a tap, as
    a directory name is anyone's); one wrong entry ends the comparison. The person then approves on
    the PC, and feat(account): enroll a new PC with the account's devices once its removals are in #3087's enrollment brings in the account's other devices and introduces the PC to them.
  • Phone app front page: signing in comes first; the QR code and pairing code move under
    Other ways. Without an account service the page is unchanged.

Docs: docs/account.md "Adding a PC".

Review

Codex (Terra, xhigh) on this branch before opening; fixed here:

  • HIGH: the typed-digits intent was lost on the page load that opens the PC, so the plain tap
    comparison stood in for it. Kept in the tab's session storage (only ever makes a comparison
    stricter).
  • HIGH (reproduced): a request taken under the local-only window, revealed after it closed, became
    remotely approvable. Fixed at request time in the session.
  • MEDIUM: the waiting screen kept reopening the window after success; the card expired while the PC
    still waited. Both fixed.
  • MEDIUM, not changed: an account page already open does not refresh its directory when a new PC
    is listed (the push ring and reopening the app do).

Tests

  • server/relay/pair-sas.contract.test.ts: a local-only window's requests are never listed or
    decided remotely, and stay so when the window closes between request and reveal (fails with the
    session capture reverted).
  • src/components/RelayShell.test.tsx: sign-in before Other ways beside saved PCs; the new-PC card
    for a fresh directory entry only; the typed comparison shows no digits and a wrong entry ends it.

Visual QA

Rendered the four new states (front page signed out with a saved PC, new-PC card, typed digits,
wrong number) at 390 and 1280 wide, light and dark, in Chromium: no overflow, card and fold sit on
the existing spacing tokens.

Validation

  • bun test server/account src/lib/account src/lib/relay src/components server/relay/pair-sas.contract.test.ts server/relay-pc.contract.test.ts src/lib/i18n.test.ts: pass (head 840526a, main merged)
  • bun run check fast at 840526a: pass (workflow syntax, generated types and themes, typecheck, build, unit tests)
  • Visual QA: the four new states at 390 and 1280 wide, light and dark, in Chromium: no horizontal overflow, no page errors
  • scripts/relay-shell-browser-qa.ts: fails at its file-viewer step (.workspace-group .pane-select click times out, line 496), and fails the same way on origin/main 554332a, so the break is on main, not here; its earlier steps (front page, pairing) pass

…, behind a barrier

The first link starts an enrollment barrier on the PC: no account add applies
until that member's POST /api/account/enroll. An enrollment now carries removes
and adds; the PC applies every remove first (in signing order), then the adds in
rounds, retrying waiting removes between rounds. An add is refused
removal_pending while a waiting remove names its key, an enrollment held it, or
the waiting queue is full or unreadable. The status lists the signed adds behind
the rows and every blocked key; ?fresh=1 pulls the mailbox first.

The client's enrollPc sends its removes through enroll, which lifts the barrier.
…removals every reachable PC holds

Before enrolling a PC it brought into the account, the client reads every other
PC of the account it is linked on (status ?fresh=1: blocked keys, signed removals
and signed adds). It then sends one enrollment: its own and kept removes, its own
adds and the adds those PCs list, minus any key a PC keeps out or a verified
removal names, and those keys as held. Nothing is signed for collected records.
If no other PC answers, nothing is sent until the next connection.

Each PC that answered introduces the new PC to the devices let in; introductions
now persist for 30 days and merge by PC.
- a remove waiting on its signer is kept before the next record of its batch,
  so an add for its key right behind it is held back (records and mailbox)
- only the member whose link started the barrier ends it, with the last part of
  its enrollment, once every remove was decided; a refused link never lifts it
- status ?fresh=1 says fresh only after a whole, error-free mailbox read; the
  client counts only such PCs as checked
- more held keys than one enrollment carries latch every add off (held_full)
- the overflow latch is written before any waiting remove is dropped; a full
  queue of waiting adds no longer holds every add back, and a relayed remove
  makes room by dropping a waiting add
- the approver hands its add to the PC that let the device in, which keeps it
- settle and a mailbox pull retry the waiting records one at a time, so a
  waiting remove never leaves the add gate's sight
- status says blocked_all when the PC holds every add back; the client then
  sends no add and holds every one on the new PC
- a remove a full queue could not keep still holds back an add for its key in
  the same batch
- an earlier part with an undecided remove keeps the new PC's wait
- the barrier names the device whose link succeeded
- account-enrolling.json and account-held.json are read apart, and neither is
  written over while one cannot be read
- older PCs: a peer without fresh counts only for its removals (no add is sent);
  a new PC that refuses removes in enroll gets them through records
…one existing device

- Settings > Account on a PC in no account: Add this PC to my account lists it
  in the account's directory and opens a pairing window only that PC approves
  (POST /api/relay/link?local_only=1); remote members never see or decide it
- on a signed-in device, a PC new in the directory shows as a card; adding it
  asks for the six digits the new PC shows, typed (one wrong entry ends it)
- the phone app's front page puts signing in first; QR and pairing code go
  under Other ways
… attempts they were meant for

- the typed-digits marker for a PC joined from its card survives the page load
  that opens it (tab session storage), so the plain tap comparison never stands
  in for it
- whether a comparison is the PC's own to decide is fixed when the phone asks,
  so a window closing before its digits show cannot hand it to a member
- the add-me screen stops reopening the window once the PC is in the account,
  and lists the PC anew when its directory entry is older than the card
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Summary

Summary by CodeRabbit

  • New Features
    • Add a PC to an account from its account page, then approve it using a device already in the account.
    • Confirm pairing by entering the number shown on the new PC. Sign-in now appears before QR-code and pairing-code options.
    • Account enrollment reports progress and can retry records that aren’t yet resolved.
  • Improvements
    • Newly linked PCs process account removals before receiving remaining devices, helping keep removed devices excluded during enrollment.
  • Documentation
    • Updated account setup guidance with the new PC-adding and enrollment steps.

The pull request adds persistent account enrollment state, removal-first enrollment processing, and client retries based on peer status. It also adds a flow for listing a PC in an account directory and approving it through local-only pairing with typed-digit confirmation.

Changes: Account PC enrollment and approval

Layer / File(s) Summary
Persistent account state
shared/account-records.ts, server/account/holds.ts, server/devices.ts, server/account/introductions.ts, server/dispatch.ts, server/index.ts, server/account/account.contract.test.ts, docs/account.md
Persistent state now tracks enrollment barriers, held keys, signed account additions, and introductions. Server wiring and tests cover these stores.
Server enrollment processing
server/account/records.ts, server/account/mailbox.ts, server/account/routes.ts, server/account/account.contract.test.ts, docs/account.md
Enrollment applies removals before additions. The mailbox retains and retries waiting records, gates additions, and reports freshness. The API exposes enrollment and account status.
Client enrollment
src/lib/account/join.ts, src/lib/relay/shell.tsx, src/lib/account/join.test.ts, docs/account.md, changelog.d/account-enroll-barrier.md
The client gathers status from other PCs, submits enrollment batches, reports progress, and introduces admitted devices. Tests and documentation cover peer checks and enrollment results.
PC listing and local approval
src/lib/account/addThisPc.ts, src/lib/account/myPcs.ts, src/lib/account/service.ts, src/lib/api.ts, server/relay/*, src/lib/relay/shell.tsx, src/lib/relay/shellState.ts, src/components/AccountPcs.*, src/components/AccountSection.tsx, src/components/RelayShell.*, src/lib/i18n*, src/lib/i18n/relay.*, server/relay/pair-sas.contract.test.ts, docs/account.md, changelog.d/account-add-pc-once.md
A PC can be listed for account addition and approved with digits shown on that PC. Local-only comparisons are omitted from remote approval listings. The interface places QR and pairing-code options under “Other ways” when sign-in is available.

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Feature

Possibly related issues

  • devswha/ovis#2956 — The enrollment flow collects verified removals from other PCs before applying additions.
  • devswha/ovis#2878 — The change stores signed additions on the approving PC for later enrollment, but does not establish retry of delivery to existing PCs.

Possibly related PRs

  • devswha/ovis#3087 — This PR implements removal-first enrollment and device introductions used by the PC approval flow.
Merge Risk: High · up to c7039

Do not merge yet: enrollment can leave removed devices with access, lose admission restrictions during state migration, and bypass the new typed verification flow. Other failures can omit account devices or leave enrollment waiting indefinitely. Resolve these correctness and access-control issues before release.

- [ ] 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

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Browser QA at e9b0475: bun scripts/relay-shell-browser-qa.ts (the hosted shell in Chromium against a real PC and the Bun relay, isolated herdr test session) passed: every front-page, pairing, push, update and CSP step, 26 pages with no policy violation.

…p that card up while the PC waits

- a PC's plain row joins as before (digits shown on this device); only the card
  for a PC that just asked to be added asks for the number it shows, with a hint
  to tap the row instead when no number is there
- each reopening of the add-me window lists the PC anew before the card's ten
  minutes run out, so the card stays while the screen waits
- the waiting screen names the phone app, where the card is
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review round (omo + Codex Terra xhigh on e9b0475) and how each finding was resolved

Fixed in c703948:

finding severity resolution
Every account PC row, not only the new-PC card, switched to the typed comparison; for a PC already in the account (members-only join, no digits on the PC) the join stalled (omo, reproduced) HIGH Only the card asks for typed digits; a row joins as before. The typed screen says to tap the row instead when the PC shows no number. Checked in Chromium: the card calls the join with typed, the row without
The 9-minute relist kept the original added_at, so the card vanished after 10 minutes while the PC still waited (omo, reproduced) MEDIUM Each relist lists the PC anew before the card would expire
The waiting screen said "a phone or PC", but only the phone app shows the card (Codex) note Copy names the phone app

Not changed (LOW, for follow-up):

  • When session storage is unavailable the typed intent falls back to the plain comparison (the behaviour before this PR).
  • The local-only window can stay up to 10 minutes after the PC is enrolled; a join asked meanwhile is approved on the PC rather than remotely (fail-safe).
  • An account page already open does not refresh its directory when a new PC is listed.

- a fresh status is fresh only for the account and relay identity it was read for
- a relayed remove the full queue cannot take holds its key out of every add
- enroll takes only true or false for last and held_full
- the first link that succeeds keeps the barrier
- while any PC from before enrollments answers, no add is enrolled
- opening the account's other PCs before an enrollment is bounded like their answer
…a PC that cannot, and let a new first member take over

- ?fresh=1 waits for a pull that starts after the request, so a remove posted a
  moment before it is counted; a PC with no account service is fresh
- a PC whose mailbox read failed counts like an older PC: its removals go, no
  add does, and the new PC's wait ends instead of holding every add for good
- a barrier confirmed by a first member revoked before it enrolled the PC is
  taken over by the next first link
…hold every add when a PC could not vouch

- only OVIS_ACCOUNT_SERVICE_URL=off counts as having no mailbox; an unusable
  address is never fresh
- when a PC the client read could not vouch for what it keeps out (mailbox read
  failed, or older), the enrollment sends held_full, so adds that waited on the
  new PC stay out after its barrier ends
…hose signer a waiting remove names, and keep a row's add through a merge
…block a signer only on a waiting remove, and replace a kept add for another key

- a PC that could not read its mailbox this time (or is older) only keeps the
  enrollment's adds home; only lost removal evidence latches every add off
- an add waits on its signer only while a remove for that signer waits here, not
  for a key an enrollment held that is back on this PC
- a row's kept add for an older key is replaced by its approver's current one
… on a new PC from before enrollments

- with no other PC to read while the directory lists some (or the directory
  cannot be read), the client sends the removes but no add
- a new PC whose status has no enrolling is from before enrollments: it gets
  the removes through records and no add, whatever the batch holds
… and introduce what an unfinished attempt let in
…p the wait while a PC could not read its mailbox

- a member's remote approval and a link onto a key this PC holds back (removed
  elsewhere, or a remove for it waits here) are refused; a pairing approved on
  the PC itself still lets it in
- an enrollment while a PC answered not fresh sends its removes and no add, and
  is not the last part: the new PC keeps its wait until a later connection reads
  that PC whole
devswha added a commit that referenced this pull request Nov 6, 2026
…movals are in (#3087)

Part of #2956 (the add half)

## What

A PC that a client brings into the account now gets the account's
devices in one go, instead of
every device asking that PC again. This is the "approve a new PC once"
half of linking by account;
the screens come in a follow-up PR.

**Server (PC)**

- **Enrollment barrier.** The link that gives a PC its first member
writes
`account-enrolling.json` first. Until that member's `POST
/api/account/enroll` succeeds, no
account `add` applies there, from `/api/account/records` or the mailbox
(`refused`, `enrolling`;
mailbox adds wait in `account-pending.json` and are tried again after
the enrollment). A refused link leaves the barrier; the first link that
succeeds keeps it. No timeout: a client that never enrolls leaves the
adds held.
- **Ordered enrollment.** `/api/account/enroll` now takes removes and
adds (at most 512) plus
`held` keys (at most 4096). The PC keeps `held` on disk
(`account-held.json`), applies every
remove first in signing order, then the adds in rounds (an add whose
signer another add lets in
applies in the next round), retrying waiting removes after each round,
then lifts the barrier.
- **Add gates on every path.** An add is refused `removal_pending` while
a waiting remove names its
key (whatever its signer), an enrollment held it, or the waiting queue
is full or cannot be read.
Past 1000 waiting records adds are dropped first; if a remove has to go,
every add is refused from
then on. An unreadable `account-pending.json` is no longer an empty
queue.
- **Status.** `GET /api/account/status` adds `adds` (the signed add
behind each row, kept as
received, including the approver's own add for a row its remote approval
made), `blocked` (every
tombstone key, signed or not, every key a waiting remove names, every
held key) and `enrolling`.
`?fresh=1` pulls the mailbox first (a pull that starts after the
request; requests that come while one runs share the next).
- **Introductions** persist in `account-introductions.json` for 30 days
and merge by PC.

**Client**

- `enrollPc` first reads every other PC of the account it is linked on
(`?fresh=1`, 8 s each). It
then sends one enrollment: its own and kept removes, its own adds and
the adds those PCs list,
minus every key a PC keeps out or a verified removal names (any signer:
fail closed), and those
keys as `held`. It signs nothing for collected records. If no other PC
answers, it sends nothing
  and tries on the next connection.
- Each PC that answered then introduces the new PC to the devices let
in, so they sign in there; an introduction a PC could not take stays in
the plan and is sent again on the next connection.

Design and two rounds of Codex (Terra, xhigh) adversarial design review
are summarised in the
first PR comment. Known, documented limit: a removal held only by PCs
the client cannot reach, and
hidden by the account service, is missed; the device then comes back on
the new PC, announced.

## Tests

`server/account/account.contract.test.ts` (real servers):
- the first link holds every account add (direct and mailbox) until the
member enrolls, across a
  restart, then lets the waiting ones in;
- an enrollment applies removes before adds whatever the order sent, and
adds in rounds;
- a remove waiting for its signer keeps that key's adds out on every
path, and once an enrollment
  lets the signer in the key is removed;
- held keys stay out of every later path, while a device already there
keeps its row;
- the status lists signed adds (incl. an approver's own) and every
blocked key;
- an unreadable pending file, or removes pushed out of a full queue,
hold every add back;
- introductions merge by PC, outlast a restart and expire.

`src/lib/account/join.test.ts`:
- the #2947 Mac repro, "does not let back on the new PC a device another
member removed": with adds
enabled and no other PC read, it fails (Y admits the Mac); with the
client reading X first it
passes, and a copy of the Mac's add arriving later is refused
`removal_pending`;
- devices another PC lists come into the new PC and are introduced to it
there, and sign in;
- with no other PC answering nothing is sent and the PC stays in its
barrier.

Failing-first: each new server test fails with its part reverted (the
`held` gate, the barrier
start on link, the remove-first ordering, keeping the approver's add,
the overflow latch).

Review fixes already in (Codex Terra xhigh on the branch before
opening): a remove waiting on its
signer is kept before the next record of its batch; only the linking
member ends the barrier, with
the last part of its enrollment and every remove decided; `?fresh=1`
reports `fresh` only after a
whole, error-free mailbox read and the client counts only such PCs;
`held_full` latches every add
off; the overflow latch is written before any waiting remove is dropped;
a full queue of waiting
adds no longer holds every add back; the approver hands its add to the
PC that let the device in.

## Validation

- `bun test server/account src/lib/account src/lib/relay
server/state-merge server/relay/pair-sas.contract.test.ts`: 399 pass, 0
fail (head 0c6807d, main merged)
- `bun run check fast` at 0c6807d: pass (workflow syntax, generated
types and themes, typecheck,
  build, unit tests)
- Not run: `bun run check full`, browser regressions (no UI in this PR;
the stacked UI PR #3088 ran
  the relay shell browser QA)
Base automatically changed from feat/account-one-tap to main November 6, 2026 02:26
# Conflicts:
#	docs/account.md
#	src/lib/i18n.ja.ts
#	src/lib/i18n.ko.ts
#	src/lib/i18n.zh.ts
@devswha

devswha commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate (owner-approved): based on main after #3087, bun run check fast passed at this head, omo CLEAR at this head; Codex Terra xhigh found no HIGH (the PC-only pairing window cannot be opened, extended or flipped from another site, an open LAN window, a Portal visitor, a relay session or a watch device; the six digits are typed only on the new-PC card by design); threads resolved, merges cleanly; visual QA 16 shots 390/1280 light/dark. Fix found in QA: Add this PC to my account was refused by relay controls (query string), now sent as the x-ovis-local-only header with a route test that fails on the old form. relay-shell-browser-qa fails identically on main (separate fix). Merged without waiting for GitHub CI.

@devswha
devswha merged commit eb87890 into main Nov 6, 2026
19 of 21 checks passed
@devswha
devswha deleted the feat/account-one-tap-ui branch November 6, 2026 02:41
devswha added a commit that referenced this pull request Nov 6, 2026
…ce (#3148)

## What

Settings → Devices and PCs is regrouped so connecting anything is one
list and one button.

- **Account** on top (sign in with GitHub, Add this PC to my account,
Sign out of GitHub).
- **My devices**: one **Connect a device** row with a **Connect**
button, then one list:
this PC (a **This PC** pill and its relay ID, read again when the relay
starts or its identity is
reset), the other PCs this app shows (PC pill, state; removing a PC
stays in the sidebar's PC menu,
which moves the selection off it first and leaves herdr-managed PCs to
herdr), signed in the
account's other PCs, then the paired phones and browsers (a Phone /
Tablet / Browser pill when the
label is still the one the app gave it, none for a renamed device; last
seen, Rename, Revoke),
**Revoke every device**, and **Sign out of this PC** (named apart from
Sign out of GitHub).
On a touch phone on this PC's own address with the relay online, its own
row carries
  **Use the relay**.
- **Connect a device** dialog:
- Signed in, this PC in that account and the relay online: the new
device signs in with GitHub
and is approved once on a device already in the account (the existing
account approval prompt,
number picked out of three, #3087/#3088; per docs/account.md it never
shows on the PC's own
    windows). **Connect with a code (no sign-in)** shows the code view.
- Otherwise: the relay's QR code and the code to type side by side, only
**Refresh** and
**Copy**; signed out where the account is offered, one line says signing
in skips the code.
While the relay is not online: its state, the switch for the owner (with
the gate condition),
a failed start's reason and Try again; read-only devices get the
owner-only line.
- **Enter a code from another device** (the typed-code form, with the ID
match step).
- **Other ways to connect**: Same Wi-Fi (six-digit code, QR, Refresh,
Copy), Tailscale, Portal
    (where offered), Add a PC over SSH.
- **More settings**: This device (Keep screen on, Install), Ovis relay
(switch, Reset relay
identity), Show in sidebar, Access, the PCs' bridge updates and load
line.
- This PC's ID left the dialog: it is at the top of My devices, and the
typed-code confirmation
  (here and in the hosted app) says to compare it there.
- Old links `?settings=devices&section=phone|remote|portal` land on My
devices; the palette's
Remote PCs entry is My devices; Connect a device's row carries the old
rows' words for search.

The same Wi-Fi code stays a row under Other ways: connecting directly on
the same network with
the relay code needs a new pairing step (find the PC's LAN address and
prove it is the same PC),
so it is left for a follow-up rather than added here.

Design precedent: WhatsApp's Linked devices (one list, one Link a
device) and Tailscale's admin
Add device (one button, the ways inside). DESIGN.md is updated.

## Notes for review

- Opening Connect a device now makes a live code at once (the relay's
code to type, which starts a
six-digit code, or the six-digit code when the relay is off), as the
owner asked for the code to be
on screen beside the QR code. It is never kept for the next opening (a
looked-up code is spent even
when its person cancels at the ID comparison), so opening the dialog
more than ten times in ten
minutes reaches the PC's pairing limit, and its error shows in the
dialog. The code and the QR code
carry the one pending pairing and are renewed together when it runs out.

- The relay's code to type is minted as the dialog opens, then the offer
is asked for: asked
together, the six-digit code the offer starts ended the code being
minted (`This code was
  replaced`, a 500), found by the updated relay-panel regression.
- Connect a device sits above Settings even where Settings is raised
over a file preview, and the
  account approval prompt sits above Connect a device.
- The demo answers `/api/account/status` with `?demo_account=member` and
carries the Host's relay
  ID while its device routes are on, for the captures.

## Validation

- `bun run check fast`: green.
- Browser regressions in the CI runner image (herdr-ci-runner:local, as
the runner user):
settings-pages-demo, security-summary-demo, hide-pc-demo, pc-load-demo,
sidebar-declutter-demo, install-state-demo, lan-exposure-notice, portal,
file-viewer, device-security-demo and
ui-regression (which runs the relay panel and wake-lock checks) all
passed before the merge of main;
after it, settings-pages-demo, install-state-demo, device-security-demo
and ui-regression passed again.
file-viewer-regression and ui-regression each failed once on an
unrelated timing (a "Needs input" droplet
over the file viewer's menu; a sidebar agent badge 27 s in) and passed
on the lane's own retry.
- Not run: relay-shell-browser-qa and machines-browser-qa (they need a
real herdr and relay outside the lane;
  their edits here are a selector and comments).
- Codex (Terra, xhigh) on the first commit: CLEAR, five MEDIUM/LOW
findings, all fixed in the second commit.
- Screenshots (1280 and 390, light and dark, signed out and signed in,
dialog states): in the lane's report (demo build).
This was referenced Nov 6, 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