Skip to content

fix(account): keep a PC that is already in the account bound when Add this PC is pressed again - #4412

Merged
devswha merged 11 commits into
mainfrom
fix/add-this-pc-relist
Nov 21, 2026
Merged

devswha merged 11 commits into
mainfrom
fix/add-this-pc-relist

Conversation

@devswha

@devswha devswha commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • Show the existing “This PC is in your account” state when the PC’s local binding matches the browser’s sign-in. No add flow or directory write is started for that state.
  • The “Turn on the relay and add this PC” button follows the same rule: if the PC has since bound, it shows that state without starting the relay.
  • Re-read local membership after the directory lookup and after a stale-invitation refresh. If the PC has bound in the meantime, show its membership and close the pairing window this attempt opened.
  • The relay returns a window ID on every link open. Automatic Add cleanup closes only that ID if it is still current, so a newer codeless link stays open. A relist that discovers membership releases its own window even if session storage is blocked. Explicit Stop waiting still closes the current window.
  • Renew stale invitations in place with ovis-sh/account#57's POST /v1/pcs/:server_id/refresh. The refresh preserves the listing and its admission; the dashboard uses invited_at for the invitation's countdown.
  • Intentionally omit the raw acct_… identifier from the added state. The localized status is the user-facing confirmation.
  • Leave account PC counts and the account service unchanged.

Only an old service that omits the listing_id field entirely and answers the refresh request with 404 not_found uses the legacy DELETE/PUT fallback. A directory row that carries the field with an unusable value (malformed, null, a number or empty), fresh or stale, is an invalid answer: nothing is refreshed, deleted or written, and the screen shows its existing "could not be listed, Try again" state (a relist retries later). Otherwise the fallback runs, after a fresh /api/account/status read. Its residual race requires a second add to bind the same PC after that read and before the DELETE arrives. It closes when #57 is in production: the supported refresh path does not delete or recreate the listing, including when the endpoint returns 409 listing_changed. An atomic conditional delete for pending listings belongs in the ovis-sh/account add-completion follow-up, not in this PR.

Exported functions and production callers

  • AccountService.refreshPc → src/lib/account/addThisPc.ts:215 (stale invitation).
  • invitationEndsAt → src/lib/account/myPcs.ts:33 (fresh invitation classification), src/lib/relay/dashboard.ts:84 (attention expiry), and src/components/RelayPcTable.tsx:84 (row countdown).
  • The existing listThisPc reports local membership and hands the window ID only to its opening caller in src/components/AccountSection.tsx:436 (scheduled/resumed relist) and :541 (manual/automatic add). The existing reopenAddWindow returns the window ID to :387 (keep the current wait open).

Verification

  • Original test-only commit e6ca1fd3: three expected reds on main, including the unexpected DELETE and PUT; the stale, locally unbound control passed.
  • Review-round test-only commit 336c9bc1: five expected reds on 109330d6, including two real one-press binds cleared by the next snapshot. The periodic-relist and bound relay-button coverage passed on that head and remains covered.
  • Review-round fix 884979af: 306 focused tests passed; repository typecheck passed.
  • Exact-head bun scripts/check.ts fast passed in Docker with --init, a private HOME, and tmpfs: 21,980 passed, 65 skipped, zero failed.
  • Offline browser QA: relay shell (including the six-digit Add this PC flow to Ready), relay-panel regression, and all 67 dashboard checks passed; both browser builds succeeded.
  • Added-state screenshots: English and Korean at 390 and 1440 px, light and dark, under /home/devswha/.cache/ovis-tmp/relay-hub/trial/relist-captures/ (local evidence).
  • Window-ownership round: both real-relay-state regressions failed at 884979af with test-only commit 05d10a84. At 2f0257db, typecheck, all 348 focused tests, and the offline relay panel and six-digit Add this PC browser scripts passed. Docker --init fast passed with 21,982 tests passed, 65 skipped, and zero failed.
  • Malformed-listing round (gate finding DIRECTORY-FALLBACK): test-only commit 9dd00797 failed at 2f0257db on both new cases (listing_id: "invalid" and listing_id: null, each with a structured 404 not_found refresh). A scratch probe on that head saw POST …/refresh, DELETE, PUT and a concurrent one-press bind cleared to null. Fix 034cf1ee: parsePc keeps a present but unusable ID as null (absent stays absent), and listThisPc refuses it before any directory write.
  • Flaky AddThisPc suite: the transient failure came from this PR. realRelay() (added in 05d10a84) starts a real PC whose herdr status reads placed their 10 s timeouts on the suite's fake timer queue, so getTimerCount() === 0 assertions failed by timing. Under the same load (16 parallel × 2), merge-base main passed 0 failures in 32 runs, 2f0257db failed 6–14 of 32, and d4a6eab6 (the file uses unitHerdrOnly(), as other server-backed unit files do) passed 32 of 32.
  • At d4a6eab6: all 350 focused tests passed (the earlier 348 plus the 2 new cases); bun run typecheck and git diff --check passed. Docker herdr-ci-runner:local with --init, a private HOME, tmpfs /tmp and an internal network ran bun scripts/check.ts fast: every step ok, 21,982 passed, 65 skipped, 0 failed. Offline browser scripts in the same image all exited 0: relay-panel regression; dashboard matrix, 67 checks passed; relay shell QA (Add this PC → six digits → approved → Ready; CSP on 32 pages, no violation; no page errors).
  • Fresh-row round (gate at d4a6eab6): test-only commit 0ffd39f3 failed at d4a6eab6 for a 1-second-old row carrying listing_id "invalid", 17 or "": the listing resolved and sent PUT. Fix e02b8fcb moves the unusable-ID refusal after the bound-membership return and before the invitation-age check, so any row with an unusable ID rejects with invalid_answer and no directory write. At e02b8fcb: all 353 focused tests passed (350 plus the 3 new cases); bun run typecheck and git diff --check passed. Docker fast and browser scripts were not rerun this round; CI covers them.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • The app now recognizes when this PC is already linked to the signed-in account and shows its joined status instead of offering to add it again.
    • If the PC becomes linked while an add attempt is in progress, the app updates its status and avoids repeating the add process.
    • The joined status is shown only for the matching signed-in account.
    • Account IDs are no longer displayed in the joined status.

The add-this-PC flow now detects existing account membership during listing and retry paths. When the signed-in account matches, the component displays the joined state and avoids further add actions. The joined-state UI no longer displays the account ID.

Changes: Add-this-PC membership handling

Layer / File(s) Summary
Return membership from PC listing
src/lib/account/addThisPc.ts, src/lib/account/addThisPc.test.ts
listThisPc checks membership while the listing attempt is active. If the PC belongs to an account, it returns membership without deleting the stale entry.
Handle membership in the add flow
src/components/AccountSection.tsx, src/components/AccountSection.addThisPc.test.tsx, src/components/AccountSection.signInAddsPc.test.tsx
The component handles membership during initial checks, relisting, and add attempts. Tests cover the joined state and verify that a binding during a retry prevents directory writes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • devswha/ovis#3088: Defines the waiting and relisting behavior that this change updates when the PC binds to an account.
  • devswha/ovis#3544: Changes the same add-this-PC waiting and retry flow, including related tests.
Merge Risk: Minimal · up to 10933

This change stops the Add this PC flow from relisting a PC that is already in the signed-in account. It shows the existing membership state instead. No concrete merge-blocking risk was found. The PR title must be changed to the required type(scope): summary format before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
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.
Title check Passed The title names the main change: a PC already in the account stays bound when Add this PC is pressed again. This matches the raw summary and the PR objectives, which describe showing the joined state …
Description check Passed The description follows the repository template. It has a Change section that explains the problem and resulting behavior, and a Validation section that lists many checks with results. The Change sect…
Full details: Title check

Explanation

The title names the main change: a PC already in the account stays bound when Add this PC is pressed again. This matches the raw summary and the PR objectives, which describe showing the joined state instead of relisting or writing to the directory. The title is specific and uses the conventional fix(account) prefix.

Full details: Description check

Explanation

The description follows the repository template. It has a Change section that explains the problem and resulting behavior, and a Validation section that lists many checks with results. The Change section does not link a maintainer-agreed issue, which the template asks for on features. This PR is a bug fix, so that link is not required. The description is long and dense, but it covers the required information. Some items in Validation mention the commands run (bun scripts/check.ts fast, typecheck, Docker runs) and the skipped steps (Docker fast and browser scripts not rerun on the last round, deferred to CI).

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • 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 85f8d6c and 109330d.

Files selected for processing: 5

  • src/components/AccountSection.addThisPc.test.tsx
  • src/components/AccountSection.signInAddsPc.test.tsx
  • src/components/AccountSection.tsx
  • src/lib/account/addThisPc.test.ts
  • src/lib/account/addThisPc.ts

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

@devswha devswha changed the title Fix Add this PC relisting an already bound PC fix(account): keep a PC that is already in the account bound when Add this PC is pressed again Nov 21, 2026
@devswha
devswha merged commit 3d372dd into main Nov 21, 2026
24 of 25 checks passed
@devswha
devswha deleted the fix/add-this-pc-relist branch November 21, 2026 11:03
@devswha

devswha commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head e02b8fcbc. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit finished, with no review that names this head.

omo gate (openai/gpt-6.2-astra) CLEAR at e02b8fc; dori CLEAR at e02b8fc; t13r security-triage YES on access at e02b8fc; required checks green. Merged by relay-hub under the lead's 0.5.9 freeze allow-list.

devswha added a commit that referenced this pull request Nov 21, 2026
…and the account as one line in Settings (#4416)

## What changed

The owner asked for adding a PC to read as buttons, not paragraphs
(mockups he approved: before/after at http://100.106.153.26:18731/, real
captures of this branch at http://100.106.153.26:18731/build/).

**Settings → Devices and PCs → Add a connection → Ovis relay** is drawn
by state, buttons only:
- Signed out: the sign-in buttons alone. GitHub, Google and Apple where
the page signs in itself (the desktop app, the PC's own window), each
provider's device page where the account service has no link page, and
the one **Sign in to Ovis** that opens the link page elsewhere (the link
page picks the provider there).
- Signed in, this PC in no account: one full-width **Add this PC to my
account**. With the relay off it also turns the relay on (the old "Turn
on the relay and add this PC"); the device-gate note is its tooltip, and
none on a relay that may not start (serve-only). In one press (step 2)
it then says **✓ Added**; where one press does not apply (step 2 off,
refused), one line names the device to choose Add on, then **Stop
waiting**. No digits paragraph, no app.ovis.sh link, no waiting
sentence.
- Signed in, this PC in the account: **Your account's PCs**, this PC
first with a **This PC** pill, then the account's others, one row and at
most one button each (**Open**, **Add**). This also holds where step 2
is on (`pc_add_from_account`): signed in to the PC's own account the
list shows at once; anyone else still gets "Add from account".
- The phone's QR code is a small **Phone QR code** link under them (no
sentence). The relay's own switch stays in More settings, and on the tab
only while a PC in the account has its relay off.

**Settings → Devices and PCs**:
- Signed out where the relay tab signs in: no account card (also while
the relay's state is still read, so it does not flash in).
- Signed in: one line, **Signed in with GitHub** · **Manage account** ·
**Sign out**, with no account id anywhere.
- **Manage account** opens a sheet (`ManageAccountSheet`) with the ways
to sign in, the plan and **Delete account** at its foot. While a search
runs they are the group's rows, as before.
- No ID line under This PC, and no sentence under the page title.

Copy in en, ko, ja and zh; strings no longer used are dropped from the
dictionaries. DESIGN.md and a changelog fragment are updated. The
one-line account follows the ChatGPT and Claude apps (the signed-in
account as one row with its sign-out, the rest one level down).

## Also in this PR

- **Strict mode** is one row of More settings → Devices and access,
**Strict mode (Linux)** with its switch; turning it on asks in a
confirmation that names what it ends and what it cannot cover (it was a
block of sentences under This PC). No switch where the PC cannot confirm
on its screen (P11), on a PC in no account (P12) or off its own window
(R10).
- **Sign in again from the wait** (owner-approved): when the account
service refuses the one press for the sign-in itself, the wait offers
**Sign in again** once, where the page signs in its own way (desktop
app, the PC's own window). The fresh same-provider sign-in is kept only
for the same account and only while the wait runs; the press is made
again for the wait's own PC with exactly that sign-in. docs/account.md
"Sign in again from the wait".
- relay-hub's hosted Sign out (`fix/hosted-signout-visible`:
`AccountHead`, `useHostedSignIn`, More's Sign out on a phone), which has
no PR of its own, folded into the one-line account and reviewed here.

Based on main `f475c0b96` (#4377 and #4412 merged); the Add this PC
logic is theirs, only what is drawn changed, apart from the
sign-in-again path above.

## Docs

README.md (Add a computer), docs/guide.md (the relay, ways to sign in,
the account's PCs) and docs/account.md (adding a PC, deleting the
account) now name the new controls: **Add this PC to my account** on the
relay tab, **Phone QR code**, **Manage account**. The README change
waits for the owner's word with the rest.

## Validation (head `d9e38524d`)

- `bun run check fast`: passed (exit 0).
- Unit tests touched and added:
`AccountSection.{addThisPc,deleteAccount,signInAddsPc,ownSignIn}` (incl.
sign in again: offer, add, no loop, another account, failure, Stop
waiting in another view, a replaced session, the address answering for
another PC), `ConnectPhoneDialog` (incl. `relayPending`),
`RelayAccountPcs`, `RelaySignIn` and its regression file,
`StrictModePanel` (row, confirmation, P11/P12/R10), `AccountPcRows`,
`addThisPc`, `i18n`.
- Browser regressions in `herdr-ci-runner:local` at this head: listed in
the comment below once the run ends (`device-security-demo` PASS so
far).
- Real captures of this head (ko, light, 1280 and 390):
http://100.106.153.26:18731/build/ (owner OK).
- Reviews: omo gate (two reviewers over five rounds, every reproduced
finding fixed; CLEAR at `dd369b05c`, this head under review); dori
review rounds' findings fixed (stale stack, docs, Manage account for
another account, unreachable Settings detour, relay read failure, Korean
particles).

UI change: waits for the owner's word before merge.

---------

Co-authored-by: sisyphus-dev-ai <[email protected]>
@devswha devswha mentioned this pull request Nov 21, 2026
devswha added a commit that referenced this pull request Nov 21, 2026
Release 0.5.9, on the owner's word (2026-11-21, relayed by the lead:
release once #4377, #4412 and #4416 are merged; he tests on the real
release). Step 2 is on by default from this release (#4377), with the
Add this PC relist fix (#4412) and the relay tab's buttons and one-line
account (#4416). The hosted shell fix for the Android preload failure
(#4413) ships as a new app.ovis.sh build (app.ovis.sh is rolled back to
0.5.7's deployment until then).

- `package.json` and `herdr-plugin.toml`: 0.5.8 -> 0.5.9.
- `REMOTE_BUNDLE_VERSION` 52 -> 53 (`shared/machines.ts`): `server/` and
`shared/` changed since `remote-v52`. After this merges, `remote-v53` is
tagged on the merge commit and the Remote PC bundles run publishes it
before the Release run. Until the Release run is done, nothing touching
`server/`, `shared/`, `bun.lock` or `patches/` merges.
- `CHANGELOG.md`: `bun scripts/changelog-fold.ts 0.5.9` folded the
fragments under 0.5.9 with their PR links. #4412 has no fragment; its
Fixed line was added by hand with its link. No `by @login` credits:
every PR in the section is the maintainer's.
- `release-summaries.json`: 0.5.9 in en, ko, ja and zh: 5 new, 2
improved, 3 fixed. The new lines say what step 2 does for people (sign
in once and the account's PCs open from any device; a 10 s check for a
new device, usually; a notice with Not me on the older devices; PCs not
in an account work as before; how to turn it off with
`OVIS_ACCOUNT_OPENS_ALL=0`). Left out of the summary on purpose (they
stay in the changelog): the desktop app's built-in browser (off by
default), strict mode as one row, and Sign in again in Add this PC's
wait.
- `telemetry/deployed.json` unchanged: release guards agree.

## Validation
- `bun run check fast` on the remote heavy host (hosthatch) at this
release commit on main e00f838: every step ok (unit: 22226 pass, 0
fail, 45 skip).
- `bun test scripts/changelog-fold.test.ts scripts/release-notes.test.ts
server/release-notes.test.ts scripts/release-guards.test.ts`: 60 pass, 0
fail.
- `bun scripts/release-guards.ts --base origin/main`: "Release 0.5.9:
remote bundle, telemetry Worker and release metadata are in order."
- `bun scripts/release-notes.ts 0.5.9` renders the notes (New features
5, Improvements 2, Bug fixes 3).
- Earlier on this branch: an app.ovis.sh incident rollback to 0.5.7's
Pages deployment 44cabf26; this release replaces it with a new build
from release.yml.
- Not run: `check full` (the diff is versions, notes and one constant).
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