Repository navigation
Add settings-section and database settings-slot extension points - #3392
Conversation
Pragmatic code review: PR #3392 (closes #3312)Review TypeInitial Review (medium depth). I read the diff against Requirements Check (issue #3312)Settings sections
Database slots
No behaviour change
Step 7 (fixture): ✅ flags Ratchet accounting (verified). Added/removed diff lines matching marker patterns: Code Review FindingsI found no correctness bugs in the placement algorithm. Details of what I checked, so the author does not have to redo it:
🟡 Important
🟢 Suggestions / Nits
What is done well
RecommendationAPPROVE (non-blocking follow-ups: items 1 and 2 should be settled before or right after merge; the rest are optional polish). No correctness, security or architectural defects found. |
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.
Address-review summary for the pragmatic review of this PRAddressed in Addressed
Skipped, with reasons
Not done here
After the changes: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The follow-up commit changes comments and documentation and adds two test assertions. It touches no production logic. The one behavioural claim (cycle warning) is backed by a mutation check. |
Extensions can now contribute a Settings sidebar category and its pane (placed by `after`, receiving `navigate`) and content for the Databases page: `database.actions` in the header and `database.row` inside each database row (receiving `databaseId`). - ui-extensions: SettingsSectionContribution, SettingsSlot, SettingsSlotContribution, `settingsSections` / `settingsSlots` on NodespaceExtension, and the `settingsSections()` / `settingsSlotFor(slot)` lookups; reactive `getActiveSettingsSections()` / `getActiveSettingsSlot()`. - settings-categories.ts holds core's category list as data plus `settingsCategories()`, `isSettingsCategoryVisible()` and `findSettingsSection()`: core ids win over section ids, the first registered section wins among sections, sections sit after their anchor (a hidden anchor keeps its place) and otherwise before About, and a section anchored to itself or into a cycle is listed before About. - The sidebar renders that list; the pane falls back to Database whenever the active category is not listed and mounts a contributed section through the isolated ExtensionOutlet. - database-settings mounts the two slots. - The test-extension fixture gains a section, a header action and row content (plus a throwing row). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…hosts - Assert the warning for a self-anchored section and for an anchor cycle, using an extension id per test since warn-once state lives for the process. - Document that unanchored sections follow sections anchored to the entry above About, that byPriority sorts in place, that settingsSections() keeps registration order, and that the outlet is also hosted by Settings. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
f1be33d to
2001cde
Compare
Closes #3312
Adds the settings extension points from ADR-082 §2.2 (proposed) so that Account, "Add synced database…" and the per-database sync badge can later move out of core. With nothing registered, Settings renders exactly as before.
What changed
plugins/ui-extensions.ts,.svelte.ts). New typesSettingsSectionContribution,SettingsSlot,SettingsSlotContribution;NodespaceExtensiongainssettingsSections?andsettingsSlots?. The registry gainssettingsSections()(registration order) andsettingsSlotFor(slot)(descending priority, ties in registration order). The reactive wrapper gainsgetActiveSettingsSections()andgetActiveSettingsSlot(slot), both filtered throughisContributionActive. The new types are in one delimited block so the Add the virtual:nodespace-extensions build entry and the extension-api import alias #3311 rebase stays small.settings-categories.ts(new). Core's category list as data (CORE_SETTINGS_CATEGORIES, with the Labs gates moved over verbatim) plussettingsCategories(),isSettingsCategoryVisible(id)andfindSettingsSection(id). The four steps follow the issue: start from the full core list so a hidden anchor keeps its place; drop sections whose id collides with a core id or an earlier section (logged); insert each section after itsafter(same-anchor sections by priority, then registration order; absent or unknownaftergoes before About); drop hidden core entries and sections whosewhen()is false or throws.settingsCategories(), keyed bycategory.key.if (!isSettingsCategoryVisible(activeCategory)) activeCategory = 'database'. That covers the Labs gates, an unknown or unregistered id (which used to render an empty pane), and a section whosewhen()turns false while open. A contributed section mounts throughExtensionOutlet, keyed by the section key, with anavigateprop. TheAccountSettingsbranch is untouched.database-settings.sveltemountsdatabase.actionsafter the existing header buttons anddatabase.row(with{ databaseId }) inside each row's left column. The slot lookups are$derivedonce per render, not once per row. The Pro button, explainer, badge and dialog are untouched.tests/fixtures/test-extension): a section (id, label, after, priority options), a header action, row content, and a throwing row component.Deviations from the issue text
settingsSlotForandgetActiveSettingsSlotare one generic signature (S extends SettingsSlot, returningKeyed<Extract<SettingsSlotContribution, { slot: S }>>[]) rather than one overload per slot. Call sites are typed identically, and a new slot needs no new overload.after, or sits on anaftercycle, is listed before About instead of being lost, and is logged. The issue does not cover this case; without handling, such a section would silently never appear.byPriorityis now exported fromui-extensions.tsso the category list orders same-anchor sections by the registry's own rule.after: 'labs', then unanchored), each group in priority then registration order.createTestExtensiontakes a secondoptionsargument for the section, and there is a small shared test helper (tests/helpers/labs-flags.ts) that sets every Labs flag generically.For #3311:
SettingsSectionContribution,SettingsSlot,SettingsSlotContributionandSettingsSlotContributionForare exported fromui-extensions.tsand belong in the extension-api type re-exports once both land.Pro-boundary ratchet
bun run scripts/check-pro-boundary.tsexits 0. No count rises above its ceiling and no baseline is raised. Marker lines this change removes and adds:cloudBindStatelabsFlags.syncEnabledcheck removed (-1), sidebar Account line removed (-1),settings-categories.tsAccount entry added (+1)proWordingThe one added marker line,
visible: () => labsFlags.syncEnabledinsettings-categories.ts, is class 3 (a planned move that adds no behaviour: it is the sidebar's existing Account gate, split into the data module). It is deleted together with the Account entry by #3325. Its tests use a generic set-all-flags helper, so no test line adds a marker.BASELINES are not lowered in this PR. The edit to
scripts/check-pro-boundary.tswas blocked by the permission classifier in the session that produced this change, so the ceilings are untouched. The check passes as is; the printed notice lists the tightening to paste (cloudBindState: 202,cloudSyncHooks: 0,proWording: 279at the time of writing; the last two also include reductions already merged by other changes).Tests
settings-categories.test.ts(34 tests): core order with all Labs flags on and off, each flag independently, placement byafter(core anchor, section anchor, hidden core anchor, hidden section anchor, unknown anchor, no anchor,after: 'about'), priority and registration-order ties, priority not moving a section across anchors, id collisions (core, hidden core, earlier section, dropped section not anchoring), warn-once, self-anchor and cycles,when()false and throwing,isSettingsCategoryVisible,findSettingsSection.settings-extension-sections.test.ts(14): sidebar position and label, hidden whilewhen()is false and reactive, selection by click and byinitialCategory, active highlight, workingnavigate('database'), fallback for an unregistered id and for awhen()that is false initially or turns false while open, core-id collision.database-settings-extensions.test.ts(9): header action renders once and only while visible, row content once per database with that row's id and inside that row, follows the list, nothing when there are no contributors, a throwing row component removes only its own outlet.ui-extensions.test.ts(+13): registration, keys, duplicate ids across lists, key conflicts, malformed input, ordering,when()never evaluated by lookups, and the active accessors.settings-pane-labs-gating,settings-pane-account-gating,settings-sidebar-labs-gating,settings-sidebar-account-gating,database-settings, andtest:free-users.Mutation check: 37 mutations applied one at a time to the source, each run against the covering tests and reverted. 36 were killed. One survived and is an equivalent mutant: removing
{#key activeSection.key}in the pane changes nothing observable, becauseExtensionOutletre-derives its load promise whenever the section it reads changes. The key stays for parity with the collection viewer host. Mutations covered every registry lookup and filter, each step ofsettingsCategories(collision rules, anchor resolution, priority, hidden anchors, cycle handling and its warning, warn-once), the pane's fallback effect, section dispatch andnavigate, the sidebar's active marker, and the two database slot outlets including the row'sdatabaseId.bun run test:changed(frontend + browser tiers) passes;quality:fixis clean (0 errors, 0 warnings).Not done: the manual
dev:tauricheck (Settings categories, database list, and the app menu's Integrations entry). There is no GUI in this environment; the Integrations path is an existing core id and is unaffected by the new fallback.🤖 Generated with Claude Code