Repository navigation
Add the collectionTreeRoots extension point to the sidebar collection tree - #3402
Conversation
Automated pragmatic-code-review (medium): APPROVEReview Type: Initial Review. HEAD reviewed: Requirements Check (#3314)Registry
Tree
Checks
📝 Deviations (all judged sound)
There are no Findings🔴 Critical: none. 🟡 Important (non-blocking)
🟢 Suggestions
Verified safe
Recommendation: APPROVE. The 🟡 is a worthwhile small addition in this PR. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above; one 🟡 (bound-root + extension-root getter test) to be addressed in this PR.
Address-review summary (commit
|
Automated pragmatic-code-review (medium), re-review of
|
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review re-review of 0554f30: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the re-review comment above.
Address-review summary (re-review of
|
… tree
An extension can name collections that the sidebar collection tree treats
as invisible containers (ADR-082 §2.2). NodespaceExtension gains an
optional collectionTreeRoots() function, and UiExtensionRegistry gains
collectionTreeRoots(), which returns the union of every extension's roots
in registration order. It calls each contributor on every lookup, so a
caller inside a derivation follows the reactive state that contributor
reads. A contributor that throws, returns something other than an array,
or is not a function counts as empty and is logged once until it next
returns normally (ADR-082 §2.4). Non-string entries are ignored.
buildCollectionsTree now takes a set of root ids, defaulting to
{ROOT_COLLECTION_ID}, and hides each one both as a parent and as a row.
The collectionsTree getter passes core's current root together with every
extension root, reading the plain registry so the store does not import
the reactive wrapper. With no extension registered the tree is unchanged.
The test extension fixture contributes testExtensionFlags.collectionTreeRoots
by default, and createTestExtension({ collectionTreeRoots }) overrides it.
The extension-api barrel exports CollectionTreeRootsContribution.
Closes #3314
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- collections.test.ts: a getter test with an active database whose root is set and an extension root, asserting both are hidden and the legacy root becomes an ordinary row. The fixture database carries only the two fields the getter reads. - collections-tree-roots.svelte.test.ts: reads collectionsTree inside a real $effect.root/$derived and checks it re-runs when the state the extension's collectionTreeRoots reads changes, and again when it changes back. - eslint.config.js: rune globals for src/tests/**/*.svelte.test.ts, where Svelte compiles runes. - ui-extensions.ts: the class doc names collectionTreeRoots() as the one lookup that runs extension code, and failingTreeRoots sits beside extensions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
0554f30 to
f3b13fc
Compare
Summary
Adds the collection-tree roots extension point from ADR-082 §2.2. An extension can name collections that the sidebar collection tree treats as invisible containers. Core unions every extension's roots with its own current root. With no extension registered, the tree is unchanged.
Closes #3314
Changes
src/lib/plugins/ui-extensions.tsNodespaceExtension.collectionTreeRoots?: CollectionTreeRootsContribution, whereCollectionTreeRootsContribution = () => readonly string[].UiExtensionRegistry.collectionTreeRoots(): ReadonlySet<string>:log.warnonce, and not again until it next returns normally (ADR-082 §2.4). The logged-once state is a per-registryWeakSetof extensions, mirroringwarnedKeysin the reactive wrapper.contribute.call(extension)), so a method-style contributor that readsthisworks.src/lib/stores/collections.svelte.tsbuildCollectionsTree(collections, locallyCreatedIds, pendingIds, rootCollectionIds: ReadonlySet<string> = new Set([ROOT_COLLECTION_ID])).!rootCollectionIds.has(p).!rootCollectionIds.has(c.id).collectionsTreegetter passesnew Set([boundRoot || ROOT_COLLECTION_ID, ...uiExtensionRegistry.collectionTreeRoots()]), with the comment the issue asks for.ui-extensions.ts), not the reactive wrapper, so the store does not pull in the wrapper's transitional built-in import.ROOT_COLLECTION_ID, theboundTenantCollectionread and thedatabaseStoreimport are kept for Remove the tenant-binding root fallback from the collections tree #3330.src/lib/extension-api/index.ts: exports theCollectionTreeRootsContributiontype alongside the other contribution types.Fixture (
src/tests/fixtures/test-extension/)collectionTreeRootsreturnstestExtensionFlags.collectionTreeRoots(reactive, default[]).createTestExtension({ collectionTreeRoots })overrides it through the existingoverridesparameter.resetTestExtension()clears the flag.Where this goes beyond the issue
null, a string, aSet, an array-like), acollectionTreeRootsthat is not a function, and a getter that throws. Each counts as empty and is logged once, the same as a throw. A string return would otherwise have added its characters as root ids.Pro-boundary ratchet
bun run scripts/check-pro-boundary.tsexits 0. BASELINES are unchanged: this PR doesn't lower them, as the epic directs, and it raises no count above its baseline.Delta against main. Two markers rise by one each:
cloudBindState: 201 → 202 (baseline 203)tenantWording: 453 → 454 (baseline 463)Every other marker is unchanged. Both rises come from one test-only line in
src/tests/stores/collections.test.ts:Class 2 (a fix to Pro code not yet moved).
databaseStore.activeDatabase?.boundTenantCollectionin thecollectionsTreegetter. This PR reshapes that line and the review asked for it to be tested.collections.svelte.tsthat Remove the tenant-binding root fallback from the collections tree #3330 also removes; the one reflowed doc comment keeps its count.Tests
src/tests/plugins/ui-extensions.test.ts, new describe "UiExtensionRegistry collection-tree roots" (22 cases):when()/load()are never evaluated;src/tests/stores/collections.test.tsnew Set([...]).buildCollectionsTreecases: two roots are both hidden (as parents and as rows); with an empty set a container shows as an ordinary row with its member collections nested; the legacy root is not hidden when it is absent from the set.ext-rootis hidden and its members are top-level (a nested child stays nested);src/tests/stores/collections-tree-roots.svelte.test.ts(added after review): readscollectionsTreeinside a real$effect.root/$derived, as the sidebar does. It checks that the derivation re-runs when the state the extension'scollectionTreeRootsreads changes, and again when it changes back.eslint.config.jsgains rune globals forsrc/tests/**/*.svelte.test.ts, where Svelte compiles runes.src/tests/build/nodespace-extensions-plugin.test.ts:expectTypeOfthat the barrel'sCollectionTreeRootsContributionequals the host's.Mutation check (every new test)
29 mutations, each caught by at least one new test. Each test file was restored after every run, and every new test is the target of at least one mutation.
Array.isArrayguardSetreturnsthiswhen()of chrome contributionswhen()/load()untrack(imperative reads still correct)CollectionTreeRootsContributionfrom the barrelsvelte-checkerror at theexpectTypeOflineCommands run
bunx vitest run src/tests/stores/collections.test.ts src/tests/plugins src/tests/build/nodespace-extensions-plugin.test.ts: 14 files, 429 tests passedbun run test(full frontend suite): 307 files, 5604 tests passedbun run test:changed: frontend Happy-DOM and Chromium passed (rust/skill/scripts not reached), at both commitsbun run --cwd packages/desktop-app test:free-users: 9 passedbun run --cwd packages/desktop-app quality:fix: eslint clean, design tokens clean, svelte-check 0 errors / 0 warningsbun run scripts/check-pro-boundary.ts: exit 0 (delta above)🤖 Generated with Claude Code