mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 16:02:55 +00:00
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.