LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtNov 16, 2026, 12:57 AM
updatedAtNov 16, 2026, 2:14 AM
githubUrlhttps://github.com/neomjs/neo/issues/21062
authorneo-opus-grace
commentsCount0
parentIssue21061
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[ ] 21063 Web desktop: sign-in, launcher and start menu follow permissions
closedAtNov 16, 2026, 2:14 AM

A tree-store menu shows records the store's filters hide

neo-opus-grace
neo-opus-grace commented on Nov 16, 2026, 12:57 AM

Context

Found while shaping #21061: permission-driven navigation filters one Neo.data.TreeStore and lets a Neo.menu.List cascade render it. The menu ignores the filter.

Reproducer (test/playwright/unit/menu/ListTreeStore.spec.mjs fixture: file → (file-new → file-new-f, file-open), edit → edit-copy, about), red on dev @ fbb9c4da19:

  • Filter set before the menus exist. {property: 'text', value: 'Copy'} keeps edit and edit-copy only, yet the root menu lists file, edit, about.
  • Filter changed while the menus exist. {property: 'text', operator: 'included', value: ['New', 'Copy']} leaves the root at file, edit, about and the file level at file-new, file-open.

Note for readers: TreeStore filtering is ancestor-aware. A group that matches a filter itself keeps its whole subtree, so a filter like id !== 'file-open' keeps file-open because file matched. That is intended tree semantics, not this bug. (This body's first version cited exactly that case as a symptom; corrected.)

The Problem

A menu level never consults the tree store's filter mask:

  1. syncLevelRecords() fills a level from TreeStore#getChildren() (src/menu/List.mjs:985-992), which reads the Structural Layer and is documented as independent of filtering (src/data/TreeStore.mjs:750-752).
  2. A level subscribes to the source store's mutate, recordChange and sort (src/menu/List.mjs:759-764), not filter, so a filter applied after the menu exists never reaches it.
  3. onSourceStoreMutate() (src/menu/List.mjs:926-943) adds every record that belongs to the level, including ones the active filter hides.

Any app that narrows a menu by data (permissions, feature flags, a search box over a command menu) shows items the store says are gone.

The Architectural Reality

Design authority: #17839, which introduced tree-store menus, states in its Out of Scope that the menu adopts "TreeStore for its structural half (#childrenMap, ancestor-aware filtering)", and menu.List#sourceStore documents "The tree store is the single source of truth and is shared by every level of the cascade" (src/menu/List.mjs:192-199). The levels read the structure but not the filter, so the intent never reached them.

TreeStore#getChildren()'s filter independence is its own contract for structural reads (src/data/TreeStore.mjs:740-766) and stays unchanged; the mask applies at the level. #17839's rejected alternative (each level rendering a filtered subset of the shared store, unsafe for list.Base index math) is not reopened: each level keeps its own flat store and only adopts the tree's mask when deriving it.

TreeStore filtering is ancestor-aware (src/data/TreeStore.mjs:588-713): a node is kept when it matches, when an ancestor matched, or when a descendant matched. _keptNodes holds the mask (null when unfiltered). A level that adopts the mask shows what a tree grid over the store shows at that depth, expansion aside.

The Fix

  • src/data/TreeStore.mjs: public isKept(nodeOrKey) answers whether the active filters keep a node (record, raw node or key, with the canonical-key fallback get() uses). The internal projection loops (collectVisibleDescendants(), updateSiblingStats()) keep reading the mask directly: they already hold canonical keys on a hot path.
  • src/menu/List.mjs:
    • syncLevelRecords() adds only children isKept() keeps.
    • onConstructed() also subscribes to the source store's filter event (onSourceStoreFilter() re-derives the level, the shape of onSourceStoreSort()); destroy() unsubscribes it symmetrically.
    • onSourceStoreMutate() skips additions isKept() rejects.
    • When a re-derive or a removal takes away the record whose submenu is open, that submenu hides, so no floating level outlives its item.

Contract Ledger

Surface Authority Contract / fallback Documentation Evidence
TreeStore.isKept(nodeOrKey) Existing ancestor-aware filter() mask and Store key resolution Record, raw node or key → Boolean; canonical-key fallback; no active mask keeps nodes independently of expansion New method JSDoc beside structural getChildren() Real TreeStore/menu filter controls
TreeStore.getChildren(parentId) Existing Structural Layer contract Still returns all direct children, including filtered-out children; current sibling ordering remains the store's Existing method JSDoc Structural read assertion under an active filter
Tree-driven Menu.List levels Shared source store; level-owned flat stores Adopt the source mask on derive/filter/mutate; hide a cascade whose item leaves; detach the filter listener at destruction; classic items unchanged Level derive, event and cleanup methods Existing owning spec plus new filter, identity, cascade and teardown controls

Acceptance Criteria

  • With a filter set before the menu exists, every level (root and nested) lists only kept records: red on dev, green after.
  • Changing or clearing the tree store's filters re-derives every live level, including an open submenu.
  • A record added under an active filter appears in its level only when the filter keeps it.
  • A filter that hides the record whose submenu is open hides that submenu.
  • A destroyed level leaves no filter listener on the source store (extends the existing "no listener behind" test in test/playwright/unit/menu/ListTreeStore.spec.mjs).
  • TreeStore#getChildren() still returns filtered-out children; its existing tests stay green.
  • Classic nested-items menus are unchanged (existing classic test stays green).
  • npm run test-unit -- test/playwright/unit/menu test/playwright/unit/data green.

Out of Scope

  • Changing TreeStore's ancestor-aware filter semantics.
  • Filtering classic nested-items submenus (they are built from plain arrays, not from a store).

Related

  • Parent: #21061; its permission shell consumes this.
  • Origin of tree-store menus: #17839.

Live latest-open + closed sweep: see #21061 (same sweep, 2026-11-15T23:54Z); no equivalent or prior exclusion found.

Origin Session ID: f1b70a0d-406f-4b7d-a69c-20d35c843303 Retrieval Hint: "menu.List TreeStore sourceStore filter syncLevelRecords getChildren isKept"