← Back to Pull requests

feat(daemon): place herdr-app views in herdr-core for a window on another machine #3956

Closed
unknown closed this pull request without merging on Nov 26, 2026 21:54 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 20:55 UTC
Author

Refs #3756

What this does

rig terminal open <view> --provider herdr-app on a machine with no herdr-app window used to fail with herdr_app_unavailable ("herdr-app has to run on the machine the daemon runs on"). That's the headless-box setup in #3756, where the daemon and seats run on a server and herdr-app runs on another machine connected to that server's herdr-core.

Now, when nothing answers at the app home's socket and this machine's herdr-core does, the view is placed in that core:

  • One space per view, one tab per seat. Each seat's viewer starts with herdr's own labels, herdr.space=openrig-<view id> and herdr.tab=openrig-<cell>, which any connected herdr-app adopts. Each tab shows its seat's label: a viewer's command leads with it, and herdr names an unnamed tab after its program. The viewers start in a per-view folder, $OPENRIG_HOME/private/herdr-app/spaces/<view name>-<view id>, which herdr names the space after; a rig's view is named after the rig.

  • The view's commands are unchanged. Each viewer runs the same per-seat tile or ssh command the provider already composes.

  • Nothing is written to an app home: no mods and no rig.json.

  • The result says placed, not seen: ok and opened mean the viewers started, and the new placement field is { mode: "core", visibility: "unconfirmed", core, viewId, host }. The CLI prints "Placed in herdr-core on <host> as view <id>. Any herdr-app connected to <host> shows it; OpenRig can't see that window."

  • Input: interactive cells take input as soon as their viewer runs, as a cell for a seat on another host already does. Read-only cells only show. The existing headless-size watch runs beside the tile, so a viewer no pane shows yet never sizes its seat.

  • Close: rig terminal close <rv-id> ends the view's verified viewers directly (journal, openrig. labels and exact argv, as today). Seats are never touched.

  • Journal and restart: core views are recorded with placement: "core" and never written into the Rig layout. A restart with both kinds rebuilds rig.json from layout views only.

  • A viewer brought back as a shell: after keep recovery, herdr-core gives a viewer whose program it lost a shell in the same tab. The daemon logs it as soon as it notices, or at its next start if it was down, leaves it running and never types into it.

  • Status: status() reports available: true with placement: "core" and host only while no window is here and the core answers.

  • Plain rig terminal open is unchanged:

  • - in a herdr-app terminal whose window doesn't answer, it still falls back to a desktop window, because core placement doesn't count as a window here;
    - an omitted provider never picks herdr-app.
  • The TUI: in a herdr-core terminal with no window on its machine, it targets herdr-app. The preview says "Opens in this machine's herdr-core (<host>)".

  • What doesn't change: a window that is there but doesn't answer still fails the open. No new refusal, error code, timer, poll or transport.
  • docs/reference/herdr-app.md gains "A herdr-app on another machine", with these limits:

  • placed is never reported as seen;

  • herdr orders the tabs, and OpenRig picks no split direction or sizes;

  • a viewer can come back as a shell after keep recovery;

  • before any window adopts a view, a reboot doesn't bring its viewers back.
  • Tests

    On macOS, against fakes of hc and the app, plus real tmux for the viewer wrapper:

  • herdr-app-provider.test.ts: 52/52. New cases cover:

  • - the core open (labels, distinct tab ids, the per-view folder, the immediate writable tile with the size watch, no layout write or mods);
    - status;
    - close with no window;
    - an ended viewer and a viewer replaced by a shell (reported once, never ended, named on close);
    - rollback;
    - mixed layout and core views across a restart;
    - the startup report, and the running daemon's report when it notices a shell;
    - tab labels and a rig view's space name.
  • herdr-app-viewer-size.test.ts, real tmux 3.6a: a core viewer attaches at once with no gate. At the headless size it leaves the person's window size alone, and once shown and typed in it sizes the seat.

  • CLI terminal-herdr-app.test.ts and the other CLI terminal tests: 135/135. They cover the ambient fallback with core placement and the result line.

  • TUI open-window-herdr-app.test.ts, open-window.test.ts, terminal-journey.test.ts and organizer.test.ts: all passed, with 9 skipped. They cover the core target, the preview text with Open kept, and the result notice.

  • Each new guard was broken on purpose and a test failed:

  • - the core close path;
    - the layout filter;
    - the shell check;
    - the core pending end;
    - the size watch;
    - the CLI's ambient check.

    Checked on real builds

    On herdr-app 0.1.18 (Linux, a virtual display) connected to a separate Linux account's herdr-core 0.1.22 over ssh to 127.0.0.1, with OpenRig built from this branch. These passed:

  • adoption;

  • space and tab naming, including a git-checkout folder;

  • a shared tab id;

  • before and after adoption;

  • reconnect;

  • a core restart;

  • a signal death;

  • a daemon restart;

  • input at the default and a custom headless size;

  • two windows;

  • close with no app connected;

  • a mixed-mode restart;

  • the TUI in a herdr-core terminal;

  • status.
  • That run found two problems, fixed here:

  • Tab and space names: tabs were named by each viewer's nonce, and a rig's space by the rig's id.

  • The shell report: a viewer brought back as a shell while the daemon ran was never reported.
  • Not run

  • A lost start reply on a real core (unit cells cover it).

  • Read-only input in the real app.

  • herdr-app on macOS.

  • Two physical machines.

  • The daemon's create-terminal.integration and terminal-pipe-utf8 tests, which need a built dist.
  • Round 2: CodeRabbit's two points on closeView

    Both were real, and both came from one gap: a core view's close counted only the viewers the journal already marked as shells.

  • The tabs note: a viewer that core turned into a shell after the last check is left in place by the close's own verification, because its argv no longer matches. A viewer the close couldn't end yet (core didn't answer, or the kill failed) stays pending. Either one still runs, so its tab stays, but the note said a connected herdr-app "removes its tabs". The close now counts what its own removal left running. Whenever anything is still running, the note says the app "removes the tabs of the viewers OpenRig ended, not those left running".

  • The view's folder: it was removed while such a viewer still used it as its working directory. It's now kept while anything of the view may still run.

  • - The trade: a folder kept for a viewer that ends later stays behind as an empty folder under spaces/, and nothing removes it afterwards.

    Tests:

  • herdr-app-provider.test.ts: 54/54, with two new cases: a shell since the last check, and a viewer the close couldn't end. On 2b00a20c's source, both fail on the note, and checked separately, on the folder.

  • The herdr suites together (herdr-app-provider, herdr-follow-view, herdr-live-reuse, herdr-app-viewer-gate and herdr-tile-resume): 147/147.

  • The daemon typechecks.
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Views can open in herdr-core when no herdr-app window is available on the daemon’s machine, with labeled tabs for each view.
    Open results and status previews report core placement and its host, and indicate that visibility is unconfirmed.
    When no local window is available, status guidance now includes how to list terminals on the daemon’s machine.
    Ambient herdr-app targeting falls back to a desktop window when core placement is reported.
    Documentation
    Clarified placement conditions, input timing, status reporting, closing behavior, and visibility limitations.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvschwarz Review duration: 1498m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3956"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%