Repository navigation
fix(settings): keep Settings open after a sign-in on Add a connection - #4510
Conversation
A sign-in on Settings > Devices and PCs > Add a connection's relay tab to the account this PC is already in closed Settings onto the main screen (owner #25), so in the Mac app the account and its PCs were gone until Settings was opened again. Now it closes only the sheet and Settings stays on Devices and PCs; only a sheet the setup checklist's Connect your phone opened still goes on to the main screen. Co-Authored-By: Claude Opus <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
…gs open relay-account-pcs-regression waited for Settings to close after a sign-in on Add a connection to the account this PC is already in. It now waits for the sheet to close and Settings to show the account and its PCs on Devices and PCs. RelaySignIn's test titles name the home signal for what it now means. Co-Authored-By: Claude Opus <[email protected]>
|
Merged through Follow-up from the owner's own test of 0.5.10-preview.22: after a sign-in from Settings in the Mac app, Settings closed (added on purpose in #4435 for a sign-in to the account the PC is already in). Now only the Add a connection sheet closes and Settings stays on Devices and PCs; a sheet opened from the setup checklist still goes to the main screen. No change to the sign-in, the account service calls or any contract. scripts/relay-account-pcs-regression.ts encoded the old behaviour and was updated. Reviewed by the merging session reading the diff (no Codex review: its usage limit lasts until 2026-11-28). Not checked with a real sign-in in the packaged Mac app; the next preview build covers it. |
|
Merged without a CodeRabbit review of the final head (f366f80): CodeRabbit skipped it. The first head was reviewed with no findings; the second commit only updates |
…r admission (#4513) ## Why A phone signed in to the same Ovis account as a PC can open that PC over the relay as an account-joined device. It never scanned the PC's QR code: the account's own list let it in (`account-devices.json`). Found while testing 0.5.10-preview.22: the phone was connected and could drive the PC, but on the PC, Settings → Devices and PCs did not list it ("No devices paired yet."), and the PC's own window showed no "new device" notice when it got in. Cause: `GET /api/devices` answered `DeviceStore.list()`, which reads `devices.json` alone. Account-joined rows never reached it, and no other screen listed them. A list admission publishes its journal notice only to older device rows (`tells`), never to the PC's own window, which therefore heard nothing. ## What changes **1. `GET /api/devices` also lists account-joined rows** (new `DeviceStore.listAccountJoined`, appended in the handler only). - Shape: the same as a paired device, plus one new optional field `through_account: true` on `PairedDevice` (`shared/access.ts`). This is the only contract change. `role: "drive"`, `via_relay: true`, `created_at` = the row's `confirmed_at`, `last_seen_at` = the start (UTC) of `last_signin_day` (the finest time this PC keeps for such a row; the panel shows it as a date, never as "n h ago"). - Listed: a row that stands as admitted here (new read-only `AccountRowSource.standing`): live, or in its 10-second join hold, or in the wait for the first whole read after a start. - Not listed, so never shown as usable: - an expired row (`state === "expired"`, or past `expiresAt(row)` before the expiry timer marked it); - a held row whose hold is over and which the admission guard (`admits()`) now refuses: `access()` refuses it at sign-in (`refused: "admission"`), and `standing` asks the same guard, read only. It comes back to the list if the guard lets it in again; - a stale row (`accountRowStale`, the verdict sign-in uses: removal evidence, a tombstone, a freeze, the lock, a failed deny, unreadable account state). Hidden rather than shown with a state, since `PairedDevice` has no state field and adding one would be a second contract change; - a row whose id or key a `devices.json` row holds (listed once, as that row). - A row waiting for the first whole read after a start is listed; that read asks the guard again (`commitList`, T42), and a row refused there is dropped from `account-devices.json`, so it leaves the list and its notice is taken back (point 3). - Reading the list changes no row: it never calls `access()` (which can end a hold or expire rows). - Caller-specific fields are the same pipeline every row goes through: `current` is `row.id === access.device.id`, so the phone reading the PC's list sees its own row as "This device now"; `connection` comes from the relay sessions map, keyed by the row id; `remote_revoke` from `remoteRevoke()`, which already reads either store (`anyRow`). `not_me_waiting` stays devices.json-only: a block naming a listed key applies on arrival, so it never waits for one (`waiting-block-list.contract.test.ts`). - `account` / `account_key` / `added_by` are not set on these rows. An account-joined key may sign no remove of another device (`removeAuthority`), so Manage account (`offersAccountRemove`) must not offer one from or for it; without these fields `AccountManage` behaves exactly as before. - `PATCH /api/devices/:id` on such a row now answers the same shape (it already renamed it; it now says `through_account` too). **Every caller of `DeviceStore.list()`**, all unchanged because `list()` is unchanged: - `server/index.ts` first-device rule (`otherRows`: `list(null).length`), the recovery preview (`file: "devices"`), the unreachable non-relay devices; - `server/devices.ts` `promote` and `linkAccountKey` (`list(null).find(...)` by id, three places: they answer a devices.json row they just wrote); - `server/relay/service.ts` revoking every relay device of `devices.json`; - `server/account/account-catch-up.ts` (three reads); - `server/pc-add-policy.test-helpers.ts` (test). (`server/seen.ts` `store.list()` is another store.) **Every reader of `/api/devices`**, checked so the new rows are not counted twice or taken for a pairing: - `DevicesPanel`: shows the tag, rename and Revoke as on any row (the server decides who may: an account-joined caller may rename only itself and revoke by admission order, as before). "No devices paired yet." does not show when account rows exist. Revoke all shows only when the list holds a paired row, as before this PR (see Known limits). A row that came through the account is not taken for a pairing: no "Paired: …" line, the code shown is not cleared, and `onDevicePaired` (which closes Connect a phone) is not called. - `SetupGuide` (three "a device paired since the code was shown" watchers, now `pairedSince` in `setupGuideFlow.ts`): ignores account rows, so a QR code shown is never claimed by a device the account let in. `otherDevice` (setup step "phone connected") counts them, as it already counts an account member phone. - `accountQrWatch` / `ConnectPhoneDialog`: `unvouched` ignores account rows (the account vouches for them, so they are never asked about or removed as strays); `addedBy` already needs `account`, which they lack. - `scripts/plugin-link.ts` (`ovis add`): its device reader drops account rows, so it sees exactly the list it saw before. Without this, the new test shows `ovis add` would have revoked an account-joined device as a stray once the PC joined the account. - `pairThisBrowser` reads `current` only; `AccountManage` see above. **2. Devices and PCs** shows such a row with a short tag: "Through your account" (ko 계정으로 연결됨, ja アカウントで接続, zh 通过账户连接), in the existing `devices-kind` pill. The design follows this list's own kind and PC pills (no new component, no new CSS); it is this app's own surface rather than a pattern taken from another coding-agent app. **3. The PC's own window gets a "new device" notice for a list admission, and only it.** - `AccountDeviceStore.commitList` gathers the rows one whole read admits and tells them once, together, through a new optional port `AccountRowPorts.admitted(rows)` (a readmission outside a read is told alone). `server/index.ts` routes it through `DeviceStore.onListAdmissions` to `JoinNotices.addListed`. - It is **not** `announce()` / `onPaired`: no push, and no other device hears it. Every older device already gets the journal's admission notice. The list notice is a `device-paired` event (no new wire field) kept in the waiting-join file with the rows it names; `shownTo` gives it to this PC's own window alone, live (`JoinNotices.onListed` in `machine-pairing-events.ts`, own window only) and when a window opens later, and `POST /api/devices/joins/seen` from any other viewer answers 404, so another device cannot mark it seen. - One whole read raises at most one notice: one device is named; several are "first label +N" (for example "Tablet +1"), in the existing `label`. List notices are kept apart from pairing joins in the waiting file (each kind keeps its newest `WAITING_JOIN_LIMIT`), so they never push out a code pairing's join. - Taken back: the notice stands while one of its rows is listed (`DeviceStore.listsAccountRow`, the same rule as point 1). `DeviceStore.onListedChange` fires after every write of either file (drop, Not me, block, removal, Revoke, promotion, expiry), after a durable safety change (`recheckListedSessions`), and when `access()` refuses a row at the end of its hold. `JoinNotices.settleListed` then takes the notice back from every window (`device-paired-seen`), and names again the rows still listed, if any. - Once per read: a re-read, a republished journal notice, a sign-in, a reconnect and a start (rows read from the file) raise none. A failure to tell is logged and the admission stands. ## What it does not change This gives no device any new right: it only shows rows that could already connect, and tells this PC's own window of an admission that already happened. Who is admitted, every guard and check, `devices.json` and `account-devices.json` formats, the journal notices and the pairing announcement (`announce()`, its push and its waiting joins) are unchanged. Revoking such a row from the list uses the existing `DELETE /api/devices/:id` path (`DeviceStore.revoke` → `anyRow`, deny, drop with the joined ids). The waiting-join file gains an optional `rows` on a list notice only; an older build reading it ignores the field. ## Review An independent review found no HIGH, one MEDIUM and four LOWs. Each one, and how it was resolved: 1. **MEDIUM: the list announcement reached every older device (live, waiting join, push), and another device could mark it seen for the PC's own window.** Fixed as point 3 above: no `announce()`, no push, own window only (live and waiting), 404 for any other viewer marking it seen. Tests: `account-rows-listed.contract.test.ts` ("one whole read's admissions are one notice…": own window yes; an older paired device, the account-joined device, a watch viewer and a Portal viewer no, live and on a later subscribe; `push.devicePaired` and `onPaired` not called; 404 for the member and the joined device, 200 for the own window), `machine-pairing-events.test.ts`, `join-notices.test.ts`. 2. **LOW: a burst of N admissions gave N banners and could push out code-pairing joins.** One notice per whole read ("first +N", no new wire field), and separate limits for list and pairing joins. Tests: `account-devices.test.ts` (one `admitted` call per read with all its rows), `join-notices.test.ts` ("never pushes out a pairing's waiting join"), the contract test ("Tablet +1"). 3. **LOW: the banner was never taken back, and the body said held/waiting rows "become usable without any new admission decision".** The notice is now taken back when its rows are dropped or refused (point 3), and the body now says what happens at the end of a hold and at the first read after a start (point 1). A held row refused by the guard is neither listed nor left announced. Tests: the contract test "Not me takes the notice back…", `join-notices.test.ts` (take back and rename), `account-devices.test.ts` ("a row stands while it is admitted…", including the settle on refusal). 4. **LOW: Revoke all showed for a list of account rows alone, and Revoke all also takes the PC out of its account, which its confirm never says.** Revoke all shows only when a paired row is listed, as before; each account row keeps its own Revoke. The confirm text is an existing gap, listed under Known limits. Tests: `DevicesPanel.account-rows.test.ts`, the demo regression (`demo_devices=account`: no `.devices-revoke-all`). 5. **LOW tests.** "An announcement that fails is only logged" now asserts the announcer was called; "expired … not listed" first asserts the row is listed; the demo regression has a row with three pills ("Phone", "Through your account", "This device now") checked at 390 and 1440 px, en and ko: each pill whole, inside the name, clear of the buttons, nothing past the edge. No overflow was found; at 390 the pills wrap onto their own lines. Closure check: a latent re-entry. If the relay identity changed while a list notice waited, the old rows' `clear()` write settled the notice, whose read called `store()` (`server/account/account-row-source.ts`) again before the new store was open, and looped. No real path reached it (a reset ends the account rows first), but `store()` now refuses to re-enter: a reader called back during the switch sees no rows, and the switch never starts again. Test: `account-devices.test.ts` ("a reader called back from the old rows' clear…"), which overflowed the stack before the guard and ends now. CI and CodeRabbit follow-up: - Integration tests failed in `server/relay/direct.contract.test.ts`: its store double for `handleDeviceRequest` had no `listAccountJoined`. It has one now (no rows). It was the only double passed to the handler; the others pass a real `DeviceStore`. The handler takes the `DeviceStore` class and the double is cast through `unknown`, so no structural type would let the compiler catch the next one. - CodeRabbit (Minor, `server/account/account-devices.ts`): still held after the rework. If the write that starts a row's hold failed after the row itself was written, the row was never told. An admitted row is now told before that write. Test: `account-devices.test.ts` ("a row on disk is told even when the write of its hold fails after it"), red on the old order. - After both: `bun test server/relay/direct.contract.test.ts` and the other files that call the handler directly pass. `HERDR_TEST_SHARDS=4 bun run check integration` (through `dori heavy`) gave 2317 pass, 6 fail; all 6 failures are in `machine-profile.contract` and `reattach.contract`, which fail on `main` too on this PC. `bun run check fast` is green (24095 unit tests). ## Validation - Red first, then green (the review round's new and changed tests were also run against the previous head, where all 12 fail): - `server/account/account-rows-listed.contract.test.ts` (new): listing, `current` and `remote_revoke` for the row's own session, connection by row id, expired, lock and freeze, PATCH and DELETE, who hears the notice, the take-back, once per read. - `server/account/account-devices.test.ts`, `server/join-notices.test.ts` (new), `server/machine-pairing-events.test.ts`. - `src/components/DevicesPanel.account-rows.test.ts` (new), `src/components/ConnectPhoneDialog.test.tsx`, `src/lib/setupGuideFlow.test.ts`, `scripts/plugin-link.test.ts`. - `bun test server/account server/devices.test.ts server/join-notices.test.ts server/machine-pairing-events.test.ts server/machine-events.contract.test.ts server/device-access.contract.test.ts server/access-authority.contract.test.ts server/push.test.ts`: 1581 pass, 0 fail (109 files) - Browser, on this PC (demo only, no herdr session): `scripts/device-security-demo-regression.ts` (with the `demo_devices=account` case; 390 and 1440, light and dark, en and ko), `scripts/settings-rows-demo-regression.ts`, and `checkRelayPanel` from `scripts/relay-panel-regression.ts` (run alone with a small runner, as `ui-regression.ts` imports it and the file has no entry point of its own): all PASS. Run on this PC, not in the CI runner image. - `bun run check fast`: green on the pushed tree (`main` merged in; typecheck, build, 24093 unit tests pass, 0 fail). The server tests and browser scripts above ran before `main`'s newest commit (#4510) came in, which touches none of this PR's code; `account-rows-listed.contract.test.ts` ran again after it: green. - This PR touches `scripts/plugin-link.ts` (`scripts/plugin*`), so it waits for GitHub's own checks rather than a local merge gate. - Skipped: the full integration suite and the browser lanes beyond the scripts above (CI runs them); no check on the Mac or Windows VM (nothing platform-specific). ## Screenshots Before and after at 390 and 1280 px (light) were taken from the demo (`?settings=devices`) and handed over with this PR's report; they are not attached here, because the browser used for GitHub uploads is signed out. Before is `demo_devices=empty`, which is what such a PC showed, since its server never listed the device (the empty-list rendering is unchanged by this PR). After is `demo_devices=account`: "iPhone · Safari" with its "Phone", "Through your account" and "This device now" pills, then "Galaxy S25" with "Through your account", each connected through the relay with its rename and Revoke, and no Revoke all. ## Known limits - An account-joined row's "last seen" is a day, not a time: the PC keeps only `last_signin_day` for these rows. - A stale (frozen, locked, covered) or guard-refused account row is hidden rather than shown with its state. - Existing, not changed here: Revoke all also takes the PC out of its account (`DeviceStore.revokeAll` → `clearAccountBinding`), and its confirm text ("Every paired device loses its pairing access…") does not say so. - A list notice that named several devices and lost some is told again, naming the rest, with a new event id: a window that showed the old one shows the new one in its place. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus <[email protected]>
What changed
A sign-in on Settings → Devices and PCs → Add a connection → Ovis relay to the account this PC is
already in (with its relay on) no longer closes Settings. The Add a connection sheet still closes,
since nothing is left to add there, and Settings stays on Devices and PCs. That page now shows the
account and its PCs. Only a sheet that the setup checklist's Connect your phone opened still goes
on to the main screen after that sign-in, because that flow started from the main screen.
The decision is
closedBySignIn(home, asked)inConnectPhoneDialog.tsx.DevicesPagepasses itconnectAsked(set only by the setup checklist'saskAddConnection, cleared by the page's ownAdd a connection button).
Why
The owner tested the Mac app preview (0.5.10-preview.22). He opened Settings, pressed Continue with
Google, finished in the system browser, and came back to a closed Settings, so he had to open it again
to see the account and its PCs.
Cause:
DevicesPageclosed Settings on purpose (onHome→onClose) for any relay-tab sign-in thatRelayTabreports ashome(an account this PC is already in, relay on). #4435 added that for owner#25 ("sign in again → straight to the main screen without the connect dialog"). Nothing reloads or
navigates the page. The desktop app's loopback sign-in (
desktop.ts), a PC's own window(
ownWindow.ts) and the link page's code (deviceSignIn.ts) all end in the sameonSignedIn(home).The fix keeps #25's "no connect dialog" and drops only the Settings close.
Each way in and out of the account in Settings
E-mail sign-in is not offered (
ACCOUNT_PROVIDERSis GitHub, Google and Apple). The phone app andthe hosted page do not reach this code: there
accountServiceHere()is null, so the sheet gets noaccountand draws no relay-tab sign-in. Their behaviour is unchanged. No change to the sign-initself, to what the account service is asked, or to any HTTP/WS contract.
Validation
closedBySignIninsrc/components/ConnectPhoneDialog.test.tsxfailed as not afunction. The
DevicesPagewiring check insrc/components/AccountPcRows.test.tsxfailed on theold
if (home) { setConnecting(false); onHome(); }. Both pass now, along withsrc/components/RelaySignIn.test.tsx(the owner Open a pane's terminal first, chat on request #25homesignal itself is unchanged).bun run check fast: green.herdr-ci-runner:local, fresh clone of this branch),all exit 0:
settings-pages-demo-regression,settings-palette-search-demo-regression,settings-rows-demo-regression,settings-segmented-demo-regression,cliproxy-settings-regression,setup-row-demo-regression,connect-dialog-scroll-regression,relay-first-link-regression,settings-tabs-regression,settings-unload-regression, andui-contexts-regression. That last one runspush-settings-regression's checks, which do nothingwhen that file runs alone.
relay-account-pcs-regression, which encoded the oldbehaviour by waiting for Settings to detach after a link-page sign-in to this PC's account. It now
waits for Add a connection to close and for Settings to stay on Devices and PCs, signed in with
GitHub and listing the account's PC "Away", which a signed-out Settings does not list. It passes in
the CI runner image (exit 0, through
dori heavy).bun run check fastis green again.RelaySignIn.test.tsxtitles now callhome"nothing is left to add". No other browser scriptwaits for Settings to close after a sign-in: every other
.settings-dialogdetach followsEscape, Close, a tap outside or "Open terminal".
Known limits
case has only the
closedBySignInunit test.connectAskedleft stale is a setup-checklist sheet that is closed and then reopened bythe account QR watch. A
homesign-in there still goes to the main screen, as the setup flow does.🤖 Generated with Claude Code