Repository navigation
perf(renderer): keep worktree lineage map identity on no-op refresh - #14217
Conversation
A host-scoped lineage refresh always spread IPC clones into new maps, so WorktreeList Object.is subscriptions missed every time even when capture, taskId, and coordinatorHandle were unchanged. Reuse structurally equal records, return the previous maps when nothing moved, and skip set() when both maps are still current so a no-op refresh is actually a no-op. Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe change adds Mergeability Score: ⚪ Minimal · up to The change preserves lineage-map identity during unchanged refreshes and adds coverage for cloned and hydrated snapshots; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
Widen reuseEqualRecordMap and the renderer lineage store fields to Readonly<Record<...>> so a reused no-op refresh map cannot be mutated in place. Co-authored-by: Orca <[email protected]>
mergeExactHostLineage was writing into AppState map types after they became Readonly. Use local mutable Records, then reuseEqualRecordMap. Co-authored-by: Orca <[email protected]>
The lineage overlay rewrite pushed the file to 305 counted lines against the 300 cap, failing oxlint. Fold the duplicated per-map filter/overlay into one scoped helper so both maps share it. Co-authored-by: Orca <[email protected]>
A key missing from next always shows up as either a key-count mismatch or a failed previous lookup in the first pass, so the second pass over the previous keys could never flip identical. Cover the identity contract with focused unit tests, including the same-count key swap that the removed loop appeared to guard. Co-authored-by: Orca <[email protected]>
Summary
A no-op worktree lineage refresh still allocated new
worktreeLineageById/workspaceLineageByChildKeymaps becausemergeLineageForHost,mergeWorkspaceLineageForHost, andmergeExactHostLineagealways spread the incoming payload. Worktree rows were already gated; these maps were not.WorktreeListObject.is-subscribes to both maps, so every refresh missed.This keeps the previous record when
areValuesEqualsays the incoming IPC clone is unchanged, returns the existing map when every key/value is still current, and skipsset()fromrefreshWorktreeLineageForSettings/refreshRemoteWorktreeLineageBestEffortwhen both maps are===current — the same shape as the worktree-row early return.Why a partial fix is inert
Identity has to survive every link from fetch to
set(). Reusing worktree rows but still spreading lineage maps, or comparing withObject.isafterstructuredClone/ hydrate rebuilds nestedcapture, still produces a new map and a new store write. The SSH host snapshot path had the same always-spread hole; fixing only the local list merge would leavemergeExactHostLineagechurning the same subscribers.Why reference compare fails
Lineage records are nested (
capture,taskId,coordinatorHandle). IPC already clones; hydrate rebuilds nested objects.Object.isnever hits after that, so the merge has to structurally compare withareValuesEqual/reuseEqualRecordMaprather than treating a new object as a new value. Main-processstructuredCloneis not the primary fix — the renderer merge still has to reuse.Tests
parentWorktreeId+ nestedcapture+taskId+coordinatorHandle.listLineage/ host snapshot mocks returnstructuredClone(payload)so the incoming object is never the stored one.fetchWorktreeLineagetwice keeps both maps and entry refs; host-scoped merge keeps other-host rows by identity.toEqualtests against the same mock object are not sufficient.Follow-up to #13744 / #13770 / #13803.
Made with Orca 🐋