Skip to content

feat(herdr-core): keep splits, order and zoom in an ovis-layout document, laid out top down - #2830

Merged
devswha merged 11 commits into
mainfrom
feat/hc-layout-doc
Nov 5, 2026
Merged

devswha merged 11 commits into
mainfrom
feat/hc-layout-doc

Conversation

@devswha

@devswha devswha commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Fixes #2812

Follows #2799 (merged); this branch has origin/main merged in.

What

On a herdr-core no Herdr app arranges (the desktop app's own core), Ovis now keeps the layout itself, and split panes no longer shrink each other:

  • One Ovis-owned hc document, ovis-layout (schema 1): ordered workspaces[], each with ordered tabs[], each tab a split tree ({leaf} or {split: right|down, ratio, first, second}) and zoomed. Written as doc.get -> edit -> doc.set(version), with one retry on conflict. Membership and names stay in terminal labels (herdr.space, herdr.tab, ovis.*), so a Herdr app started later still adopts the terminals.
  • Top-down geometry: every tab is cut from a fixed 1000x1000 area by its tree and never by terminal cols/rows. This also applies to tabs from the Herdr app's document, laid out by size.weight, with a stack showing its active child and hidden nodes skipped. splits[] is filled with herdr's path ids (split_<n>_<path>), so divider drag and keyboard resize work unchanged.
  • Reconcile on every snapshot: a leaf whose terminal is gone is pruned, a terminal labeled into a tab without a leaf is appended to its right, and a core with labels but no document (feat(herdr-core): rename, split and move workspaces and tabs where Ovis keeps the layout #2799's state) is laid out from the labels. The document is first written on the first layout change.
  • Re-enabled on Ovis-kept tabs: pane.split, layout.set_split_ratio, pane.resize, pane.swap (neighbour or explicit), pane.zoom, tab.move, workspace.move, pane.rename (ovis.pane label). ping reports layout.split/layout.arrange only where hc's hello lists doc.set (capabilities come from hello.methods, never from version strings). HelloInfo now carries methods.
  • Read-only where the Herdr app arranges the core: Ovis never writes herdr-app. A ovis-layout written in an unknown schema is neither read nor overwritten.
  • UI: LayoutOffer gains worktrees (always false on herdr-core), so arrange can turn on without offering worktrees.

Why

Issue #2812: a pane's rect was its terminal's grid, the attach resized the terminal to its cell, and the next snapshot read that grid back, so nested splits collapsed (a shell went to 8x1). Labels alone can't hold order, ratios or zoom, and they can't be written atomically across terminals. That's why the order and tree live in one CAS document.

Public contract: docs/herdr-core-layout.md (labels table, document format, reconcile and write rules); docs/guide.md herdr-core section updated.

Validation

Follow-ups / known limits

  • Two viewers of one terminal at different sizes (phone + desktop) still trade cols/rows. That's a viewer-policy issue, not geometry.
  • A Herdr app started later on an Ovis-arranged core adopts the terminals and their grouping but not split ratios or order (documented in the guide).

…is keeps the layout

hc has no workspace, tab or split API. On a core whose herdr-app document
was never written (the desktop app's own core), the adapter keeps names,
splits and a pane's move to another workspace in terminal labels, and ping
reports which layout calls it answers. The UI gates each layout action on
that offer instead of one herdr-core boolean.
…e on new tabs, refuse a helper's move to Other terminals

Review round: a split records the pane it split (ovis.split=<dir>:<pane>) and
a label-made tab is tiled as that split tree; tab.create and pane.split carry
the workspace's name; moving a helper to Other terminals is refused, as its
parent's tab would still show it.
…eir own

Panes of a label-kept tab take their rects from their terminals' grids, and
the attach sizes each terminal to its cell, so split panes shrank each other
(a shell went to one row). ping now reports layout.split false, pane.split
stays unsupported, and the split-tree layout goes until top-down geometry
lands.
…ent, laid out top down

On a herdr-core no Herdr app arranges, Ovis now keeps the order of
workspaces and tabs, each tab's split tree and its zoom in one hc
document, ovis-layout (schema 1), written with doc.get -> edit ->
doc.set(version) and one retry on conflict. Membership and names stay
in terminal labels; every snapshot reconciles the document with them.

Every tab, the Herdr app's included, is now cut top down from a fixed
1000x1000 area by its tree, never from terminal grids: a viewer resized
each terminal to its cell and the grid read back as the rect made split
panes shrink each other (#2812).

pane.split, layout.set_split_ratio, pane.resize, pane.swap, pane.zoom,
tab.move, workspace.move and pane.rename are answered on Ovis-kept tabs;
ping reports layout.split and layout.arrange only where hc's hello names
doc.set. The Herdr app's document is only read. Worktrees get their own
offer flag so they stay hidden on herdr-core.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2a96234 and 587fc39.

Files ignored due to path filters: 1

  • server/herdr-core/hc-api.generated.ts is excluded by !**/*.generated.*, !server/herdr-core/hc-api.generated.ts
Files selected for processing: 25

  • changelog.d/hc-layout-doc.md
  • changelog.d/hc-workspace-layout.md
  • docs/guide.md
  • docs/herdr-core-layout.md
  • scripts/hc-types.ts
  • server/core/pane-grid.test.ts
  • server/core/terminal-process.ts
  • server/herdr-core/adapter.test.ts
  • server/herdr-core/adapter.ts
  • server/herdr-core/connection.ts
  • server/herdr-core/layout-doc.test.ts
  • server/herdr-core/layout-doc.ts
  • server/herdr-core/live.test.ts
  • server/herdr-core/snapshot.test.ts
  • server/herdr-core/snapshot.ts
  • server/herdr/client.ts
  • shared/machines.ts
  • shared/protocol.ts
  • src/components/CommandPalette.appLayout.test.tsx
  • src/components/PaneCanvas.appLayout.test.tsx
  • src/components/Sidebar.appLayout.test.tsx
  • src/components/Sidebar.tsx
  • src/components/TabStrip.appLayout.test.tsx
  • src/lib/machineContext.test.ts
  • src/lib/machineContext.tsx
  • 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

- Read ovis-layout before the terminal list, so an edit never prunes a
  pane another writer added under the version it writes against.
- Apply tab and workspace moves to the order as each attempt reads it,
  anchored on the entry they go before: a concurrent reorder stays, and a
  drop after Other terminals or among a parent's helper tabs lands.
- Claim the terminals of the Herdr app's hidden nodes and inactive stack
  children, so they show nowhere else.
- Keep every pane of a deep split at least one unit wide.
- Place a leaf a document names twice once.
- Offer no split or arrange, and start no split shell, where ovis-layout
  is in a schema this Ovis does not know; say so when a split pane could
  not be placed.
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review round 1 (omo at 9c57999: BLOCK on MEDIUMs, no HIGH; Codex Terra xhigh: no HIGH, six MEDIUM). Fixed in b109f31, each with a test:

Finding Source Resolution
Hidden nodes / inactive stack children of the Herdr app's tree re-adopted (as Other terminals, or beside the tab when labeled) omo (reproduced) + Codex Fixed: appTree claims their terminals; snapshot.test.ts checks both labeled and unlabeled cases show only the active pane and no extra tabs
Reorder retry re-applies a stale full order, undoing a concurrent move Codex + omo Fixed: the move is applied inside each CAS attempt, anchored on the entry it goes before; adapter test with an interleaved writer
Drop after Other terminals / among helper tabs refused or silently ignored Codex + omo (LOW) Fixed on the server: the visible boundary maps to the next document-ordered entry (Other terminals and helper tabs are skipped). Dragging Other terminals itself is still refused (unsupported). The client does not know that id, so this is left as-is (LOW)
Edit could prune a pane added under the version it writes against (list read concurrently with the doc) Codex Fixed: ovis-layout is read before the terminal list
Deep splits could give 0-width panes Codex Fixed: subtree minimum extents, as the client's layoutTree.ts; layout-doc.test.ts
Split reported success when placement failed; foreign schema still offered split Codex + omo (LOW) Fixed: ping offers no split/arrange and pane.split starts no shell under an unknown schema; a placement failure after the shell started answers layout_not_saved naming the pane
Same leaf named twice in a foreign-written doc shown twice omo (LOW, reproduced) Fixed: reconcile places it once

Validation at b109f31: bun run check fast pass (unit 11281 pass, 0 fail); bun test server/herdr-core/ 165 pass / 0 fail; live test vs real hc 0.1.14 7/0.

Pane rects on herdr-core are shares of a fixed 1000x1000 area now, so an
observer or keep_size attach that started at the pane's rect asked hc for
a 1000x1000 terminal. Panes carry their terminal's grid (HerdrPane.grid)
and the attach reads it first (paneGrid).

Also: a split in a zoomed tab unzooms it, so the new pane is in view; and
every child of a Herdr app stack shows again (Ovis cannot switch the
active one), only hidden nodes are held back.
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review round 2 (omo at b109f31: BLOCK on one reproduced HIGH). Fixed in f0a17c2:

Finding Severity Resolution
Observer / keep_size attach spawned at the pane's layout rect, now 1000x1000 layout units on herdr-core, resizing the shared terminal HIGH (reproduced) Fixed: herdr-core panes carry their terminal's own grid (HerdrPane.grid), and terminalInfoFor reads it first (paneGrid, server/core/pane-grid.test.ts). Herdr TUI panes keep using the layout rect
Inactive children of a Herdr app stack became unreachable MEDIUM (reproduced) Fixed: every stack child shows side by side again (Ovis cannot switch the active one); only hidden nodes are held back
Split in a zoomed tab kept the zoom, hiding the new pane MEDIUM (reproduced) Fixed: the split edit clears zoomed; adapter test
Split offered on Other terminals / helper tabs, then refused LOW (unreproduced) Left as is: the refusal is explicit (unsupported); per-tab gating can follow with #2806

Validation at f0a17c2: bun run check fast pass (unit 11282 pass, 0 fail); bun test server/herdr-core/ server/core/pane-grid.test.ts with real hc 0.1.14: 173 pass / 0 fail.

A terminal under a hidden node was left out of the snapshot, so closing
its tab or workspace from Ovis ended the shown panes and left it running
out of reach. Hidden nodes are laid out with the rest again, like stack
children: Ovis can neither show nor switch them, and each closes with
its tab.
Base automatically changed from feat/hc-parity-workspaces to main November 5, 2026 00:54
# Conflicts:
#	server/herdr-core/adapter.test.ts
#	server/herdr-core/adapter.ts
#	server/herdr-core/live.test.ts
#	server/herdr-core/snapshot.ts
#	server/herdr/client.ts
#	shared/machines.ts
#	src/components/CommandPalette.appLayout.test.tsx
#	src/components/CommandPalette.tsx
#	src/components/PaneCanvas.appLayout.test.tsx
#	src/components/Sidebar.appLayout.test.tsx
#	src/components/Sidebar.tsx
#	src/components/TabStrip.appLayout.test.tsx
#	src/lib/machineContext.test.ts
#	src/lib/machineContext.tsx
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Merged origin/main (with #2799) at 89405e8, no force-push. bun run check fast passes (unit 11312 pass, 0 fail). dori review at 89405e8: CLEAR.

Remaining LOW findings, not fixed in this PR (one fix round is spent):

  • A layout.set_split_ratio retry after a conflict reapplies the same path to a tree another writer just changed. It needs a second writer within milliseconds, and the user can drag the divider back.
  • layout_not_saved (both CAS attempts lost) is only logged by the palette, not shown to the user.
  • Split and reorder are offered core-wide but refused (unsupported) on Other terminals and helper tabs. This is per-tab gating, which can follow herdr-core: hide split, rename and move on targets the adapter refuses (Other terminals, helper tabs) #2806.
  • Herdr-app weights are clamped to 10-90% in chain, so a 20:1 row shows as 90/10 (read-only there).

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Merged origin/main (with #2829) at 587fc39 with no conflicts and no force-push. bun run check fast passes (unit 11327 pass, 0 fail); herdr-core + layout-gating tests 196/0. dori review at 587fc39: CLEAR. Its two LOWs are already listed above (split/arrange offered on Other terminals / helper tabs, which are refused before anything starts; ratios from weights or equal shares are clamped to 0.1-0.9, so wide rows aren't exactly equal), and are left for a follow-up.

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Merge note: Ovis-owned 'ovis-layout' doc + top-down geometry, fixes #2812. omo CLEAR at 587fc39, Codex Terra xhigh no HIGH (reproduced HIGH/MEDIUMs fixed earlier), required checks green. CodeRabbit skipped.

@devswha
devswha merged commit a1de8d2 into main Nov 5, 2026
21 checks passed
@devswha
devswha deleted the feat/hc-layout-doc branch November 5, 2026 02:07
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: lay out split panes top-down so they do not shrink each other, then offer split

1 participant