Repository navigation
fix(sidebar): stack same-branch hosts at every level of a workspace hierarchy - #456
Merged
Merged
Conversation
A root workspace with lineage children was excluded from the Group by branch merge, so as soon as one host's checkout gained a child, that branch split back into one row per host and lost the host selector. Roots with children now merge like any other root. The merged card owns the union of every member's children: the chip counts and summarises all of them, their rows are drawn beneath the card even when they belong to another host, and one click folds the whole union — the card writes and clears every member's lineage group key at once, so it can never sit half collapsed. Revealing a child unfolds every key of the card it hangs under. Verification: branch-groups merge tests (stacks a parent with children, unions the counts, moves the other host's subtree up, folds all members, collapse-key toggle tests, tc:web, check:changed (only the three pre-existing baseline-drift ratchets fail: direct-link-open, main-blocking-api, react-compiler-compat). Not verified: rendered UI with two live hosts. EOF )
…ierarchy A root workspace with lineage children was excluded from the Group by branch merge, so as soon as one host's checkout gained a child, that branch split back into one row per host and lost the host selector. The merge is now a recursive pass over the row tree: siblings are grouped by branch at every depth, not only at the root. The same hierarchy on two hosts therefore collapses into one tree in which every workspace — parents and children alike — carries the host dropdown, and each level's card owns the union of its members' subtree. The dropdown changes only what the card represents (its agents and terminals): children are always the union across every member, so the child list under a card is identical whichever host it shows. Host picks are resolved by row key, so a nested card on the same branch as its parent activates its own member. Review round 1 (claude/opus, high) found three SHOULD-FIX: - the half-collapsed union showed folded but the first click folded again, so nothing changed on screen; the key set now folds only when nothing is folded, and the shortcut's expand detection matches it; - a non-primary member's workspace could not reach the child-workspaces shortcut; the fold keys are published per workspace, including the hosts a card absorbed, on their own channel so the Cmd+1-9 order is untouched; - the sidebar-closed fallback derived keys without the merge; it now applies the same gated merge. Reveal also stops unfolding other hosts' groups when no merge happened, and a merged card's child count is the sum of its members' counts (ids can repeat across hosts).
- A depth-less row (section header, imported-worktrees card) attached to the open workspace above it, so a merged last row of a section could swallow the next section's header and reorder or hide the rows under it. It now closes the subtree stack and lands at the root, as the pre-recursion walk did. - Reveal matched members only for root ancestors, leaving a nested card folded and its revealed child hidden. Members are now the ancestor's same-branch siblings at its own level, which is what the merge grouped. - A card counted workspaces while it drew cards: two children on two hosts are one nested card, so the chip now counts the rows the next level renders — except when folded, where the hidden rows are still counted.
…vel by level Reveal still left a nested card folded: it matched members among rows sharing an occurrence parent, but a merged card's members sit under different parents (each host's own. Members are now resolved the way the merge resolves them — the same-branch workspaces among the previous level's members' children — so revealing a leaf clears every key of every card above it, at any depth. Covered by a new test on the reveal itself (no test reached it before): a folded mid card on both hosts, reveal a leaf under one of them, expect both keys. EOF )
A pinned root is never one of the merge's candidates, so a three-host hierarchy with the local root pinned resolved level 0 to the other two hosts and dropped the pinned ancestor from the walk, leaving it folded when a child was revealed. A level now falls back to the ancestor alone when the resolved member set does not contain it.
…de-dupe an import The fork's upstream-file-comments ratchet refuses added comment lines above upstream's code: they are conflict adjacency, and the sync that measured it paid for them hunk by hunk. The rationale lives in the fork-owned merge modules, so the comments come off the six upstream files this branch touched — 5113/5113 on the frozen baseline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported: a branch checked out on two hosts —
M5 StudioandWin— stops being one stacked cardwith the host selector the moment one of the two checkouts gains a child workspace. With no child the
rows merge as intended; add one and the branch splits back into one row per host. Asked for on top of
that: when the same hierarchy exists on both hosts, every workspace in it should carry the
dropdown and only one hierarchy should be drawn, and changing a dropdown must switch that card's
agents and terminals but not the child workspace list.
Two defects produced the first symptom. The merge's candidate filter rejected any row with
lineageChildCount > 0, an exclusion written before lineage rows existed; and the merge only everlooked at depth-0 rows, so a hierarchy could only stack on its top level. The tab strip's
getBranchGroupMembersForWorktreenever had the exclusion, which is why the strip and the sidebardisagreed.
What changed
grouping/same-branch-row-merge.ts,same-branch-merged-row.ts,sidebar-row-forest.ts). The row list is read as a depth-keyed tree, siblings are grouped by branchat every level, and the result is flattened back. The same three-level hierarchy on two hosts is now
three stacked cards, each with the host dropdown, not two trees.
unions, and every member's children are drawn under the card in host order — so the child list is
the same whichever host the card shows. One chip click folds the union: the card writes and clears
every member's lineage group key at once and reads folded if any is folded, so it can never sit half
collapsed and strand rows.
use-branch-group-host-selection.ts), so a nested card on thesame branch as its parent activates its own member instead of the parent's.
indexLineageFoldKeys+ asetVisibleLineageFoldKeyschannel,
visible-worktrees.ts). It keys the hosts a card absorbed, which render no row of theirown, so the child-workspaces shortcut works when the active workspace is a non-primary parent or a
relocated child — without touching the Cmd+1-9 order, which names rows.
worktree-reveal-group-keys.ts). Members are resolved the way themerge resolves them — the same-branch workspaces among the previous level's members' children — so a
leaf under a folded nested card clears every key above it.
Decisions
dropdown is the requirement, and it is what makes the child list host-independent: each level folds
only its own members.
the strip already lists every host's sibling checkout, so the sidebar now agrees with it.
count is the rows the next level renders. A folded card still counts the rows it hides.
host, it draws twice rather than guessing which host's parentage wins.
(rows become host sections), and two checkouts of one branch on the same host (ambiguous — one
would hide behind the dropdown).
Verification
orca-queue node local/gate-unit.mjsc44c31aafbpnpm test(merge, reveal, host-pick, collapse-toggle)pnpm tc:webpnpm check:changedpnpm run audit:code-quality:nativenode local/check-upstream-file-comments.mjsThe three failing
check:changedratchets (direct-link-open,main-blocking-api,react-compiler-compat) are pre-existing baseline drift in files this branch does not touch.Tests added: a three-level hierarchy on two hosts collapses to three cards, each with both hosts in
its dropdown; child counts follow the cards drawn; a nested card folds without folding its parent;
children on their own branches still relocate under the merged parent; deep chains (to depth 3) move
intact; a child never merges with its parent; the child list is the same whichever host a card shows;
the collapse-key toggle unfolds a half-folded set rather than re-folding it; the reveal clears both
keys of a folded nested card.
Disclosed, not fixed in this PR
workspace") because a folded member's child rows were never planned, so the count can only be
recomputed once they exist.
child also switches the parent's card (only the child is activated).
isLastLineageChild— each host's own last child. Only theparity/golden serializer reads that flag.
LOCAL_EXECUTION_HOST_IDas its reference host; a clientwhose default host is remote could merge differently there than the mounted list does.
Reviewed by Opus 5.5, high: R1 (3 blocking fixed), R2 delta (1 blocking fixed), R3 delta (1 blocking fixed), delta clean on R4 (1 MINOR fixed as prescribed)
The review covers the code as of
3893e557ce. The follow-up commits since then only satisfy the fork lint gate: they remove the fork comment lines this branch had put above upstream-owned files (local/check-upstream-file-comments.mjs, back to its frozen 5113) and merge one duplicated import thataudit:code-quality:nativerefuses. No behaviour changes.