Skip to content

fix(server): the machine profile lists its own machine to the app's PC list - #3972

Merged
devswha merged 4 commits into
mainfrom
fix/machine-profile-own-pc-list
Nov 16, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/machine-profile-own-pc-list

Conversation

@devswha

@devswha devswha commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Change

The app builds its PC list, and the terminal list in it, from GET /api/machines, polled every 5 s. The machine
profile (a preview behind OVIS_PREVIEW=fleet, #3938) refused every route under /api/machines. So a phone that
opened a machine through the relay kept its PC list loading under that refusal, and named the PC by its id local.

The profile now answers that one read, a GET of the exact path /api/machines, with this machine alone, shaped as
an ordinary server lists its own PC. A query string does not change which route it is; the one query value read is
verify_source_boot:

  • id and kind: local;
  • name: the machine's host name, as the pairing offer gives it;
  • enabled: true;
  • state and error: connected, or error with the reason the profile's health gives while its herdr is down;
  • snapshot: the snapshot /api/session gives, with hidden tokens left out the same way;
  • source_boot_id: its boot id; server_id: its relay ID, once the relay has an identity;
  • verified_source_boot: with exactly one ?verify_source_boot=local, its own boot.

Every other route under /api/machines (other methods, the event stream, the routes of other PCs) is still
answered 409 machine_profile: the profile manages no other PC. #3938's description lists /api/machines among
the refused routes: that is now all of it but its GET. A herdr that started after the profile is looked for on
this request too, as on /api/session.

When a herdr read fails on /api/session or on this list, the profile answers:

  • with the reason its health gives, or "herdr did not answer this request" while health gives none;
  • with the status every failed herdr read answers with;
  • with the bridge's own error code, or herdr_error when the code came out of herdr's reply;
  • with cache-control: no-store.

A HerdrError records whether its code came out of herdr's reply (fromReply, not enumerable).

The app is not changed: the list follows its existing 5 s poll, and the profile still answers no live events. With
OVIS_PREVIEW and OVIS_PROFILE unset, an ordinary server answers exactly as main does.

Validation

On this head (four commits on main 2f95460):

  • bun test server/machine-profile.contract.test.ts server/relay/service.contract.test.ts scripts/plugin.test.ts, in
    one run: 254 pass, 1 skip (the Windows-only case), 0 fail. The plugin's tests are in the run because they start
    a machine profile too.
  • bun run typecheck: passed, at each of the four commits.
  • bun run check fast: passed (workflow syntax, generated types and themes, typecheck, build; unit tests 17,759
    pass, 0 fail, 54 skip; they include server/herdr).
  • macOS arm64 (27.0.1), Bun 1.4.2, in a fresh clone of this pull request's head (9eb7fe7): the two contract
    files, 159 pass, 1 skip, 0 fail.
  • New tests, from the outside (a launched profile, or the in-process profile the file's other tests use):
    • the profile lists this machine alone, under its host name, with health's reason while herdr is down;
    • it proves its own boot, names no other PC, and refuses a foreign Origin;
    • every other route under /api/machines is answered 409;
    • a herdr that started after the profile is found on a request for the list;
    • through the relay, the app's own transport and fetchMachines get the machine and its workspace, and the
      list leaves hidden tokens out;
    • a failed read answers health's reason with connect_failed, herdr_error for a reply's own code, or the
      client's closed, each with no-store.
  • Side by side with main 678d87f (one merge before this head's base; that merge does not touch these routes),
    an ordinary server (both variables unset), with herdr refusing the read with its own
    error, closing before it answers, or absent: /api/session, /api/machines and
    /api/machines?verify_source_boot=local answer with identical statuses, headers and bodies. A HerdrError's
    JSON.stringify, keys, spread and printed fields are identical too.
  • Not run: Windows, a real phone, the public relay, a real account.

devswha and others added 4 commits November 16, 2026 20:35
…C list

The app builds its PC list, and the terminal list in it, from GET /api/machines, every 5 s. The
machine profile refused every route under /api/machines (409 machine_profile), so a phone that had
opened a machine through the relay said "Loading PCs…" under that error for good, and named the PC
by its id "local".

The profile now answers that one read with this machine alone, as an ordinary server lists its own
PC: its host name, the snapshot /api/session gives (hidden tokens left out the same way), its boot
id and its relay ID. While its herdr is down the machine is listed with the reason its health gives
and no terminals; a read that fails while herdr answers is that read's failure, as on /api/session.
?verify_source_boot=local proves its own boot. A herdr that started after the profile is looked for
on this request too. Every other route under /api/machines (other methods, the event stream, the
routes of other PCs) is still refused: the profile manages no other PC.

Only the machine profile changes; the app and an ordinary server do not.

Co-authored-by: sisyphus-dev-ai <[email protected]>
… health reason

On the machine profile, a herdr read that fails on /api/session or on the PC list
(GET /api/machines) is answered with the reason the profile's health gives, such as
"herdr is not running for the selected session", or with "herdr did not answer this
request" while health gives none. The status and the error code stay the ones every
failed herdr read answers with. One function beside the health answer decides the
message.

Only the machine profile changes; an ordinary server answers as before.
…bridge's own error codes

On the machine profile, a herdr read that fails on /api/session or on the PC list keeps its
error code only when this server's herdr client made it (HERDR_CLIENT_CODES, the codes the
client constructs); any other code is answered as herdr_error. The status stays the one every
failed herdr read answers with, and the answer is sent with cache-control: no-store, as the
list itself is.

Only the machine profile changes; an ordinary server answers as before.
A HerdrError now says whether its code and message came out of herdr's reply
(`fromReply`): the client sets it where it builds the error from a reply's `error`, and keeps
it where it wraps one. It is not enumerable, so an error's printed and encoded forms keep their
own fields only. The machine profile's answer to a failed herdr read uses it: a reply's own
code is answered as herdr_error, and a code the client made is kept. The client keeps no list
of its codes for this.

Only the machine profile's answers use the flag; an ordinary server answers as before.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • The machine profile now supports GET /api/machines, returning a listing for the local machine with its host name and terminal information.
    • The listing can include the local boot ID when requested with the supported source-boot verification option.
  • Bug Fixes
    • Machine listings and session requests now report the machine’s health reason when the connected service is unavailable or returns an error. If no health reason is available, a fallback message is shown. Other machine-listing routes remain unavailable.

The machine profile now serves GET /api/machines with a roster containing only the local machine. It also maps herdr read failures for roster and session requests to no-store responses.

Changes: Machine-profile roster

Layer / File(s) Summary
Herdr read error handling
server/herdr/client.ts, server/machine-profile.ts, server/dispatch.ts, server/machine-profile.contract.test.ts
Herdr errors record whether the error came from a reply. Machine-profile session reads map herdr failures to no-store responses. Contract tests cover down, failed, and closed herdr reads, plus an ordinary-server control.
Local machine roster
server/machine-profile.ts, server/dispatch.ts, server/machine-profile.contract.test.ts, server/relay/service.contract.test.ts, changelog.d/machine-profile-own-list.md
GET /api/machines returns the local machine and its snapshot. The route checks origin and supports local source-boot verification. Tests cover route restrictions, late herdr discovery, relay snapshots, and secret filtering. The changelog describes the roster and read-error behavior.

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

Change: Feature

Possibly related issues

Possibly related PRs

  • devswha/ovis#3938: This PR extends the machine profile and contract tests introduced there.
Merge Risk: Minimal · up to 9eb7f

This change adds a local-only machine list to the machine profile and returns clearer, uncached errors when herdr reads fail. Ordinary-server behavior is unchanged, and the tests cover the new paths. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the machine profile now lists its own machine in the app's PC list via GET /api/machines. It is short, specific, and matches the raw summary and objectives. It uses th…
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 repository template. It has a Change section that explains the problem, the new GET /api/machines behavior, the failed-read responses, the fromReply marker, and the unchang…
Full details: Title check

Explanation

The title names the main change: the machine profile now lists its own machine in the app's PC list via GET /api/machines. It is short, specific, and matches the raw summary and objectives. It uses the fix(server) prefix, which is a conventional style rather than noise.

Full details: Description check

Explanation

The description follows the repository template. It has a Change section that explains the problem, the new GET /api/machines behavior, the failed-read responses, the fromReply marker, and the unchanged app and ordinary-server behavior. It also has a Validation section that lists the commands run, their results, the macOS run, the side-by-side comparison, and the items not run (Windows, real phone, public relay, real account). The description does not link an issue for the feature, but it references #3938 and the PR's own scope, so the gap is minor.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2f95460 and 9eb7fe7.

Files selected for processing: 6

  • changelog.d/machine-profile-own-list.md
  • server/dispatch.ts
  • server/herdr/client.ts
  • server/machine-profile.contract.test.ts
  • server/machine-profile.ts
  • server/relay/service.contract.test.ts

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

@devswha
devswha merged commit 4d94a2d into main Nov 16, 2026
24 checks passed
@devswha
devswha deleted the fix/machine-profile-own-pc-list branch November 16, 2026 12:24
@devswha

devswha commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 9eb7fe7cc681 as 4d94a2d33633 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

devswha added a commit that referenced this pull request Nov 16, 2026
)

## Change

On the machine profile (a preview behind `OVIS_PREVIEW=fleet`, #3938), a
failed herdr call is now answered with the
profile's own code and sentence, in its HTTP answers and in its error,
submit and pending frames. Such an answer
carries `cache-control: no-store`. The two read routes of #3972,
`/api/session` and `GET /api/machines`, keep the
reason the profile's health gives.

What the profile answers for a failed call:
- the code: the one the bridge's own client made (`connect_failed`,
`timeout`, `closed`, ...), or one of the codes
out of herdr's reply that the app acts on, or else `herdr_error`. The
app acts on `pane_not_found` (nothing was
typed), `stale_content` (the find bar looks again), `agent_blocked` and
`agent_not_ready` (the draft stays),
`not_git_worktree` (that workspace is no checkout) and `invalid_request`
(the read falls back to recent rows);
- the message: "herdr did not answer this request";
- the status: the one every failed herdr call answers with.

A move's, swap's, zoom's or resize's answer keeps a reason the app acts
on (`same_pane`, `cross_tab`, `not_found`,
`no_neighbor`) or one the bridge gives itself (`zoomed_tab`,
`unchanged`); any other reason is `herdr_error`. An
error frame for a fault other than a herdr call keeps its code
(`snapshot_failed`, `command_failed`) and takes the
profile's sentence.

A pane herdr could not restore after it restarted keeps its
`restore_error`, which the app keys on, in one sentence
of the profile's own: in `/api/session`, `GET /api/machines`, the
snapshot frame and an attach's `pane_not_restored`
error. An empty or absent `restore_error` stays as it is.

A move herdr did not make that leaves a pane in a tab of its own, or
back in its tab, is answered `pane_not_moved`
with a sentence of the bridge's own saying where the pane is.

The no-store header covers the answers that carry the profile's words
inside a 200 or 409 body too: a create's
agent start and first message, a worktree create's or open's agent
start, the worktree inventory and a find refused
as stale.

`GET /api/plugin/action` returns a plugin run's state with what the
user's own plugin command printed when it
failed. On the profile it answers the local owner and a device that
drives the PC; a watching device is refused
(403 `read_only`).

How:
- The herdr client marks the error a call to herdr rejects with, at the
one place every such rejection passes
(`failedCall`, not enumerable, like `fromReply`). A refusal the bridge
words itself carries no mark.
- `machineFailure` in `server/machine-profile.ts` is the one function
that decides the profile's code and sentence.
The kept codes and layout reasons are two small sets beside it, each
entry with the app's use of it, and
`machineSnapshot` beside it words a pane's `restore_error`. Where the
bridge knows what came of a failed move, the
error carries that outcome (`outcome`, not enumerable), and
`machineFailure` says it instead of its sentence.
- The machine profile sets its view on the request
(`wordHerdrFailures`), so `errorResponse` words a marked error
by it. None of the existing `errorResponse` call sites changed. The
answers that carry a fault inside a 200 or
409 body (`requestFault`) and the layout answers read the same view, and
every worded answer takes its no-store
  header from one place (`wordedHeaders`).
- The core is given the same view for its frames: `pendingFault` takes
it as a required argument, so a new call
  that forgets it does not typecheck.

With `OVIS_PREVIEW` and `OVIS_PROFILE` unset, an ordinary server sets no
view and answers byte for byte as main
does.

## Validation

On this head (fourteen commits on `main` 00069b4; `main` has moved
since, and merges into this head cleanly):

- `bun test server/machine-profile.contract.test.ts
server/relay/service.contract.test.ts server/http.test.ts
server/herdr/client.test.ts server/agent-launch.test.ts
server/core/composer-framing.test.ts`, in one run:
  245 pass, 1 skip (the Windows-only case), 0 fail.
- `bun run typecheck`: passed, at each commit.
- `bun run check fast`: passed (workflow syntax, generated types and
themes, typecheck, build; unit tests 17,848
  pass, 0 fail, 54 skip).
- The walk (a launched profile, asked on its owner socket): every
`/api/...` route the shipped server code names,
by `GET`, `POST` and `PUT`, with one set of pane, tab and workspace ids,
against three stand-in herdrs: one that
refuses every call, one that answers its snapshot and panes and refuses
every other call (so a route's later
  calls are the ones that fail), and none listening.
- Every answer to a failed call carries the profile's own code and
sentence; every `herdr_error` answer is
    no-store.
- Against the refusing herdr, every route the profile does not refuse or
answer first reaches it, except a
short list of routes that need a request shape of their own, each named
with its reason. Any other route
fails the test by name, so a new route is walked; layout answers have
scripted cases of their own.
  - An ordinary server on the same herdr answers as main does.
- New tests, from the outside: a move herdr did not make (no change, a
refused swap, a pane left outside its tab),
the layout reasons kept and replaced on swap, zoom and resize, a find
refused as stale, the WebSocket error
frames on the profile's socket and an ordinary server's port, a profile
and an ordinary server in one process
with interleaved requests, and the units for the mark, `errorResponse`,
`pendingFault` and the error frames.
- Side by side with `main` 00069b4, an ordinary server (both variables
unset), launched with its own home, with
herdr refusing every call, answering its snapshot and panes, scripting
moves and layout answers, or absent: every
walked route answers with identical statuses, headers and bodies, apart
from values made anew at each start.
- Read before it was opened by a reviewer that did not write it, three
times, with runs: the layout answers and
  the frame cases in this change come from those reads.
- macOS arm64 (27.0.1), Bun 1.4.2, in a fresh clone of this pull
request's head (b1c0a1f): the six test files,
  245 pass, 1 skip, 0 fail.
- Not run: Windows, a real relay device, the real entrypoint (the runs
are in-process servers).
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