Skip to content

fix(herdr-core): leave another hc machine's terminals out of this PC's workspaces - #2783

Closed
zerone0x wants to merge 1 commit into
devswha:mainfrom
zerone0x:fix/herdr-core-other-machine-terminals
Closed

zerone0x wants to merge 1 commit into
devswha:mainfrom
zerone0x:fix/herdr-core-other-machine-terminals

Conversation

@zerone0x

@zerone0x zerone0x commented Nov 4, 2026

Copy link
Copy Markdown

Change

Fixes #2768

With OVIS_RUNTIME=herdr-core, hc lists the terminals of every machine the core holds in terminal.list and events.subscribe (vps/t14 after this machine's t7). groups() in server/herdr-core/snapshot.ts took them all, so a terminal the Herdr app started on vps (labelled with a space only vps's document has) fell into the "not placed" branch and became a workspace of this PC named from its where label (ubuntu). Its events reached the server as this PC's pane events too.

A <machine>/tN address belongs to that machine, not this PC. Until hc machines show as PCs of their own, they are now left out:

  • snapshot.ts: new onThisMachine(address) (no / in the address); groups() only takes this machine's live terminals, so no workspace, tab or pane is invented for another machine's, whatever its labels or the layout document say.
  • adapter.ts, events.subscribe: hc events about another machine's terminal (created, status, turn, labels, lost, finished, removed, ...) are dropped, and its records in hc's subscribe snapshot are not remembered.
  • adapter.ts, pane lookups: terminal() (send_text, process_info, agent start) and pane.send_keys answer pane_not_found for another machine's address instead of reaching it through hc, as pane.get and pane.read already do through the snapshot.

The pin bridge (pin-label.ts) is left as it is: it writes no workspace and only acts on panes the server shows.

Validation

  • bun test server/herdr-core/snapshot.test.ts server/herdr-core/adapter.test.ts: 64 pass. The two new tests (a snapshot with vps/... terminals labelled, unlabelled, parented to a local terminal and named in this core's layout; and an adapter test covering the snapshot, pane.get/send_text/send_keys and the event stream) fail on main and pass with this change.
  • bun test scripts/changelog-fold.test.ts: pass.
  • bun run check fast: generated types, generated themes, typecheck, build and actionlint pass; unit tests 11180 pass, 1 fail: server/claude-images.test.ts "a lookup that sees the file rewritten drops the boundary it kept", which has nothing to do with this change and passes when run alone (43/43) both on main and on this branch.
  • Skipped: bun run check full (needs herdr and Chrome, not available here); no real hc machine pair was available, so the fix was not tried against a live hc machine add.

…s workspaces

hc lists every machine's terminals (`vps/t14`) in terminal.list and
events.subscribe. groups() took them all, so one labelled with a space
only that machine's document has became a workspace of this PC named
from its `where` label, and its events reached the server as this PC's.

Leave `<machine>/tN` terminals out of the snapshot, the event stream
and the pane lookups until hc machines show as PCs of their own.

Fixes devswha#2768
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Terminals belonging to other machines are no longer displayed in this PC’s workspaces or included in its terminal event stream. Attempts to view or interact with those terminals now report that the terminal cannot be found. Terminals on this machine continue to appear and their events are still handled normally.

The herdr-core snapshot and adapter now exclude terminals from other hc machines. Remote terminals do not appear in local workspaces, tabs, panes, or event streams. Remote pane lookups and writes return pane_not_found.

Changes: Local terminal filtering

Layer / File(s) Summary
Snapshot filtering
server/herdr-core/snapshot.ts, server/herdr-core/snapshot.test.ts, changelog.d/herdr-core-other-machine-terminals.md
onThisMachine identifies addresses without / as local. Snapshot grouping excludes other addresses, including when a local layout names a remote terminal. Tests and the changelog describe this behavior.
Adapter filtering
server/herdr-core/adapter.ts, server/herdr-core/adapter.test.ts
The adapter rejects remote terminal lookups and key input, skips remote status records, and drops remote events. Tests check these cases and verify that local terminal creation events are forwarded.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • devswha/ovis#2497 describes the same exclusion of remote terminals from this PC’s snapshot and events. This pull request implements that behavior and also filters adapter lookups and writes.

Suggested reviewers: devswha, nahwan-kim

Merge Risk: Minimal · up to 1f22a

No merge-blocking issue was identified. The change excludes other machines’ terminals from local workspaces and operations; merge after normal checks pass.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: terminals from another hc machine are kept out of this PC's workspaces. It uses the fix(herdr-core) convention and is specific enough for a teammate scanning history. …
Description check Passed The description follows the template. It has a Change section that explains the problem (groups() took other machines' terminals, so they became workspaces of this PC), the resulting behavior across s…
Linked Issues check Passed Issue #2768 has one direct, open coding requirement: with OVIS_RUNTIME=herdr-core, terminals addressed as /tN must not produce a workspace, tab, or pane of this PC, and their events must not …
Out of Scope Changes check Passed Every changed path maps to issue #2768 and the PR objective.

- server/herdr-core/snapshot.ts: adds onThisMachine and applies it in groups(). This is the requirement's core fix.
- server/herdr-core/ad…
Docstring Coverage Passed Docstring coverage is 100.00% 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. Documentat…
Full details: Title check

Explanation

The title names the main change: terminals from another hc machine are kept out of this PC's workspaces. It uses the fix(herdr-core) convention and is specific enough for a teammate scanning history. The 81-character length is slightly long but acceptable.

Full details: Description check

Explanation

The description follows the template. It has a Change section that explains the problem (groups() took other machines' terminals, so they became workspaces of this PC), the resulting behavior across snapshot.ts, adapter.ts, and pane lookups, and links issue #2768. It also has a Validation section listing the commands run, their results, a pre-existing unrelated failure, and the skipped full check with its reason. The template asks for a maintainer-agreed issue for features only, which does not apply to this fix.

Full details: Linked Issues check

Explanation

Issue #2768 has one direct, open coding requirement: with OVIS_RUNTIME=herdr-core, terminals addressed as <machine>/tN must not produce a workspace, tab, or pane of this PC, and their events must not reach this PC's server. The reviewed head meets this at each point the issue names.

  • Snapshot (server/herdr-core/snapshot.ts): the new onThisMachine(address) returns false for any address containing '/'. groups() builds its live map with terminal.state === "live" && onThisMachine(terminal.address). The take() helper and the 'rest' list (terminals no tab places) both read from this map, so a vps/tN terminal cannot be placed or adopted into a workspace, whatever its herdr.space, where, or parent labels say.
  • Events and subscribe snapshot (server/herdr-core/adapter.ts): onEvent returns early when event.terminal is defined and not on this machine. remember() and the reported-status seeding loop in subscribe() skip such records.
  • Pane lookups: terminal() throws AdapterError(missing) for another machine's address before any hc call. pane.send_keys throws pane_not_found for it before inTurn runs.

The PR description and the diff summary report new tests in snapshot.test.ts (+19 lines) and adapter.test.ts (+43 lines) covering these cases. I did not read the test bodies, so test coverage rests on the summary and the PR's reported run (64 passing). The pin bridge is unchanged, as the issue does not require a change there.

Unresolved uncertainty: the file read of snapshot.ts was truncated after the 'rest' placement logic. I did not confirm that the truncated remainder of groups() and buildSnapshot() reads terminals only through the filtered live map. The diff itself adds no other terminal source, so this does not change the verdict.

Full details: Out of Scope Changes check

Explanation

Every changed path maps to issue #2768 and the PR objective.

  • server/herdr-core/snapshot.ts: adds onThisMachine and applies it in groups(). This is the requirement's core fix.
  • server/herdr-core/adapter.ts: applies the same check in terminal(), pane.send_keys, the subscribe snapshot seeding, remember(), and onEvent(). Each hunk serves the issue's 'left out of snapshot and events' and 'no pane for another machine' outcomes. The import of onThisMachine is needed for these uses.
  • server/herdr-core/snapshot.test.ts and adapter.test.ts: regression tests for the snapshot, pane lookups, and event stream. Supporting tests for the fix are in scope.
  • changelog.d/herdr-core-other-machine-terminals.md: a changelog entry describing the user-visible behavior. Documentation for the fix is in scope.

No hunk introduces unrelated behavior. The changes do not alter the pin bridge, which the PR states it leaves unchanged.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% 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 2 functions across 4 files. (1 skipped: 1 unsupported.)

Finishing Touches
Generate unit tests (beta)
  • 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
  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 7240c80
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: efd80f06-076f-4f88-a4c7-39542b78baa1
Commits

Reviewing files that changed from the base of the PR and between 7240c80 and 1f22a71.

Files selected for processing: 5
  • changelog.d/herdr-core-other-machine-terminals.md
  • server/herdr-core/adapter.test.ts
  • server/herdr-core/adapter.ts
  • server/herdr-core/snapshot.test.ts
  • server/herdr-core/snapshot.ts

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

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thank you @zerone0x for tracking this down and for a careful fix with tests.

The same bug (#2768) was fixed on main by #2795, which landed while this PR was open. It takes the same approach as yours (an address with a / is another hc machine's terminal, left out of the snapshot, the pane lookups and the event stream), and also covers two cases found in review: the pin bridge (pin-label.ts), where a hidden remote agent could otherwise be unpinned on the other machine, and hc's doc events that name a machine and no terminal.

Before closing, I ran both of your new tests (snapshot.test.ts and adapter.test.ts, #2768) on current main (fda9c00): both pass, together with the rest of server/herdr-core/ (70 pass, 0 fail). So main already holds everything they check, and I'm closing this as fixed by #2795. Your diagnosis matched ours exactly, and it helped confirm the fix. Thanks again!

@devswha devswha closed this Nov 5, 2026
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.

herdr-core: a terminal of another hc machine becomes a fabricated workspace of this PC

2 participants