Files
orca/tests
Neil 3f2b778b38 fix(sidebar): decouple agent-list expansion from the child-worktrees toggle
A worktree card's inline agent list keeps two disclosure states — the compact
"N agents" summary and per-parent agent-lineage folds. Both lived in local
useState on WorktreeCardAgents. Toggling the sibling "N child workspaces" chip
mutates the collapsedGroups store, which flips the parent card between an `item`
and a `lineage-group` render row. That changes its virtualizer key
(getRenderRowKey) and remounts WorktreeCard, wiping the agent list's local
expansion — so folding one section visibly reset the other. The same remount
fires on virtualizer scroll-recycle, resetting expansion on scroll too.

Lift the agent-list expansion into a session-scoped, LRU-bounded per-worktree
module cache (useWorktreeAgentExpansionState), mirroring the existing
pr-comments-list-selection "survive sidebar remounts" pattern. Expansion now
persists across the remount, keeping the two sections independent.

Tests:
- WorktreeCardAgents.expansion-remount: unit durability + cache bounds/isolation
  (fails against the pre-fix component, passes with the fix).
- WorktreeList.lineage-agent-expansion-coupling: real WorktreeList + real
  WorktreeCardAgents, virtualizer mock honoring getItemKey, proves the remount
  no longer resets agent expansion in full and compact modes.
- e2e worktree-lineage-agent-expansion: real app asserts the expanded "N agents"
  summary survives a child-worktrees toggle.
2026-07-13 01:47:29 -07:00
..