Skip to content

feat(install): an ovis command, and --add to add the PC to your account at the end of the install - #3542

Merged
devswha merged 10 commits into
mainfrom
feat/install-ovis-command
Nov 10, 2026
Merged

devswha merged 10 commits into
mainfrom
feat/install-ovis-command

Conversation

@devswha

@devswha devswha commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

What

Adding a PC to an account from its terminal meant finding the plugin's folder and typing bun <that folder>/scripts/plugin.ts link. Now:

  • The installer (Linux and macOS) writes an ovis command into ~/.local/bin: ovis add, ovis pair, ovis status. It holds no path of the install; each run it looks up the herdr plugin (devswha.ovis, or the id before the rename) and, when herdr lists none, Ovis on herdr-core in ~/.local/share/ovis/app with the settings and state dirs its service gives it. An ovis the installer did not write (no mark on its second line, a link, a folder) is left alone, and the installer says so. Another ovis elsewhere on the PATH does not lose its name to the install: where ~/.local/bin comes before it no launcher is written; where it comes first the launcher is written, and the installer says which one the name runs and that the launcher takes the name once ~/.local/bin comes first. On a plugin checkout from before link (first installed before v0.5.0), ovis add runs the release that Settings → Updates installed for that checkout and port; where no installed release can add a PC it says to update.
  • curl -fsSL https://ovis.sh/install.sh | sh -s -- --add (or OVIS_ADD=1) ends the install with the add step, reading its answers from /dev/tty. It runs only at a terminal that can be answered at, in its foreground, while the app runs, and never under OVIS_NO_OPEN; anywhere else (a script, a background job, a fresh PC whose herdr is not started yet) the installer prints the command to run. A failed or interrupted add does not fail the install.
  • The installer's last lines name ovis add (by its path when ~/.local/bin is not on the PATH) and say that on a PC other people log in to, OVIS_TOKEN is set first. With --add at a terminal that line is printed before the add starts.
  • An unknown installer option fails with the usage before anything is installed.
  • Windows: scripts/plugin.ps1 passes a command's flags on (plugin.ps1 link --code) instead of dropping them. No launcher on Windows yet.

How

install.sh gains release_js, quoted, launcher_text, find_other_ovis, write_launcher, ovis_command, find_add_name, add_command, in_foreground, add_pc, token_line and closing_lines. The launcher is written to a mktemp file beside its target and moved over it. A release from before add/login is told by grepping the running release's scripts/plugin.ts for COMMAND_ALIASES, and is run as link; with neither, the installer and the launcher say to update in Settings → Updates instead of naming a command. The release that runs is found by release_js, JavaScript that the installer (running_code) and the launcher both run under Bun, the way scripts/plugin.ts finds it: the settings from the shell, then the plugin's env and .env files (read, never run; .env wins); the state dir (OVIS_STATE_DIR, else under XDG_CONFIG_HOME or ~/.config); the port (PORT, else <state>/plugin-port, else 7317); and only updates/<sha256(root:port)[:16]>/current.json. The launcher uses it only for a checkout from before link; a newer checkout's own script hands on by itself, and --add runs that script. Paths in printed commands are single-quoted where a shell would split them. Docs (docs/guide.md, docs/relay.md) use ovis add; the guide's Uninstall line removes only a launcher with the installer's mark.

Difference from the plan: the plan had the launcher look at the herdr-core checkout first. It looks at the herdr plugin first (see Review, finding 4), which is the order the installer itself enforces: with a plugin listed it never installs herdr-core's Ovis.

Review

An independent review of the first commit said fix-then-ship, with four low findings; all four are fixed in the second commit.

  1. The OVIS_TOKEN line came after --add had already added the PC: real. add_pc prints it before plugin.ts add starts and closing_lines leaves it out for that run; the test asserts the order and that it is printed once.
  2. write_launcher's bare rm -f could end the install under set -e (ovis.new a folder): real. Now rm -f … 2>/dev/null || true; a test covers the folder, a read-only ~/.local/bin and a .local that is a file.
  3. The release-detection greps were tested only against a stand-in: real. A test reads the real scripts/plugin.ts for COMMAND_ALIASES, "link" and "phone", and checks install.sh greps those words.
  4. The launcher ran an earlier herdr-core checkout while the installer had just set up the plugin: real. The launcher prefers a listed plugin and falls back to the checkout; the installer's "also runs on herdr-core" notice says the ovis command runs the plugin; a test covers both present, and the plugin removed again.

The merge pass's two reviews of 46f5188 (two medium, five low) are fixed in aa52f2a; each item and its test is in the comment of that push.

Its reviews of aa52f2a (one high: the launcher and the installer ran whichever update folder was listed last; one medium: the plugin's env/.env settings were ignored; three low: the Uninstall line, unquoted paths, the "never hidden" wording) are fixed in bf909ce; each item and its test is in the comment of that push.

Validation

  • bun run check fast: every line ok at bf909ce (workflow syntax, generated types and themes fresh, typecheck, build, unit tests 14835 pass / 0 fail / 51 skip in 888 files).
  • bun test scripts/install-ovis-command.test.ts: 39 pass. The tests of the last round were written first: against aa52f2a's install.sh the file gives 32 pass / 7 fail.
  • sh -n and dash -n on install.sh and on the launcher it writes.
  • Every installer run is in a throwaway HOME (the test file's stand-in PCs).
  • Not run: browser regressions (no rendered component changes), a real install on a fresh PC, macOS (the "at a terminal" tests need util-linux script and are skipped there), native Windows (scripts/plugin.ps1 and scripts/windows-plugin.test.ts wait for the Windows job), and a real ovis add against an account. shellcheck is not installed on this host, so install.sh was not linted locally.
  • Touches install.sh and scripts/plugin.ps1, so GitHub's macOS and Windows jobs check it and it waits for GitHub's checks rather than a local merge gate.

Needs a real review: --add starts the account sign-in and the PC's admission from the installer, and the launcher decides which install's state and token ovis add and ovis pair act on.

🤖 Generated with Claude Code

devswha and others added 4 commits November 10, 2026 14:14
… window and checks the account it joined

`bun scripts/plugin.ts add` and `login` run `link` (COMMAND_ALIASES). The re-exec into the
active release still passes the literal "link", the one name an older release knows.

While link waits for the device that adds this PC:
- it asks for the approve-here window again every 30 seconds (the window route alone, with
  x-ovis-local-only, no directory write), so a server restart no longer leaves it closed
  until the nine-minute renewal;
- it stops after 30 minutes with exit 1.

It reports success only when /api/account/status names the account that signed in and
`enrolling` is no longer true; while enrolling it says so once and keeps waiting. A PC that
ended in another account is reported with both ids and the Revoke all step, exit 1. A PC
already in an account is named by the start of that account's id rather than as "your account".

Who approves the adding device is unchanged: the pairings loop and its y/N prompt.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… the 30 minutes, and cleans up after a mismatch

- A local call that gets no answer (connection refused, a hang) is no longer the end of the
  command: the wait loop keeps the sign-in, polls on, and asks for the approve-here window again
  with the first call the server answers.
- The window is asked for only until ten minutes before the run's end, so the server's
  ten-minute window never outlives a run that reaches its 30 minutes. The directory renewal in
  those minutes reuses the entry it already has instead of asking for the window.
- Run on a PC that is in an account whose other devices are still being brought in, it waits for
  them (no sign-in needed) instead of exiting 0, and the 30-minute stop says so in that state.
- On an account mismatch the PC is taken off the list of the account that signed in, and the PC is
  told the account it is in for its relay pass.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…nt at the end of the install

install.sh writes a small `ovis` launcher into ~/.local/bin. It bakes in no
path: each run it finds Ovis on herdr-core (its checkout, with the dirs its
service gives it) or the herdr plugin, and runs that scripts/plugin.ts, so
`ovis add`, `ovis pair` and `ovis status` work and keep working after an
update or a reinstall. A file of that name the installer did not write is
left alone, with a notice.

`curl -fsSL https://ovis.sh/install.sh | sh -s -- --add` (or OVIS_ADD=1) ends
the install with the add step, read from /dev/tty. It runs only at a terminal
that can be answered at and never under OVIS_NO_OPEN; anywhere else the
installer prints the command to run. An unknown option fails with the usage
before anything is installed. The last lines name `ovis add` and say to set
OVIS_TOKEN first on a PC other people log in to.

On Windows, scripts/plugin.ps1 passes a command's flags on (link --code) on
both of its paths, and refuses anything that is not a plain --flag.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e ovis command run the plugin over an old herdr-core checkout

- --add at a terminal prints the OVIS_TOKEN line before the add step starts,
  once, instead of after the PC is already in the account.
- The launcher looks for the herdr plugin first and the herdr-core checkout
  second, as the installer does: a checkout left beside a plugin is an earlier
  install, and `ovis` no longer addresses it.
- A launcher that cannot be written (ovis.new is a folder) no longer ends the
  install under set -e.
- A test ties the release-detection greps to the real scripts/plugin.ts.

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

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added an ovis command for checking status, pairing devices, and adding a PC to an account on Linux and macOS.
    • Added add and login commands for linking a PC, with support for pairing without a screen and clearer account and enrollment status.
    • Installers can optionally start the account-linking flow; existing unrecognized ovis commands are preserved.
    • Windows command launchers now forward supported flags.
  • Documentation
    • Updated the setup and pairing guides with CLI usage, installation options, and account-linking steps.

The plugin adds add and login aliases for link and updates account-enrollment handling. The installer can create an ovis launcher and optionally run account setup. Documentation and tests cover the commands, installer behavior, and Windows flag forwarding.

Changes: Account linking and command aliases

Layer / File(s) Summary
Account-linking aliases and enrollment flow
scripts/plugin-link.ts, scripts/plugin.ts, scripts/plugin-link.test.ts, scripts/plugin.test.ts, docs/relay.md, docs/guide.md, changelog.d/cli-add-login.md
add and login map to link. The flow handles server outages, approval-window renewal, account enrollment, timeouts, and account mismatches. Tests and documentation describe the command and its outcomes.

Installer launcher and optional account setup

Layer / File(s) Summary
Installer launcher and optional account setup
install.sh, scripts/install-ovis-command.test.ts, scripts/install-star.test.ts, scripts/plugin.ps1, scripts/windows-plugin.test.ts, docs/guide.md, docs/relay.md, changelog.d/install-ovis-command.md
The installer creates a marked ovis launcher when the destination is available, and supports --add and OVIS_ADD=1. The launcher locates an installed plugin or checkout. Windows launchers forward supported flags. Tests and documentation cover these behaviors.

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

Change: Feature

Possibly related PRs

  • devswha/ovis#3539: Adds the add and login aliases and changes the link approval and enrollment flow.
Merge Risk: Minimal · up to ce109

The change adds the ovis launcher and the add/login aliases. The supplied evidence shows no concrete merge-blocking problem. Native Windows and macOS were not exercised, which is normal validation uncertainty.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly identifies the new ovis command and the installer’s optional --add behavior.
Docstring Coverage Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
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 clearly explains the change and resulting behavior, and it lists validation performed and skipped. It does not link an issue where a maintainer agreed to the feature, and it does not s…
Full details: Docstring Coverage

Explanation

Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 8 files. (5 skipped: 5 unsupported.)

Full details: Description check

Explanation

The description clearly explains the change and resulting behavior, and it lists validation performed and skipped. It does not link an issue where a maintainer agreed to the feature, and it does not state contract-test coverage for the API-related changes.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f885760 and ce1097c.

Files selected for processing: 13

  • changelog.d/cli-add-login.md
  • changelog.d/install-ovis-command.md
  • docs/guide.md
  • docs/relay.md
  • install.sh
  • scripts/install-ovis-command.test.ts
  • scripts/install-star.test.ts
  • scripts/plugin-link.test.ts
  • scripts/plugin-link.ts
  • scripts/plugin.ps1
  • scripts/plugin.test.ts
  • scripts/plugin.ts
  • scripts/windows-plugin.test.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.

Base automatically changed from feat/cli-add-login to main November 10, 2026 09:22
…mand

# Conflicts:
#	changelog.d/cli-add-login.md
#	docs/guide.md
#	docs/relay.md
#	scripts/plugin-link.test.ts
#	scripts/plugin-link.ts
@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying ovis with  Cloudflare Pages  Cloudflare Pages

Latest commit: bf909ce
Status: ✅  Deploy successful!
Preview URL: https://c61298cb.ovis.pages.dev
Branch Preview URL: https://feat-install-ovis-command.ovis.pages.dev

View logs

…r a running app

Review findings on the ovis command and the installer's --add step:

- The launcher ran herdr's checkout, which stays at the version first
  installed: on one from before `link`, `ovis add` ended in a usage line
  while the installer named it. For add, login and link the launcher now
  finds the running release as running_code does and runs that; where no
  installed release can add a PC, it and the installer's closing lines say
  to update instead of naming a command that fails.
- --add ran the add step while the app was down (a fresh PC whose herdr the
  installer cannot start). It now runs only when status says running;
  otherwise the closing lines say what to run once the app is up.
- The launcher is written through mktemp, so a file or link called
  ovis.new in ~/.local/bin is never written through, replaced or deleted.
- --add checks it holds the terminal's foreground before the add step reads
  there: a background install prints the hint instead of being stopped.
- Without a launcher of the installer's, the closing line names the running
  release's script under the name that release knows (link or add).
- Another ovis elsewhere on the PATH is never hidden: where ~/.local/bin
  comes before it no launcher is written, and either way the installer says
  which one the name runs.
- The guide's Uninstall removes ~/.local/bin/ovis.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Fixes for the merge pass's review of 46f5188 (both reports), pushed as aa52f2a. Each has a test in scripts/install-ovis-command.test.ts that fails without it (checked by reverting each fix alone).

MEDIUM

  1. ovis add exited 2 on a plugin checkout first installed before v0.5.0 (before link), while the installer named it: fixed. For add, login and link the launcher now finds the release that runs, as running_code does (current.json under the app's state dir whose source_revision is the checkout's HEAD), and runs that one under the name it knows. Where no installed release can add a PC, the launcher says in one line to update in Settings → Updates (exit 1), and the installer's closing lines say the same instead of naming ovis add. Tests: "on a checkout from before link, runs the release Settings → Updates installed", "says to update, in one line, where no installed release can add a PC", "says what to run on a release from before both".
  2. --add ran the add step while the app was down (a fresh PC whose herdr the installer cannot start): fixed. add_pc runs the step only when plugin.ts status says running; otherwise the closing line is "the app is not running yet, so this PC was not added to your Ovis account. Once it runs, run in a terminal on this PC: ovis add". The test's stand-in add step now fails while the app is down, as the real one does, and its herdr stand-in runs only while the app does. Test: "does not start the add step while the app is not running, and says what to run once it is".

LOW
3. Launcher temp file (ovis.new followed a link, replaced or deleted a file of that name): fixed with mktemp "$BIN_DIR/.ovis.XXXXXX"; only that file is removed on failure. Test: "is written beside the launcher under a name of its own, so a file called ovis.new is not touched".
4. A backgrounded --add install stopped by the terminal: fixed. in_foreground (perl's tcgetpgrp, as the star question checks; ps -o tpgid=,pgid= without perl) runs before the add step; in the background the hint is printed. Test: "does not read the terminal from the background, where that would stop the install" (bash job control under script(1)).
5. The fallback command without a launcher of ours: fixed. It is now the running release's script under the name that release knows (bun <release>/scripts/plugin.ts link or add), or the update line when it knows neither. Test: "the installer names a command that adds the PC, whichever release runs and whoever owns ovis", which also runs the printed command.
6. Another ovis elsewhere on the PATH: fixed. Where ~/.local/bin comes before it, a new launcher would take its name, so none is written and the installer says so; where the other one comes first (or ~/.local/bin is not on the PATH), the launcher is written, the installer says which program the name runs, and the closing line names ours by its path. A launcher of ours that is already there is kept, with a line saying it comes first. Test: "never takes the name of another ovis on the PATH, and says which one the name runs".
7. Uninstall docs: rm -f ~/.local/bin/ovis added to the guide's Uninstall. Test: "the guide's Uninstall removes the launcher".

Not changed: scripts/plugin.ps1 (no finding against it; the reviewer's note that $ lets a trailing newline through is reachable only by a user's own call).

Validation: bun run check fast every line ok (unit 14527 pass / 0 fail / 50 skip in 879 files); scripts/install-ovis-command.test.ts 34 pass, scripts/install-star.test.ts 41 pass; install.sh parses under sh and dash (-n). Not run: shellcheck (not installed here), macOS (the "at a terminal" tests need util-linux script and are skipped there; in_foreground's perl branch was checked by hand on Linux only), native Windows, a real install or a real ovis add. This PR touches install.sh and a .ps1, so GitHub's macOS and Windows jobs are what finally check it.

devswha and others added 4 commits November 10, 2026 21:42
… and port, read with the plugin's settings

The launcher and the installer took whichever updates/*/current.json the listing gave last that
named the checkout's commit. A second folder (another port, another checkout at the same commit)
made ovis add run a stale release or ask for an update that was already there. Both now find the
release as scripts/plugin.ts does (release_js): the settings from the shell, then the plugin's env
and .env files; the state dir; PORT, the saved plugin-port, or 7317; and only
updates/<sha256(root:port)[:16]>/current.json.

- the installer's --add and its closing line use the checkout's own script where it knows link,
  and the running release only for a checkout from before it
- printed paths are quoted where a shell would split them (a home directory with a space)
- the guide's Uninstall line removes only the installer's launcher
- the installer and the docs say that another ovis keeps the name only until ~/.local/bin comes
  before it on the PATH

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Fixes for the merge pass's two reviews of aa52f2a, pushed as bf909ce (one fix commit, one line for the conventions list, and a merge of main). Round one's fixes are untouched.

1. HIGH: ovis add and --add ran whichever updates/*/current.json the listing gave last — fixed.
The launcher and the installer's running_code no longer scan updates/*. Both run one piece of JavaScript, release_js in install.sh (the launcher carries a copy), which picks as scripts/plugin.ts does (activePluginScript, updateStateDir): only updates/<sha256("<root>:<port>")[:16]>/current.json, taken while it names the checkout's commit and a release-* folder of its own; the port is PORT, else <state>/plugin-port, else 7317. The hash comes from Bun's node:crypto, which both already need, so no sha256sum/shasum is involved. In add_pc, the installer now runs the checkout's own script where it knows link (it hands on by itself), and the exact pick only for a checkout from before link; the closing line names the same script.
Tests: ten update folders for one checkout (other ports, another checkout at the same commit) with the right one in the middle; only a stale folder for another port (the checkout itself runs, so ovis add says to update and runs nothing); plugin-port; PORT over plugin-port; and the pick compared with the real activePluginScript for four ports. A third test covers add_pc's choice of script.

2. MEDIUM: the plugin's env / .env settings were ignored — fixed.
release_js reads them as scripts/plugin.ts does (readEnvFile, mergeEnvLayers, defaultStateDir): the folder is HERDR_PLUGIN_CONFIG_DIR, else what herdr plugin config-dir names for either id, else ~/.config/ovis; KEY=value lines with comments, blanks and quotes, read and never run; .env over env over the shell's own, each layer with its HERDR_WEB_* names mapped first. So OVIS_STATE_DIR, HERDR_WEB_STATE_DIR, PORT and XDG_CONFIG_HOME in those files are honoured, and the default state dir is the old name's only while that holds state of its own. On herdr-core the installer now looks for the running release after it has set the service's config dir.
Tests: each variable, the precedence (shell, then env, then .env), the old name in a file over the new name in the shell, the old plugin id's folder, the old state dir name, and a settings file holding $(…), backticks and a bare command that must not run.

3. LOW: the guide's Uninstall line removed an ovis of the user's own — fixed.
The line removes ~/.local/bin/ovis only when it is not a link and its second line is the installer's mark, the same test write_launcher uses. The test pastes the guide's line in a throwaway HOME: the installer's launcher goes; a file of the user's own and a link stay.

4. LOW: printed commands broke with a space in HOME — fixed.
ovis_command prints the launcher's path and the script's path through quoted, which single-quotes a path holding anything a shell reads (and escapes a '); a plain path is printed as before. Tests: a HOME with a space and an apostrophe, both printed forms run under sh -c, and the whole installer run in a HOME with a space, whose last line then runs.

5. LOW: "never hidden" did not survive ~/.local/bin being put first — wording corrected, behaviour unchanged.
The installer's line now ends "…this installer's is <path>, which takes the name once ~/.local/bin comes before it on your PATH"; the guide and the changelog fragment say the same instead of "never replaced or hidden". Not changed: the installer still writes the launcher beside another ovis that comes first on the PATH. Refusing to write it whenever a profile mentions .local/bin would leave those users with no command at all, so the choice is to say what happens.

Also: scripts/conventions.test.ts lists scripts/install-ovis-command.test.ts among the files that may name a HERDR_WEB_* setting (it tests the old state dir name).

Checks

  • bun run check fast (through dori heavy): every line ok at bf909ce — workflow syntax, generated types and themes fresh, typecheck, build, unit tests 14835 pass / 0 fail / 51 skip in 888 files.
  • bun test scripts/install-ovis-command.test.ts: 39 pass. Written first: on aa52f2a's install.sh the same file gives 32 pass / 7 fail (the six new tests and the reworded PATH line).
  • sh -n and dash -n on install.sh and on the generated launcher; busybox sh -n on the launcher.
  • Every run used a throwaway HOME under ~/.cache/ovis-tmp/fix2-3542; install.sh itself ran only inside the test file's stand-in PCs.
  • Not run: shellcheck (not installed here), macOS, native Windows, a real install, a real ovis add. This PR touches install.sh and scripts/plugin.ps1, so GitHub's macOS and Windows jobs are the ones that check it; it does not qualify for the local merge gate.
  • main is merged in at 62a5192; 8ffa66a (fix(appearance): follow-ups on imported themes from the #3547 review #3588, themes) landed while the checks ran and is not in this push.

@devswha
devswha merged commit b8c5386 into main Nov 10, 2026
24 of 26 checks passed
@devswha

devswha commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head bf909ce0a2e7 as b8c53860809c on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

Three review rounds (Claude Opus 5.5 and Codex Terra each); both CLEAR at this head. The release an ovis add runs is now picked exactly as the server and plugin.ts pick it (compared line by line), settings files are read, and the installer's own tests run in throwaway HOMEs.
For the session's one security follow-up PR: buffered terminal input can approve a device during --add (the #3581 family). On its after-release list: take realpath of the checkout root when hashing (a HOME reached through a symlink misses the running release), the fallback add command under herdr-core settings, a Bun not on the PATH.

@devswha
devswha deleted the feat/install-ovis-command branch November 10, 2026 18:19
devswha added a commit that referenced this pull request Nov 10, 2026
…d without the owner meaning it (#3609)

## What

Eleven follow-up findings, in two groups: five across the onboarding
surfaces (items 1 to 5), and six about how a terminal reads a person's
answer to a request (items 6 to 11, following #3581).

### Items 1 to 5

Five follow-up findings from the reviews of pull requests that are now
in main. Each is a way a device could be approved, or a PC or device
added under an account, without the owner meaning it.

1. **Follows #3542 (`install.sh --add`).** Lines typed while the
installer worked, or pasted after the install command, were still in the
terminal's input when the add step began to read from it. A `y` and
Enter typed ahead could approve the next device that asked.
2. **Follows #3570 (the PC's approval prompt).** Shift+Tab from another
dialog's first stop landed on the prompt's last button, so two
Shift+Tabs and an Enter typed for the dialog pressed Approve. The guards
(keys for 1 s, clicks for 500 ms after the prompt arrives, moves or is
handed the focus) were measured against the time the handler ran, so on
a busy page a key or click made before the guard ran out, and heard
late, could approve.
3. **Follows #3555 (the hosted app's shell).** The confirm records the
sign-in it was drawn for, but only in the page's memory. When the hosted
app reloaded itself for a newer build between the confirm and the
enrollment, the reloaded page enrolled the PC as whoever was signed in
by then: another tab signing in as someone else in between added the PC
under that account.
4. **Follows #3584 (Add this PC).** A relisting that was given up for
getting no answer still had its request for the window on its way; when
it reached the PC after Stop waiting, nothing closed the window again.
And Stop waiting's close (`POST /api/relay/link/close`), arriving late,
could shut the window of a new wait begun meanwhile.
5. **Follows #3544 (Add this PC, resumed).** A resumed wait opened a
ten-minute approve-here window before it compared which PC had answered,
and believed "added" of whichever PC answered. A page that now answers
for a different PC got a window opened on it, and a PC already in the
account was said to be the one that was added.

### Items 6 to 11: the answer typed in a terminal (follows #3581)

`ovis add` / `login` / `link` and `pair --approve` ask in the PC's
terminal about a device that wants in, and an approval lets it into the
PC. #3581 (in main, 64344a5) made an approval need the request's
digits and dropped lines typed ahead. Its last two reviews left these
six:

6. **Three digits that two requests share.** The last three digits
approve, and two requests end in the same three once in a thousand
pairs: a line typed for one approved the other.
7. **A line typed while an answer was lost.** When the POST that carries
an answer got no reply, the request was asked about again, and a line
typed meanwhile answered it.
8. **A typo declined for good.** Any line that was not the digits
declined, so a `y` out of habit or a mistyped digit ended the request.
9. **Full-width digits.** Digits typed with an input method in its wide
mode (222) did not match.
10. **A line begun before a run's first prompt.** The terminal hands a
line over only at Enter, so what was typed and not sent before the first
question came as part of the line sent at it.
11. **`pair --approve` took buffered answers.** It read one line per
request with no dwell and no drop, so a second line sent behind an
answer answered the next request, and piped input approved.

## How

1. `install.sh`: `discard_typed` empties the terminal's input right
before the add step, after the terminal and foreground checks and under
the INT trap: with perl's `tcflush`, as the star question does, else
with `stty -icanon min 0 time 0` and `dd`. Where neither can, the add
step does not run and the closing lines name the command. **What the add
step does itself:** what is typed after the add step has started is that
step's own to tell from an answer: #3581 (in main, 64344a5) takes a
line as an answer only when it was typed after its request was shown,
and items 6 to 11 below go further in `scripts/plugin-link.ts` (the add
step now also empties the terminal's input itself as each question first
shows). The installer's discard stays: it runs before the sign-in, where
the add step reads nothing yet. **Only on a release with that reader:**
the installer is served from main but installs the latest release, and
up to v0.5.2 that release's `link` asks `[y/N]` and takes the next line.
So `add_pc` runs the add step only when the release that runs has
`export function answerOf` in `scripts/plugin-link.ts`; otherwise it
says to update and prints the command.
2. `useFocusTrap.ts`: `overlayEntry` makes a prompt's button reachable
by Tab only from inside that prompt; from outside, in either direction,
the prompt itself is entered first. `RelayPairingPrompt.tsx`: the key
guard starts again whenever the focus comes into a prompt from outside
it, and both guards count to the event's own `timeStamp` (and to the
keydown or pointerdown a click comes of, when earlier), capped at five
seconds.
3. `shellState.ts`, `shell.tsx`, `accountController.ts`: the sign-in's
id and the PC's id (no token) cross the shell-update reload in the tab's
session storage. The next load reads them and leaves them there until
the app opens, another confirm is acted on, or the PC is forgotten, so a
second reload on the way finds them too (the same now holds for main's
"a key of its own" marker). The reloaded page goes on under that sign-in
only when it is still the one stored; with another, or none, the PC
opens with the key this page holds and the enrollment does not run.
4. `addThisPc.ts`, `AccountSection.tsx`: every close from the page goes
through `closeAddWindow`, and a window is asked for only once every
close sent before was answered (a minute at most). The late close is
tied to the listing itself as well as to the attempt's end, once per
attempt. A listing whose wait was stopped ends at once
(`AddPcWaitOver("ended")`): before the window is asked for, and right
after it opened.
5. `addThisPc.ts` (`pcAnswers`), `AccountSection.tsx`: the wait reads
`web_ui.server_id` from `GET /api/health`, which opens nothing, before
every reopen, before a relisting asks for the window (`listThisPc` for a
wait) and before it believes the PC has joined. Where the health does
not tell the id, the hosted app's page names the PC; with neither, no
window is opened and nothing is said. The check of the link's own id
stays, for an address that changes between the two requests; the window
that reopen opened on the other PC is then closed again.

Items 6 to 11 are in `scripts/plugin-link.ts` (one implementation,
`asking`, used by `ovis add` and by `pair --approve` through
`approveWaiting`), `scripts/plugin.ts`, their tests, `docs/relay.md` and
`docs/guide.md`:

6. A request asks for all six digits, and says why, when its last three
are also those of a request asked about earlier in the run or waiting
now; only all six approve it then. A request already asked about with
three is asked about again with all six as soon as such a request waits
beside it (`beside`, at every look), and `ovis add` reads the waiting
requests once more before it sends an approval typed as three digits.
`pair --approve` does the same before a three-digit approval
(`ApproveOptions.list`).
7. `lost()` arms the one-shot drop when an answer's POST fails with no
reply: the next line handed over answers nothing, whichever request is
asked about by then.
8. `answerOf` returns no answer for a line that is neither the digits
nor empty. One line says what approves and what declines, and the
question is asked again. Enter by itself still declines. Three or six
digits that are not the request's get a line of their own: they are not
this request's digits, the request may be another device's, and Enter by
itself declines it.
9. The line is NFKC-normalised before it is matched.
10. `discardTyped` empties the terminal's input queue with the system's
`tcflush` (through `bun:ffi`: libc on Linux, libSystem on macOS) as a
request's question first shows. Where that cannot be done (Windows, no C
library found) the first line after each question answers nothing and
the question is asked again.
11. `pair --approve` asks through the same loop: the 1.5 s dwell, one
line per request, the drops above, and input that is not a terminal
answers nothing: the command says so and exits 1 without sending a
decline, so the requests keep waiting (`ovis add --approve` still
declines what shows in the window its own run opened). An answer the
server does not take is asked for again instead of ending the command.

### Trade-offs, where the guard wins

- **Item 10's limit.** The terminal is read a line at a time, so when a
line was begun is never seen. Keys pressed in the moment after a
question showed, before it was read, are part of the line sent at it;
such a line approves only if it is that request's own digits (after the
dwell) and declines only if it is empty.
- **Item 10 costs an answer typed too early.** Digits typed before a
question showed stay on the screen in front of it but were discarded, so
Enter pressed at it is an empty line and declines; the device has to ask
again. Not changed (a decline is the safe side, and making the first
Enter answer nothing would take two Enters for every decline);
`docs/relay.md` and the changelog fragment say so.
- **Item 6:** between two looks (two seconds at most) a request that
shares the three digits can come to wait unseen; the extra read before a
three-digit approval is sent closes that, at the price of one more local
request per such approval. A request that starts waiting after that read
and before the POST is not seen.
- **Item 10 on Windows** takes two lines for every answer, a decline
included.

- **Item 5 needs herdr to answer.** `GET /api/health` without a scope
answers only after herdr's ping. While Ovis is up and herdr is stopped,
a wait's window is not reopened or relisted, and **"This PC is in your
account" is withheld too**: the screen keeps saying "Waiting" until
herdr answers, or the wait expires. The press itself needs no health. A
follow-up outside this surface could name `web_ui.server_id` in the
`?scope=bridge` answer.
- **Item 2's age cap cuts both ways, and the refusal is silent.** In a
browser whose `event.timeStamp` runs behind `performance.now()` (clock
drift after the PC slept), every key or click counts as five seconds
old, so Approve does nothing for about 5.5 s (pointer) or 6 s (key)
after a prompt arrives, with no sign why. And a key made inside the
guard but heard more than five seconds later on a frozen page counts as
five seconds old and can approve.
- **Item 1:** a perl whose `tcflush` fails does not fall back to `stty`
and `dd`; the add step is skipped and the command printed.

## Review

### Items 1 to 5

An independent reviewer read the branch (verdict: fix, then ship). Its
findings and what became of each:

- **Medium, item 4: a close that main guaranteed was gone.** The branch
closed late only when the listing promise settled, and `listThisPc` did
not ask `wait.running()` after the window opened, so with the account
directory's read hanging the window reopened after Stop waiting was
never closed; a relisting still reading health at Stop went on to open a
window. **Fixed** (62ee8aa): `listThisPc` throws
`AddPcWaitOver("ended")` for a stopped wait right after `pcAnswers` and
right after the window opens, and the attempt-end close is back beside
the listing's own, once per attempt. Tests: `addThisPc.test.ts` "a
listing for a wait that was stopped opens no window, and reads nothing
once a window on its way has opened" and
`AccountSection.addThisPc.test.tsx` "Stop waiting while a listing asks
for the window closes the window it opens late, also when the account's
directory never answers"; both failed before the fix. The component test
passes with either of the two changes alone, so it does not hold the
attempt-end close by itself; the lib test holds the other.
- **Low, item 5: "added" is withheld while herdr is down.** Real; not
changed, the guard wins. Said above.
- **Low, item 2: the age cap.** Real; not changed. Said above.
- **Low: focus-trap browser regressions and where they ran.** See
Validation.
- **Info, not fixed here by agreement** (outside the five): a late close
from Add this PC can shut a window opened by Settings' pairing link
(`RelayPanel.tsx` calls `requestRelayLink` outside the new ordering),
and a close from another tab is not ordered; `starts` is per copy, so
one copy's late close can shut the window of a listing another copy
began (as on main); item 3 binds only signed-in confirms, so a pairing
made with no consent still acts as whoever is signed in after the
reload; Codex's second #3555 finding (enrollment can end the terminal's
session after the app opened) is untouched; a failed `stty` restore
would leave the terminal in non-canonical mode.

### Items 6 to 11

An independent reviewer read the six terminal commits at f78ccbe
(verdict: fix, then ship). Its findings and what became of each:

- **Medium, item 6: half closed in `ovis add`.** Whether a request needs
all six was decided once, when it was first asked about; a request with
the same last three that came to wait afterwards left the "Type 456"
prompt standing, and `456` read off the other device approved the
request on the screen. **Fixed** (710920b): `beside` compares the
waiting requests at every look and once more before a three-digit
approval is sent, and asks again for all six with a line saying why.
Tests in `scripts/plugin-link.test.ts`, "a request whose last three
digits another request shares": "asks again for all six once another
request with the same last three starts waiting beside it" and "looks
once more before it sends an approval typed as three digits"; both
failed before the fix. A third holds that all six, or a decline, already
typed still stand.
- **Low, item 10: digits typed ahead, then Enter, decline.** Real; not
changed, the guard wins. Now said in `docs/relay.md`, the fragment and
above.
- **Low, item 10: `discardTyped` had no test, and its macOS branch had
never run.** **Fixed** (7473352, df602ec): `scripts/plugin.test.ts`
"discards what was typed at a real terminal before the question showed"
runs `pair --approve` on a real pty (`script`), types the request's
digits before the question and Enter after the dwell, and expects a
decline. With the wrong queue selector in `discardTyped` it fails with
"Approved." on Linux and on macOS (both tried). It is skipped on Windows
and where `script` is not installed.

### After the reviews at df602ec

Both reviewers were clear at df602ec (Opus with four lows, Codex with
two mediums). `origin/main` with #3586 (`ovis add` ends in one QR code)
was merged in, keeping its QR path and this PR's answer rules for
`--approve`; the QR path's keep question now discards the terminal's
input as it first shows and reads the word NFKC-normalised. Then, each
with a test that fails without it: the wording for digits of another
value (Opus low 1), the second read in `pair --approve` (low 2), no
decline from a non-terminal `pair --approve` (low 4), the installer's
add step only on a release with the new reader (low 3 and CodeRabbit's
thread at install.sh:558, answered and resolved), and Codex's two
mediums, both reproduced: the consent kept over a second reload, and the
window opened on another PC closed. Details in the PR comment of the
same name.

## Validation

On this head (65ca063), which has `origin/main` at 35b00a8 merged
in, unless a line names an earlier head.

- `bun run check fast` through the queue: every line ok (workflow
syntax, generated types, generated themes, typecheck, build, unit tests:
15533 pass, 0 fail, 51 skip in 894 files).
- The tests added after the reviews at df602ec were watched failing
without their fixes (the shell and Add this PC ones by running them on
the unfixed code; the others assert behaviour or words the unfixed code
does not have). The macOS hand run of the pty test below was at
df602ec and not repeated.
- Items 6 to 11: each has tests with an injected clock and a fake
keyboard. The tests added for the review's findings were watched failing
before their fixes at this head; those of the six original commits were
written before their fixes by the session that made them and were not
watched failing again here. One real terminal was used, a pty made by
`script` for the test above: on this Linux PC inside `bun run check
fast`, and on macOS 27.0.1 (the test MacBook Air, a fresh clone of main
in `/tmp` with this PR's diff applied, deleted afterwards), where it
passed three times and failed with the wrong queue selector. GitHub's
macOS job does not run `scripts/plugin.test.ts`, so macOS has that one
hand run and nothing automated. Whether the CI runner image has `script`
was not checked: without it the pty test is skipped there.
- Items 6 to 11, not run: no real `ovis add` against a real server,
account service or second device; no person at a keyboard; Windows (the
path where the input cannot be discarded) only through the fake
keyboard; musl only by the library name in the code.
- Items 1 to 5: each new or changed test was watched failing without its
fix. The independent reviewer also overlaid the tests of the first five
commits on a throwaway copy of `origin/main` and saw them fail there.
- Browser scripts (items 1 to 5), run at the earlier head ff6bddf and
not again since: three merges of `main` came in after that run, and
65ca063 changes `AccountSection.tsx` (one branch of the reopen) and
`shell.tsx`. Each with `bun run check run` on the isolated test session,
**on this PC's host, not in the CI runner image**:
`scripts/relay-pairing-prompt-regression.ts` (item 2, with `--build`),
`scripts/ui-regression.ts` (items 4 and 5, with `--build`), and for the
shared focus trap `scripts/settings-pages-demo-regression.ts` and
`scripts/drawer-modal-regression.ts`. All passed. The other scripts that
go through `useFocusTrap` (Files, the file viewer, ConfirmDialog rounds
and the rest of the browser set) were not run by hand; they run in the
runner image in this PR's "Integration and browser" job.
- `scripts/relay-pairing-prompt-regression.ts` presses at the 1000 ms
and 500 ms boundaries with 250 ms of slack, so only the unit tests
(injected clocks) hold the exact boundaries.

Items 1 to 5, not run: no real terminal and no real install
(`install.sh` ran only in its tests, under a throwaway HOME, with
stand-ins for perl, stty and dd); no real account service, relay or
second device; no real browser clock drift for item 2's cap.
`install.sh` on macOS and Windows is left to GitHub's macOS and Windows
jobs.

Needs a real review: approval and consent paths (pairing prompt,
enrollment, add-this-PC, the installer's add step, the terminal's answer
loop of `ovis add` and `pair --approve`)

The merge pass agreed on these eleven (the five, then the six from
#3581's last reviews), and only these, as the one follow-up PR before
the release; everything else from those reviews waits.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>
devswha added a commit that referenced this pull request Nov 11, 2026
…prove a FIFO unread by who gets its text (#3630)

## Why

Two tests fail on a busy machine with their code untouched.

- `server/pty/host.test.ts`, "PtySession on the node PTY host > ends a
plain exit without waiting out the hold for a closed terminal": 151.99
and 213.5 ms against 150 in two local merge gates (#3585, #3354), 233.6
and 166.7 ms in two Integration jobs on GitHub (run 42827626297 attempt
1 of #3542, run 42831916527 attempt 1).
- `server/opencode.contract.test.ts`, "answers the catalog and a cold @
send within budget while opencode.json is a FIFO": 2047 ms against 2000
in the local gate of #3585.

Each measured mostly something else than what it guards.

- The PTY test's 150 ms ran from before the host's spawn. The Node
host's start is 37 of the 55 ms an idle run takes; the behaviour, an
exited command not being held for the host's 200 ms wait, is the last
17.
- The FIFO test's 2 s is the 1.5 s attach budget plus delivery. The
server never opens the FIFO, so none of it is the FIFO. On one CPU the
test fails every time (2009, 2023 ms).

## What

- PTY: the command leaves a file as it exits (`: > "$1"; exit 7`), and
the 150 ms run from that file's own time (its mtime, the system's word
for when the command wrote it) to the reported exit. What the test
process does late only makes the span longer, so a host that holds the
exit cannot pass on a busy machine. (The first head of this PR started
the clock when the test saw the file; the review showed that could hide
a hold.) Same number, same exit code. From there the exit is 18 to 23 ms
away on the Node host (the Rust host's whole test takes 4 to 5 ms); a
waited hold adds 200 ms. The marker is a file and not output because the
Node host ends a pty whose last byte comes with the hangup another way
(see "Not in this PR").
- FIFO: a writer waits at the FIFO from the start, and the test goes on
only once the writer has said it is about to open the FIFO and sleeps in
that open, so no read can come before it waits. Its open returns only
when something opens the FIFO to read, and that reader gets its text. At
the end the test opens the FIFO itself, without waiting, and must get
the text. No time is counted, and a server that reads the FIFO is not
held by it, so a regression fails in about 4 s instead of 7. The test is
renamed "answers the catalog and a cold @ send without opening an
opencode.json that is a FIFO".
- No product code changes.

Two things change in what the FIFO test catches:

- It now also fails when the server opens the FIFO without waiting on it
(`O_NONBLOCK`, refused by its descriptor). The old test passed there.
`openRegular` checks the path before any open, and the test now holds it
to that.
- It no longer bounds the catalog at 4 s or the first key at 2 s. A cold
send slowed past 2 s by something other than the FIFO failed before and
passes now. The attach budget has its own test, checked at its boundary
(#1741).

## Proof

In the CI runner image, one container at a time, commit ce11b34 plus
patch files.

| Product | Old tests | New tests |
|---|---|---|
| as is, 8 CPUs, whole files ×3 | pass | pass (41 pass / 26 pass, 0
fail) |
| as is, with a Rust host built from main, `host.test.ts` ×3 | pass |
pass on both hosts (64 pass, 0 fail) |
| Node host waits out the hold for an exited command | fail ×3 (322 to
371 ms) | fail ×3 (206 to 207 ms) |
| Rust host waits out the hold for an exited command | fail ×3 (404 ms)
| fail ×3 (200.4 ms) |
| the scan reads `opencode.json` with a plain open | fail ×3 (catalog
5.0 to 5.2 s) | fail ×3 (the text is gone) |
| the cold send reads `opencode.json` with a plain open | fail ×3 (first
key 6.2 to 6.4 s) | fail ×3 (the text is gone) |
| forced: the host starts 120 ms later, delivery is 600 ms slower | fail
×3 both (198 to 208 ms; 2115 to 2217 ms) | pass ×3 both |
| forced: one CPU, whole files ×2 | PTY pass, FIFO fail ×2 (2009, 2023
ms) | pass ×2 both |
| the server opens the FIFO without waiting and refuses it | pass ×2 |
fail ×2 (by design) |

## Validation

Ran:

- In the CI runner image (`herdr-ci-runner:local`), three times each, on
8 CPUs: `bun run check run -- env HERDR_TEST_MODE=integration bun test
--timeout 15000 ./server/pty/host.test.ts` (41 pass, 29 skip, 0 fail)
and `bun run check run -- env HERDR_TEST_MODE=integration bun test
--timeout 15000 ./server/opencode.contract.test.ts` (26 pass, 0 fail).
The same two commands twice on one CPU: pass.
- The first command three more times with `crates/pty-sidecar` built
from main (Rust 1.85, musl) in place: 64 pass, 4 skip, 0 fail.
- The mutation and forcing runs of the table above, each test alone
(`-t`).
- On the host: `bun run typecheck`; `bun test --timeout 15000
./scripts/conventions.test.ts ./server/conventions.test.ts
./server/catalog.conventions.test.ts ./src/conventions.test.ts` (63
pass).

- `bun run check fast`: pass on this head (15742 unit tests pass, 0
fail).
- On this head, in the CI runner image: both files three times (67 pass,
0 fail each), and the two changed tests with the Node host made to wait
out the hold and the scan made to read `opencode.json`: both fail, twice
(211.7 and 212.2 ms against 150; the text handed is `""`).
- Checked again on the final diff by the session that opens this PR, in
the CI runner image: both files twice (67 pass, 0 fail each), and the
two changed tests with the Node host made to wait out the hold and the
scan made to read `opencode.json` (both fail, twice: 208.4 and 206.9 ms;
the text handed is `""`). The independent review agent meant for this
change ended on the account's rate limit before it reported, so this
check and a reading of the diff stand in for it.

Skipped:

- `bun run check full`, the rest of the integration suite, the browser
lanes (no UI change).
- Native Windows and macOS: neither file is in those jobs.
- GitHub's "Rust PTY host" job, which runs `host.test.ts` on its own
build: it runs on the PR.

No changelog fragment: tests only, nothing a user notices, as in #3617,
#3604 and #3605.

## Not in this PR

- The Node PTY host holds a command 200 ms, or kills it, when its last
output is read together with the hangup: `printf X; exit 7` is reported
after 242 ms where `exit 7` takes 51 and the Rust host 2, and `printf X;
exec 0<&- 1>&- 2>&-; sleep 0.05; exit 3` is reported as 137 where the
Rust host says 3. The host takes the socket's end of stream for
node-pty's destroy after an exit. It needs its own fix and parity tests.
- The other tests that assert elapsed time under a fixed number. The
tightest are `server/prompt.test.ts:6651` (`< 1_790` over a 1.5 s wait),
the first-key gaps in `server/opencode.contract.test.ts:1102` (`<
1_000`, seen up to 774 ms) and `server/prompt.contract.test.ts:564` (`<
600`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>
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