Summary
Staged AI mindmaps are keyed only by boardId, and the drain in useHarnessApplyMindMap runs against store.getAllNodes() of whatever layer is mounted when it fires. If a mindmap is staged while the board isn't ready (or before the user navigates) and the user enters a sub-folder layer before ready flips true, the drain places the staged cluster into that sub-layer with parentId = rootId of the wrong layer.
Location
webui/src/features/board/harness/agent/use-harness-apply-mindmap.ts (effect deps include rootId + ready; clusters keyed by boardId only).
Repro (race)
- Stage a mindmap for board B (e.g. an AI Spark transform result) while B is still hydrating (
ready === false).
- Before
ready flips true, navigate into a sub-folder (root_id changes).
- Drain fires on the sub-layer → the cluster lands in the sub-folder it was never meant for.
Impact
Notes appear in the wrong folder. Low probability (requires staging during hydration + a navigation in the same window), but silently wrong when it happens.
Suggested direction
Tag each staged mindmap with the rootId (layer) it was authored for, and have the drain place it into that layer — not whatever layer happens to be current when hydration completes. (Pairs with the working-folder / headless-write direction in docs/plans/agent-board-authoring-tools.md.)
Found during /code-review high on #250; pre-existing (introduced with the mindmap placement work in #248), unrelated to that PR.
Summary
Staged AI mindmaps are keyed only by
boardId, and the drain inuseHarnessApplyMindMapruns againststore.getAllNodes()of whatever layer is mounted when it fires. If a mindmap is staged while the board isn'tready(or before the user navigates) and the user enters a sub-folder layer beforereadyflips true, the drain places the staged cluster into that sub-layer withparentId = rootIdof the wrong layer.Location
webui/src/features/board/harness/agent/use-harness-apply-mindmap.ts(effect deps includerootId+ready; clusters keyed byboardIdonly).Repro (race)
ready === false).readyflips true, navigate into a sub-folder (root_id changes).Impact
Notes appear in the wrong folder. Low probability (requires staging during hydration + a navigation in the same window), but silently wrong when it happens.
Suggested direction
Tag each staged mindmap with the
rootId(layer) it was authored for, and have the drain place it into that layer — not whatever layer happens to be current when hydration completes. (Pairs with the working-folder / headless-write direction indocs/plans/agent-board-authoring-tools.md.)Found during
/code-review highon #250; pre-existing (introduced with the mindmap placement work in #248), unrelated to that PR.