Skip to content

feat(herdr-core): worktree actions and the branch line on the desktop app's runtime - #2899

Merged
devswha merged 7 commits into
mainfrom
fix/hc-worktree-actions
Nov 5, 2026
Merged

devswha merged 7 commits into
mainfrom
fix/hc-worktree-actions

Conversation

@devswha

@devswha devswha commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

On a server running OVIS_RUNTIME=herdr-core (the desktop app's runtime), a workspace on a git
repository had no worktree actions and no branch line, because hc has no worktree API and the
actions were hidden (#2451). This makes them work there, following the first two directions in the issue.

  • server/herdr-core/adapter.ts now answers herdr's worktree.list, worktree.create,
    worktree.open and worktree.remove by running git itself (server/herdr-core/worktrees.ts).
    Answers and error codes follow herdr's: not_git_worktree, linked_worktree_source,
    worktree_create_failed (a repository with no commit is refused with git's own wording, which
    the route already turns into repository_without_commits; newer git would otherwise make an
    orphan branch), worktree_not_found, ambiguous_worktree_branch, not_linked_worktree,
    dirty_worktree_requires_force. A checkout opens as a workspace of its own (a shell in its
    folder, like New workspace); the default folder is herdr's ~/.herdr/worktrees/<repo>/<branch>.
  • A workspace's herdr worktree facts are kept in an ovis.worktree terminal label, so the
    snapshot marks worktree workspaces and their repository's workspace, and the sidebar groups them.
    New tabs, splits and moved panes carry or drop the label.
  • workspace.close follows herdr's group rule: a repository workspace with open worktrees needs
    close_group, and closes them with it.
  • ping reports layout.worktrees (only on a core whose layout Ovis keeps), and appLayoutOf
    offers the worktree items from it instead of always hiding them on herdr-core.

Fixes #2823

Validation

  • Failing-first: the two new adapter tests (server/herdr-core/adapter.test.ts -t worktree,
    fake hc + a real git repository in a temp folder) fail on main and pass here.
  • bun test server/herdr-core src/lib/machineContext.test.ts src/components/*.appLayout.test.tsx server/workspace-routes.test.ts src/lib/useWorktreeBranches.hook.test.ts: pass; conventions tests pass; bun run typecheck passes.
  • OVIS_TEST_HC_BIN=<hc 0.1.14 from ci.yml> bun test ./server/herdr-core/live.test.ts: 7 pass.
  • Manual, real hc 0.1.14 in an isolated core + OVIS_RUNTIME=herdr-core server on loopback with a
    temp state dir: health says worktrees: true; through the HTTP routes, list, create, open again
    (already_open), close head without group (refused), remove dirty (refused) / forced (folder
    gone), close group (both closed, clean checkout kept). In the browser the repository row shows
    main under its name with the worktree grouped below, and its menu lists Pin, Rename, Earlier
    sessions, Close group, New worktree, Open worktree…, Collapse.
  • bun run check fast at 88d0f6b (contains main): workflow syntax, generated types/themes, typecheck, unit tests and build all ok (exit 0).

Review rounds

  • Round 1 (omo + Codex Terra xhigh at 222e228): nested repositories taken for the outer repository's checkout, a checkout moved or replaced outside Ovis still deleted, quoted paths from git worktree list, worktree calls on a core the Herdr app arranges, concurrent opens, trimmed open paths, a failed shell after git worktree add. Fixed in 5580fcf with a failing-first test.
  • Round 2 (omo at 6e7e422): git reuses .git/worktrees/<name> for a checkout added again at the same path, and an existing branch with a base was refused. The label now keeps the git folder's file identity; an existing branch ignores the base as herdr does; remove runs in the same queue. Fixed in bf28854, test extended (fails before, passes after).
  • Not changed (unreproduced, noted): a terminal started by a create whose snapshot read then fails is not ended; a create waiting in the queue does not count against the client's timeout.

…line

hc has no worktree API, so on herdr-core the sidebar hid New worktree, Open worktree
and Delete worktree checkout, and no branch line showed. The adapter now answers
worktree.list/create/open/remove by running git itself and opens a checkout as a
workspace of its own; the workspace's worktree facts live in an ovis.worktree label
so worktrees group under their repository. workspace.close honours close_group as
herdr does, and ping offers layout.worktrees on cores whose layout Ovis keeps.

Fixes #2823
@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 10 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 1dd4f3f and 39da22f.

Files selected for processing: 14

  • changelog.d/herdr-core-worktrees.md
  • server/herdr-core/adapter.test.ts
  • server/herdr-core/adapter.ts
  • server/herdr-core/live.test.ts
  • server/herdr-core/snapshot.ts
  • server/herdr-core/worktrees.ts
  • server/herdr/client.ts
  • shared/machines.ts
  • src/components/CommandPalette.appLayout.test.tsx
  • src/components/PaneCanvas.appLayout.test.tsx
  • src/components/Sidebar.appLayout.test.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

Review round for #2899: a workspace in a subfolder is a checkout's only when git says
so (nested repositories); remove refuses a checkout moved away or replaced, compared
by its own git folder kept in the label; git worktree list is read NUL-separated so
quoted paths match; worktree calls are refused where the Herdr app arranges the core,
and its labels are not read there; create and open run one at a time; open takes the
path as given; a create whose shell fails undoes the checkout and its new branch.
…ened

Second review round for #2899: git reuses .git/worktrees/<name> when a checkout is
added again at the same path, so the label keeps that folder's file identity
(device, inode, birth time) and remove refuses a checkout whose folder differs. An
existing branch is checked out as it is whatever base was asked, as herdr and the
dialog say. worktree.remove runs in the same queue as create and open.
@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying ovis with  Cloudflare Pages  Cloudflare Pages

Latest commit: 88d0f6b
Status: ✅  Deploy successful!
Preview URL: https://47c11e83.ovis.pages.dev
Branch Preview URL: https://fix-hc-worktree-actions.ovis.pages.dev

View logs

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review at 88d0f6b: CLEAR (omo + Codex Terra xhigh), no HIGH or MEDIUM. CodeRabbit was rate-limited and did not review this head. Left as LOW follow-ups:

  • worktree.open of a checkout already open in an unlabeled workspace returns that workspace without labeling it, so it is not grouped and offers no Delete worktree checkout.
  • openWorkspaces matches a labeled workspace by path only; after a checkout is removed and re-added outside Ovis, Open worktree returns the stale workspace (its remove is still refused by the git-folder identity check, so nothing is lost).
  • worktree.list answers for Other terminals (hc-other) when its first terminal is in a repository; the server refuses workspace.close there but not the listing.
  • A create/open waiting in the one-at-a-time queue does not count against the client's timeout, so a workspace can appear after the client gave up (a retry answers already open).

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate (owner-approved): reviewed head (omo CLEAR, threads resolved) with bun run check fast passing; held until the account PR #2867 landed and it still merges cleanly. Merged without waiting for GitHub CI.

@devswha
devswha merged commit 3be9938 into main Nov 5, 2026
21 of 23 checks passed
@devswha
devswha deleted the fix/hc-worktree-actions branch November 5, 2026 08:27
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: worktree actions and the branch line are missing from the sidebar

1 participant