Context
Leaf of #21061. @neo-gpt-emmy's review of #21070 found it: with the start menu's cascade open two levels deep, collapsing their ancestor in the source tree and expanding it again closes the still-permitted grandchild. #21068 (resolving #21062) merged at 01:14Z before the fix could land there, so the fix gets its own ticket.
The Problem
Reproduced on dev @ d940179245 with a new arm in test/playwright/unit/menu/ListTreeStore.spec.mjs: root → File → New open, then treeStore.collapse('file'):
Expected: ["file-new", "file-open"]
Received: []
The File level empties, and #hideOrphanedSubMenu() (added by #21068) then finds no item for the New submenu and closes it. Before #21068 the rows already left and came back on expand; only the open grandchild survived. A level that renders structure loses its rows to an expansion change it does not render.
The Architectural Reality
TreeStore#collapse() (src/data/TreeStore.mjs) removes a branch's visible descendants from the Projection Layer through Collection#splice, which fires mutate with them as removedItems. The Structural Layer keeps them: TreeStore#get() falls back to #allRecordsMap. A real removal deletes a node from #allRecordsMap before mutate fires.
menu.List#onSourceStoreMutate() (src/menu/List.mjs) splices every removedItems entry of its level out of the level store, so a collapse reads as a removal; expand() then re-adds the rows as addedItems.
- Design authority: the
TreeStore#getChildren() JSDoc, "Independent: expansion and filtering. A collapsed or filtered-out branch still returns its children, because visibility is a property of the projection, not of the hierarchy." The spec arm "a child level reads through the COLLAPSED tree — expansion is not a rendering prerequisite" pins the same contract for a level's first render.
The Fix
In menu.List#onSourceStoreMutate(): a removed record leaves the level only when sourceStore.get() no longer resolves it, and an added record joins only when the level store does not already list it. No TreeStore change.
Acceptance Criteria
Out of Scope
- A menu that renders the tree's projection rather than its structure; none exists.
- The web desktop's own repairs on #21070.
Related
Live latest-open + closed sweep: checked latest 20 open (59 open, red band: the owning epic #21061 takes this as a leaf, and the resolving ticket #21062 is closed) + open and closed search (menu collapse submenu tree; closed hits #17839, #18870, #17860 read, none governs a collapse) + A2A last 30 + Memory Core (menu level collapse submenu) + own open assignments at 2026-11-16T01:19Z; no equivalent or prior exclusion found.
Retrieval Hint: "menu level tree collapse removedItems projection structural layer open submenu orphan"
Context
Leaf of #21061. @neo-gpt-emmy's review of #21070 found it: with the start menu's cascade open two levels deep, collapsing their ancestor in the source tree and expanding it again closes the still-permitted grandchild. #21068 (resolving #21062) merged at 01:14Z before the fix could land there, so the fix gets its own ticket.
The Problem
Reproduced on
dev@ d940179245 with a new arm intest/playwright/unit/menu/ListTreeStore.spec.mjs: root → File → New open, thentreeStore.collapse('file'):The File level empties, and
#hideOrphanedSubMenu()(added by #21068) then finds no item for the New submenu and closes it. Before #21068 the rows already left and came back on expand; only the open grandchild survived. A level that renders structure loses its rows to an expansion change it does not render.The Architectural Reality
TreeStore#collapse()(src/data/TreeStore.mjs) removes a branch's visible descendants from the Projection Layer throughCollection#splice, which firesmutatewith them asremovedItems. The Structural Layer keeps them:TreeStore#get()falls back to#allRecordsMap. A real removal deletes a node from#allRecordsMapbeforemutatefires.menu.List#onSourceStoreMutate()(src/menu/List.mjs) splices everyremovedItemsentry of its level out of the level store, so a collapse reads as a removal;expand()then re-adds the rows asaddedItems.TreeStore#getChildren()JSDoc, "Independent: expansion and filtering. A collapsed or filtered-out branch still returns its children, because visibility is a property of the projection, not of the hierarchy." The spec arm "a child level reads through the COLLAPSED tree — expansion is not a rendering prerequisite" pins the same contract for a level's first render.The Fix
In
menu.List#onSourceStoreMutate(): a removed record leaves the level only whensourceStore.get()no longer resolves it, and an added record joins only when the level store does not already list it. NoTreeStorechange.Acceptance Criteria
collapse('file')keeps both levels' rows and the open New submenu, and the followingexpand('file')lists each row exactly once (unit arm, red ondev).test/playwright/unit/menu/stays green.Out of Scope
Related
Live latest-open + closed sweep: checked latest 20 open (59 open, red band: the owning epic #21061 takes this as a leaf, and the resolving ticket #21062 is closed) + open and closed search (
menu collapse submenu tree; closed hits #17839, #18870, #17860 read, none governs a collapse) + A2A last 30 + Memory Core (menu level collapse submenu) + own open assignments at 2026-11-16T01:19Z; no equivalent or prior exclusion found.Retrieval Hint: "menu level tree collapse removedItems projection structural layer open submenu orphan"