Skip to content

board: staged mindmap can drain into the wrong layer during a hydration/navigation race #252

Description

@winlp4ever

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)

  1. Stage a mindmap for board B (e.g. an AI Spark transform result) while B is still hydrating (ready === false).
  2. Before ready flips true, navigate into a sub-folder (root_id changes).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions