Skip to content

fix(cli): ovis approve and ovis add let in a PC's first device with its six digits - #4532

Merged
devswha merged 2 commits into
mainfrom
fix/ovis-approve-first-join
Nov 23, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/ovis-approve-first-join

Conversation

@devswha

@devswha devswha commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

What and why

A PC with no screen could not be used right after ovis add. The press path ends with "Added. Open from My PCs.", but the PC has no account member yet. So the first device that opens it sends a first join: six digits that only the PC's own window may accept (server/relay/session.ts accountJoin returns "first" while hasAccountApprover() is false). ovis approve skipped any join that came with digits and then said "No device is waiting to pair." That left nobody able to let the first device in.

The server already takes a first join from the own window with six typed digits: decideTyped has no first-join check, and POST /api/relay/join {id, digits} reaches it from the terminal, which counts as the own window (loopback, not forwarded, x-herdr-machine). No server change was needed. This PR changes scripts/plugin*.ts, their tests, the docs and one changelog fragment.

Decisions (the lead's, as implemented)

  1. ovis approve handles first joins. Each one is listed with the device's name, the account it comes from (the PC's account, short id) and the time it asked: Pixel asks to open this PC (from Ovis account acct_1a2b3c4, asked at 10:02). Type the six digits Pixel shows (one wrong entry ends this request), or press Enter to skip:. The typed digits go to the existing route (POST /api/relay/join {id, digits}), and the PC compares them.
    • A wrong number says so. The route's own limit applies: one wrong entry ends that join. The command then says how to try again: have the device ask again, then run ovis approve again.
    • Enter by itself skips the join. It keeps waiting until its own deadline.
    • The terminal never shows the digits, although the route lists them for the own window's card. Nothing is approved unless the digits are typed at this terminal.
    • Joins that are not first joins behave as before, with the same prompt, wording and outcomes.
    • With no terminal (stdin not a TTY), each first join is listed with "Run ovis approve in a terminal on this PC and type the six digits shows.", followed by the existing not-a-terminal line. Nothing is sent, and the exit code is 1, as before.
    • --digits is not added. Every request ovis approve answers today needs a terminal, and docs/relay.md and docs/account.md both say that input that is not a terminal approves nothing. A --digits flag would be the first way to approve from a script or an agent. It would also put the digits in shell history and in ps. The existing options pattern does not make it a natural fit.
  2. ovis add goes on after "Added." at a terminal, meaning both stdin and stdout are TTYs:
    • It shows: Added. Open <name> from My PCs on your phone. If the phone shows six digits, type them here (Enter to finish without):.
    • It watches GET /api/relay/joins, the same read ovis approve uses, for up to 10 minutes. Each first join is asked about by name, account and time.
    • Typed digits go to POST /api/relay/join. On success it says <device> is let in; it opens this PC in a moment. and ends.
    • A wrong number says so, and that join ends. When the device asks again, its new request shows in the same run.
    • If a device gets in by itself meanwhile, it says <device> can open this PC now: it got in through your account. with the ovis approve hint, and ends. "By itself" means, in GET /api/devices compared with the snapshot taken before the watch started: a new member row or through_account row, or a known through_account row that signs in during the watch (its last_seen_at goes from null or an older day to a new one, or a live connection appears with a new since). A session that ended, or a member's last_seen_at moving, does not count.
    • The account sign-in ends (after any putListing) before "Added." is printed, so it is not kept during the watch.
    • Enter by itself, Ctrl+C, Ctrl+D and the 10 minutes each end the watch with the hint line below. The exit code is always 0, because the PC is added.
    • A line answers only the question it was typed under, after 1.5 s (DWELL_MS), and the terminal input is discarded as each question first shows. These are the same rules askLine and asking follow.
    • With --account and no terminal it ends after "Added." with one plain line: If your phone asks for six digits when you open <name>, run ovis approve on this PC and type them. That line also ends the watch, ends the "relay did not come online in 30 s" case, and covers an Ovis that answers 404 for /api/relay/joins.
  3. Docs.
    • docs/relay.md, "A PC with no screen", now walks through add → open on the phone → type the digits at the PC's terminal, including the wrong-digit, Enter and timeout endings and the no-terminal line. The step-7 paragraph now names first joins too.
    • docs/account.md says that ovis approve (and ovis add) takes a first join with its digits, and why that is the same authority as the PC's own window.
    • docs/guide.md: the ovis approve comment and the login paragraph are updated.

Who can do what after this

  • Approving a first join from the terminal needs local owner access. The request has to reach this PC's local server as its own window: loopback, not forwarded, and with the access token when one is set. Those are the same people who can open its own window. With no access token, that means any local OS account on that machine; the docs already tell shared machines to set a token.
  • The CLI only approves with typed digits. It approves a first join only when the six digits shown on the asking device are typed, and the server compares them.
  • The asking device needs a fresh admission. It needs an admission at most 10 minutes old, from that PC's account, for its exact key (condition 2 in account.md).
  • No remote party gains anything. The route answers 403 own_window_required to everything else.

Correction to the brief: "only with the six digits" holds for the CLI, not as a server guarantee. The own window, and so anyone with that same local access, could already approve a first join with a tap and no digits (POST /api/relay/join {id, decision: "approve"}, decideOwn). The CLI deliberately uses the stricter typed-digits route. This PR adds no new authority: it uses one that already existed, more strictly.

Review

An independent review of 3c43ca0 found no HIGH. Each finding below was checked against the code first, then fixed in one push.

  • MEDIUM 1, the watch missed the usual case. One press reads the account snapshot before it answers (server/account/one-press.ts), so the phone's through_account row is already known when the watch starts. With fix(relay): a press opens a PC new in the account through the account key #4531 the phone signs in with the account key and no join, no new row appears, and the terminal kept asking for digits. Fixed: a known through_account row now counts as "got in" when it signs in during the watch. GET /api/devices carries two signals for such rows: last_seen_at (the day of its last sign-in here, null before its first; server/devices.ts joinedAsPaired) and, to the PC's own window, connection.since while a session is up. The row counts when either one moves to a new non-null value, and the ending names that device.
    • Unit tests: a known row signing in by connection and by last_seen_at; and a session that ended plus a member in use, neither counted.
    • New contract test against the real server: the phone is on the account's list before the press, so the one-press snapshot admits it. It signs in with its account key once its 10 s join hold is over, and the watch ends. This test fails without the fix (it times out) and passes with it.
  • LOW 2, sign-in kept during the watch. Fixed: linkToAccount has one idempotent signOut (put a taken listing back first, then sign out). addByPress calls it before "Added.", and finally calls it again as a no-op. The harness asserts that /v1/signout came before "Added.".
  • LOW 3, missing hint. Fixed: the "got in through your account" ending now ends with the ovis approve hint.
  • LOW 4, approval wording. Fixed: an approval now says <device> is let in; it opens this PC in a moment., in both ovis approve and the add watch.
  • LOW 5, prompts did not state the limit. Fixed: both first-join prompts now say (one wrong entry ends this request).
  • LOW 6, docs assumed every phone shows digits. Fixed: docs/relay.md and docs/guide.md now say the phone usually opens the PC at once. They add: "If the phone shows six digits instead…, it does when this PC does not list that phone from the account yet (for example the phone whose sign-in created the account, during that sign-in's first day)". The relay.md walkthrough also names the watch's two signals and says the sign-in ends as the PC is added. The changelog fragment is reworded to match.
  • Finding (a) from my first report: the reviewer confirmed it is existing and harmless. A first-join row gets account only from the device's own POST /api/account/link, which the contract test's raw client never sends.

Validation

  • Red first: before the fix, 16 of the new or updated tests in scripts/plugin-link.test.ts failed, and the new contract tests failed.
  • bun test scripts/plugin-link.test.ts: 199 pass. New tests cover:
    • approveJoins with first joins: name, account and time; no digits shown; all six approve; wrong digits; Enter skips; account unknown; a members join beside it; no terminal.
    • The add watch: approve by typed digits; wrong then retry; Enter; a line too soon and a line that is not digits; a device that got in through the account; 10 minutes; Ctrl+C; an Ovis without the route.
    • Updated endings of the existing press tests, and the --account no-terminal hint line.
  • bun test scripts/plugin-link.contract.test.ts: 6 pass, against a real PC server and the fake account service:
    • ovis add --account at a terminal: the PC is added in one press; a phone sends a real first join through the relay (approve_on: linux); the command asks without showing the digits; the typed digits let the phone in (AUTH_OK, key stored).
    • ovis approve (approveJoins against the real routes): Enter leaves the join waiting; wrong digits end it (auth_failed); the same device asks again and its digits let it in.
  • bun test scripts/plugin.test.ts -t "pair --approve": 12 pass. New tests run the real CLI against a fake PC:
    • at a real terminal (script): a first join approved with typed digits, the next skipped with Enter, the screen never showing the digits;
    • wrong digits;
    • piped stdin: the listing plus the instruction, nothing sent.
    • The existing Make terminal touch scrolling work on phones #28 members-join tests still pass.
  • bun run typecheck: clean.
  • After the review: scripts/plugin-link.test.ts 201 pass, scripts/plugin-link.contract.test.ts 7 pass, scripts/plugin.test.ts -t "pair --approve" 12 pass, scripts/conventions.test.ts pass, bun run typecheck clean, and dori heavy approve -- bun run check fast green.
  • Before the review: dori heavy approve -- bun run check fast: green. The first run caught two fixed sleeps in scripts/plugin.test.ts without a // fixed wait: note; they now have one.
  • Skipped: screenshots (a CLI change with no UI) and browser regressions (no shared UI component touched). Windows and macOS were not run locally; the new script-based tests skip on Windows like the existing ones.

Known limits

  • ovis approve is one pass over the joins it read. After a wrong entry, run it again once the device asked again. ovis add's watch picks up the new request by itself.
  • A row of the account's list that already signed in here before the watch started (same day, no new session) gives no new signal. The watch then waits until Enter, Ctrl+C or the 10 minutes, and says how to finish.
  • The watch reads GET /api/relay/joins and GET /api/devices on loopback every 2 s for at most 10 minutes.
  • This PR touches scripts/plugin*, so it waits for GitHub's checks and an independent review.

🤖 Generated with Claude Code

…ts six digits

A PC added in one press has no account member yet, so the first device that
opens it sends a first join, which only the PC itself may let in. On a PC with
no screen nobody could: `ovis approve` skipped joins that carry digits and said
no device was waiting.

- `ovis approve` now asks about each first join by its device, its account and
  when it asked, and lets it in once the six digits the device shows are typed
  (POST /api/relay/join, which compares them; one wrong entry ends that join).
  It never shows the digits. Without a terminal it lists the join with the way
  to let it in and approves nothing. Members joins are asked as before.
- `ovis add` at a terminal goes on after "Added." and watches this PC's joins
  for up to ten minutes, letting the first device in by its typed digits; it
  ends on Enter, Ctrl+C, Ctrl+D, the ten minutes, or a device that got in
  through the account. Without a terminal it says to run `ovis approve`.
- docs: relay.md walks through add, open on the phone, digits typed at the PC;
  account.md says why the terminal holds the own window's authority.

Co-Authored-By: Claude Opus <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

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
Summary

Summary by CodeRabbit

  • New Features

    • First-time phone access can now be approved from the terminal by entering the six-digit code shown on the phone. Prompts identify the device, account, and request time without displaying the code.
    • After adding a PC, terminal users can approve a waiting phone immediately. Non-terminal users receive instructions for completing approval.
    • Incorrect codes end the request; the phone can request access again.
  • Documentation

    • Updated command guides to explain first-join approval, account joins, and the available approval steps.

The change adds terminal approval for first joins using the six digits shown on the joining device. ovis approve handles waiting joins, and ovis add can watch for first joins after adding a PC. Tests and documentation cover both flows.

Changes: First-Join Approval

Layer / File(s) Summary
Approve first joins from the terminal
scripts/plugin-link.ts, scripts/plugin.ts, scripts/plugin-link.test.ts, scripts/plugin-link.contract.test.ts, scripts/plugin.test.ts, docs/account.md, docs/guide.md, docs/relay.md
approveJoins now prompts for first-join digits without showing them and distinguishes first joins from member joins. ovis approve passes account and command context. Tests cover correct, incorrect, and skipped entries, as well as non-terminal behavior.
Watch for first joins after add
scripts/plugin-link.ts, scripts/plugin-link.test.ts, scripts/plugin-link.contract.test.ts, docs/guide.md, docs/relay.md, changelog.d/ovis-approve-first-join.md
After a successful add, the command watches for first joins when terminal input is available. The watcher handles digit entry and early exits. Tests and documentation describe the post-add flow and its fallback instructions.

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

Change: Bug fix

Possibly related PRs

  • devswha/ovis#4435: Defines the own-window authority required to approve a PC’s first phone.
  • devswha/ovis#4514: Changes the ovis add flow that this change extends after “Added.”
  • devswha/ovis#3586: Defines ovis add and --approve pairing behavior that overlaps with the typed-digit flow.
Merge Risk: Low · previous review 3c43c

This change lets a PC added in one press approve its first device from the terminal using the six digits shown on that device. The only open concern is a minor edge case at the end of the ten-minute watch, where an answer typed just before the limit may complete a few seconds after it. It is low risk and the PR is mergeable.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: ovis approve and ovis add now let a PC's first device join with its six digits. It is specific, single-sentence, and matches the changeset (plugin-link, plugin, do…
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.
Description check Passed The description follows the template. It has a Change section that explains the problem, the decisions, and the resulting behavior. It has a Validation section that lists the commands run, their resul…
Full details: Title check

Explanation

The title names the main change: ovis approve and ovis add now let a PC's first device join with its six digits. It is specific, single-sentence, and matches the changeset (plugin-link, plugin, docs, changelog).

Full details: Description check

Explanation

The description follows the template. It has a Change section that explains the problem, the decisions, and the resulting behavior. It has a Validation section that lists the commands run, their results, and the checks skipped (screenshots, browser regressions, Windows and macOS). The author did not link an issue. The template asks for a link only when a maintainer agreed to a feature. This PR is a bug-fix style change to an existing feature, so the omission does not block the check. The description is long, but it covers all required parts.

Finishing Touches

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

scripts/plugin-link.ts-1700-1700: 1

1700-1700: Minor · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Check the watch deadline before processing an answer.

If the final wait resumes at or after stopAt with six digits queued, Line 1650 submits the approval and returns before this check runs. The watch can therefore approve a request after its ten-minute limit.

Check the deadline before draining input and before submitting approval. Keep answers processed before the deadline valid.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 08d4578 and 3c43ca0.

Files selected for processing: 9

  • changelog.d/ovis-approve-first-join.md
  • docs/account.md
  • docs/guide.md
  • docs/relay.md
  • scripts/plugin-link.contract.test.ts
  • scripts/plugin-link.test.ts
  • scripts/plugin-link.ts
  • scripts/plugin.test.ts
  • scripts/plugin.ts

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

Review follow-up for #4532.

- One press reads the account's list before it answers, so the phone that
  pressed Add is a known account row when the watch starts, and it usually
  opens the PC with the account key and no join. The watch now counts a known
  `through_account` row as got in when it signs in during the watch: its
  `last_seen_at` or its live `connection.since` moves to a new value in
  GET /api/devices. That ending names the device and says how to let a phone
  in later with `ovis approve`.
- The account sign-in ends (after any listing goes back) before "Added.", not
  up to ten minutes later as the run ends.
- An approval says "<device> is let in; it opens this PC in a moment.", and
  both first-join prompts say one wrong entry ends the request.
- docs: a phone usually opens the PC at once; the six digits come only when the
  PC does not list that phone from the account yet.

Co-Authored-By: Claude Opus <[email protected]>
@devswha
devswha merged commit 6b2d123 into main Nov 23, 2026
16 of 17 checks passed
@devswha
devswha deleted the fix/ovis-approve-first-join branch November 23, 2026 20:38
@devswha

devswha commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head b0292f2b6. 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 said it did not review (a limit or a skip) since this head.

Found by the r14 device pass: a PC with no screen added by ovis add ended "Added." but the first device that opened it could not be let in (a first join needs the PC's own window; ovis approve dropped joins that carry digits). Now ovis approve takes a first join when the six digits the device shows are typed at the PC's terminal, and ovis add goes on after "Added." to do the same for up to ten minutes, ending when a device gets in through the account. No server change and no new authority: the terminal already reached the join route as the PC's own window, which can approve a first join with a tap; the CLI only ever sends digits typed at a terminal, and approves nothing without one. Independent review by an Opus reviewer agent (no Codex review: its usage limit lasts until 2026-11-28): no HIGH; one MEDIUM (the add watch missed a phone that signs in through the account, the normal case after #4531) fixed with a contract test on a real PC server; LOWs fixed (the sign-in ends before the wait, wording). The rework was read by the merging session. Docs name "the sign-in that created the account, in its first day" as the case where digits appear; that example must change when the account service stops holding that sign-in back. Not run against the real or staging account service or a real phone; the next preview's recheck covers it.

@devswha

devswha commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

Merged without a CodeRabbit review of the final head (b0292f2): CodeRabbit skipped it. An independent reviewer agent reviewed the change (Review section in the PR body); the rework was read by the merging session.

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