Repository navigation
Description
Summary
Switch the UI-extension registry from Pro variants to ADR-082's (proposed) contribution contract. Neither app changes visibly.
- The contract. A
NodespaceExtensioncarriesapiVersion. Each contribution is{ id, when?, priority?, load }, and hosts key it by<extension id>/<contribution id>. - Registration rules. A duplicate extension id, a version mismatch or a duplicate contribution id is logged and dropped, never thrown.
- The built-in Pro extension (
pro-plugin.ts):- translated one to one into
when()predicates over the variant machine; - gains a default export for the build entry;
- keeps registering itself until Stop importing the Pro extension in core; register it only through the build entry #3316.
- translated one to one into
- Hosts:
ChromeSlotOutletreplaces the app shell's inline slot loops.ExtensionOutletgains a load-failure path and a<svelte:boundary>.- The collection viewer keys its tabs by contribution key.
- Tests. A test fixture extension, plus generic registry and outlet tests that import nothing Pro.
Context
Paths are under packages/desktop-app/. Line hints are at af8ddb61; after #3309, locate code by symbol.
Registry files:
src/lib/plugins/ui-extensions.ts:ChromeContributionandViewerExtensionboth havevariantandlazyLoad;ViewerExtensionhastab: { appliesTo, id, label };UiExtensionDefinitionis{ id, name, version, chrome?, viewerExtensions? };UiExtensionRegistry.register()replaces by id.
src/lib/plugins/ui-extensions.svelte.ts: thegetActive*accessors filter withc.variant === resolveProSyncVariant().
src/lib/plugins/pro-plugin.ts:
proSyncUiExtension, which nothing else imports: 3 modal contributions (consent, relogin, connected) and 4collaborationtab contributions (sign-in, consent, relogin, connected).- The tabs all share
tab.id: 'collaboration', so the selected tab survives a variant change. - It registers itself as a side effect.
Hosts:
src/lib/components/layout/app-shell.svelte:- L37-38: imports;
- L692-702: the overlay slot
<div class=pro-sync-pill-slot>, keyed byc.variant. No extension contributes to it today. - L732-736: the modal slot, keyed by
c.variant; - CSS: L804 and L807-815.
src/lib/components/viewers/collection-node-viewer.svelte:- L26-38: imports, Pro comments and
collabExtensions; - L262-285: the tab strip, keyed by
tab.id; - L287-291:
{#key activeExtension.variant}.
- L26-38: imports, Pro comments and
src/lib/plugins/extension-outlet.svelte:{#await load() then mod}with no failure path.
Pro wrapper components:
src/lib/components/collaboration/collaboration-tab.sveltewrapsCollaborationView.collaboration-locked.svelteis the placeholder.pro-relogin-slot.sveltealready tolerates being remounted on a variant change; see its header.
ADR-082 rules:
- §2.1: a duplicate extension id logs an error and keeps the first registration. An
apiVersionmismatch is logged and the extension is not registered. - §2.3: hosts key by
<extension id>/<contribution id>. Order is descending priority, then registration order. - §2.4: a throwing
when()counts as false and is logged once. A rejectedload()renders nothing and is logged. A throwing component removes only its own outlet.
Scope
1. The contract, in src/lib/plugins/ui-extensions.ts
export const EXTENSION_API_VERSION = { major: 1, minor: 0 } as const;
export interface Contribution<P extends Record<string, unknown> = Record<string, never>> {
id: string; // unique within its extension, across all contribution lists
when?: () => boolean; // reactive and pure; absent = always shown
priority?: number; // higher renders first; default 0
load: () => Promise<{ default: Component<P> }>;
}
export type ChromeSlot = 'app-shell-overlay' | 'app-shell-modal';
export type ChromeContribution = Contribution & { slot: ChromeSlot };
export type ViewerTabContribution = Contribution<{ nodeId: string }> & { nodeType: string; label: string };
export interface NodespaceExtension {
id: string;
apiVersion: typeof EXTENSION_API_VERSION.major;
chrome?: ChromeContribution[];
viewerTabs?: ViewerTabContribution[];
}
// A contribution as a host sees it; key = `${extensionId}/${id}`
export type Keyed<C> = C & { extensionId: string; key: string };-
Remove:
- the
ProSyncVarianttype import and everyvariantfield; UiExtensionDefinition, together with itsnameandversion;ViewerExtensionandlazyLoad;tab.appliesTo,tab.idandtab.label.
- the
-
Rewrite the module doc (L1-21). It describes the registry behind ADR-082's frontend extension API:
- what an extension is;
- how it is registered:
registerExtensions(), called from the build entry; - how keys and ordering work;
- that lookups never evaluate
when.
No Pro wording.
2. Registration
This covers UiExtensionRegistry, the uiExtensionRegistry singleton, and a new registerExtensions.
register(ext):
- The identical object is already registered: a no-op, logged with
log.debug. This is needed whilepro-plugin.tsregisters itself and a build also injects the same object through the build entry (Add the virtual:nodespace-extensions build entry and the extension-api import alias #3311). - A different object has the same
id:log.errornaming the id, and the first registration is kept. ext.apiVersion !== EXTENSION_API_VERSION.major:log.error, and the extension is not registered.- A contribution
idrepeats within the extension (across all of its lists):log.error, and the later one is dropped. - It never throws, because a throw during registration would blank the app.
export function registerExtensions(extensions: readonly NodespaceExtension[]): void registers each extension in order. A non-array argument is logged and ignored.
Other methods:
- Keep
unregister(id),has(id)andall(), which returns extensions in registration order. Tests useunregister. chromeFor(slot)andviewerTabsFor(nodeType)returnKeyed<…>[]across all extensions. They sort by descendingpriority, break ties by registration order (extension first, then contribution), and never evaluatewhen.
3. src/lib/plugins/ui-extensions.svelte.ts
- Remove the
resolveProSyncVariantimport. - Keep
import './pro-plugin';, with a one-line comment: it is transitional, and is removed once builds inject extensions throughvirtual:nodespace-extensions(ADR-082 §2.1). - Add
isContributionActive(c):whenabsent: true;- a throwing
when: false, logged withlog.warnonce per key until it next returns normally (ADR-082 §2.4).
getActiveChromeContributions(slot)andgetActiveViewerTabs(nodeType)(renamed fromgetActiveViewerExtensions) filter through it.- Module doc: reactivity comes from whatever the predicates read, so hosts call these accessors inside a
$derivedor a template (ADR-049).
4. src/lib/plugins/pro-plugin.ts: a one-to-one translation
-
Add a helper that imports from
./pro-sync-variant.svelte:const whenVariant = (...variants: ProSyncVariant[]) => () => variants.includes(resolveProSyncVariant());
-
Declare
export const proSyncExtension: NodespaceExtension = { id: 'pro-sync', apiVersion: 1, chrome: […], viewerTabs: […] }. It is renamed fromproSyncUiExtension, which nothing else imports. Its contributions:
| Contribution id | Kind | when |
load |
|---|---|---|---|
consent-modal |
chrome, app-shell-modal |
whenVariant('consent') |
first-pro-consent-slot.svelte |
relogin-modal-relogin |
chrome, app-shell-modal |
whenVariant('relogin') |
pro-relogin-slot.svelte |
relogin-modal-connected |
chrome, app-shell-modal |
whenVariant('connected') |
pro-relogin-slot.svelte |
collaboration |
viewer tab, nodeType: 'collection', label: 'Collaboration' |
whenVariant('sign-in', 'consent', 'relogin', 'connected') |
collaboration/collaboration-tab.svelte |
- Why two relogin contributions: they keep today's remount of the relogin slot when the variant changes between relogin and connected.
- Why one Collaboration contribution: today, four variant contributions share the tab id
collaboration, so the selected tab survives a variant change (for example, "Turn on sync", then consent accepted, then connected). Under ADR-082 the host keys a tab by its contribution key. Four contributions would therefore drop the selection back to Contents. - Add
export default [proSyncExtension];so that a build can setNODESPACE_EXTENSIONSto this file. The interim Pro build does this after Stop importing the Pro extension in core; register it only through the build entry #3316. - Keep
uiExtensionRegistry.register(proSyncExtension);with a one-line transitional comment. Stop importing the Pro extension in core; register it only through the build entry #3316 deletes it. - Reword the doc table (L1-40) for the new shape.
5. src/lib/components/collaboration/collaboration-tab.svelte
This component becomes the variant switch that the four tab contributions used to express:
const variant = $derived(resolveProSyncVariant());
const live = $derived(variant === 'relogin' || variant === 'connected');
{#key variant}
{#if live}<CollaborationView collectionId={nodeId} />{:else}<CollaborationLocked {nodeId} />{/if}
{/key}{#key variant}keeps today's remount on every variant change.collaboration-locked.svelteitself is unchanged, so its design-token baseline entries stay valid.
6. Hosts
New src/lib/plugins/chrome-slot-outlet.svelte:
- Prop
name: ChromeSlot. It is not calledslot, because Svelte reserves that attribute. - Body:
{#each getActiveChromeContributions(name) as c (c.key)}<ExtensionOutlet load={c.load} />{/each}.
src/lib/plugins/extension-outlet.svelte:
- Load with
const loaded = $derived(load().catch((error) => { log.error(…); return null; })), and render nothing fornull. A rejectedload()is retried only on the next mount; nothing loops. - Wrap the render in
<svelte:boundary onerror={…}>with an emptyfailedsnippet. A component that throws while rendering, or in an effect, then removes only its own outlet, and the error is logged throughcreateLogger('ExtensionOutlet'). - Doc: the outlet is part of the extension API, and callers key it by contribution key (ADR-082 §2.4).
src/lib/components/layout/app-shell.svelte:
- The overlay slot (L692-702) becomes
<div class=extension-overlay-slot><ChromeSlotOutlet name=app-shell-overlay /></div>, with a neutral comment: a generic overlay slot, to which core contributes nothing. - The modal slot (L732-736) becomes
<ChromeSlotOutlet name=app-shell-modal />, with a neutral comment. - CSS: rename
.pro-sync-pill-slotto.extension-overlay-slot(L804, L807-815). - Imports (L37-38):
ChromeSlotOutletreplacesgetActiveChromeContributionsandExtensionOutlet.
src/lib/components/viewers/collection-node-viewer.svelte:
const tabs = $derived(getActiveViewerTabs('collection')).activeViewholds'contents'or a tab'skey, andactiveTab = tabs.find((t) => t.key === activeView).- The tab strip (L262-285) becomes
{#each tabs as t (t.key)}, showingt.label. - The outlet (L287-291) becomes
{#key activeTab.key}<ExtensionOutlet load={activeTab.load} props={{ nodeId }} />{/key}. - Make the comments at L29-37 and L263-265 neutral ("registry-contributed tabs"), with no Pro wording.
7. Test fixture: src/tests/fixtures/test-extension/
-
flags.svelte.ts:export const testExtensionFlags = $state({ overlay: false, modal: false, tab: false, throwingWhen: false, throwingComponent: false }). -
index.ts:createTestExtension(overrides?)returns aNodespaceExtensionwith idtest-extension, whose contributions are each gated by a flag:- an overlay;
- a modal;
- a
collectiontab; - a contribution whose
whenthrows whilethrowingWhenis set; - a contribution that loads a throwing component.
Later sub-issues extend this fixture.
-
Components, none with a
<style>block:test-chrome.svelte;test-viewer-tab.svelte, which renders itsnodeId;test-throwing.svelte, which throws while rendering.
8. Pro-boundary ratchet
- Paste the printed
BASELINES. - Markers that go down: the generic files lose the variant filter,
ProSyncVariantand the Pro wording in their docs. Lower those baselines. - Markers that go up:
pro-plugin.tsandcollaboration-tab.sveltegain a fewproSyncModulelines, because the variant comparison moves out of the generic filter and into the Pro extension. Declare them under Add the Pro-boundary ratchet check and the CLAUDE.md Pro/sync placement rule #3299's relocation rule. ThewhenVarianthelper limits them to the import and helper lines.
Out of scope
- Removing
import './pro-plugin'or the self-registration (Stop importing the Pro extension in core; register it only through the build entry #3316). - The build entry and the alias (Add the virtual:nodespace-extensions build entry and the extension-api import alias #3311).
- The settings, lifecycle and tree-root kinds (Add settings-section and database settings-slot extension points #3312, Add start, onDatabaseActivated and debugDump extension lifecycle hooks #3313, Add the collectionTreeRoots extension point to the sidebar collection tree #3314).
- The host API barrel (Add the virtual:nodespace-extensions build entry and the extension-api import alias #3311, Publish the extension host API: services, ui and testing entries, version policy #3315).
- Any change to the variant machine's logic, and deleting Pro files (Move the Pro sync and collaboration UI out of core #3333).
Steps
- Start up as core's
CLAUDE.mddescribes: a worktree namedissue-<N>-extension-contract,bun install, and self-assign at pickup. - The types and the registry, with the generic registry tests.
- The wrapper accessors.
ExtensionOutletandChromeSlotOutlet, with their tests.- Translate
pro-plugin.tsandcollaboration-tab.svelte, and updatepro-sync-variant.test.ts. - The app shell and the collection viewer, with the viewer test.
- The ratchet, the verification and
quality:fix, then the PR.
Acceptance criteria
Contract
-
ui-extensions.tsexports, as specified above:EXTENSION_API_VERSION,Contribution,ChromeSlot,ChromeContribution,ViewerTabContribution,NodespaceExtension,Keyed,registerExtensionsand the registry. Novariantfield remains. -
grep -rnE 'pro-sync-pill|lazyLoad|viewerExtensions|UiExtensionDefinition|getActiveViewerExtensions' packages/desktop-app/srcreturns nothing. - None of
proSync,labsFlags,ProSyncVariant,resolveProSyncVariantorDATABASE_SETTINGS_NODE_IDappears inui-extensions.ts,ui-extensions.svelte.ts,extension-outlet.svelteorchrome-slot-outlet.svelte. The one exception is the transitionalimport './pro-plugin'line and its comment. - Registration follows section 2 and never throws.
No behaviour change
- For each of teaser, sign-in, consent, relogin and connected, the same modal component and the same Collaboration content (locked or live) render as before (
pro-sync-variant.test.ts,collaboration-tab.test.ts). - The Collaboration tab stays selected across a change from consent to connected.
-
test:free-userspasses, and the manual smoke test of the free app shows no change.
Isolation
- A rejected
load()and a throwing component each remove only their own outlet, and each is logged. Sibling outlets still render.
Checks
-
bun run test:changedpasses, andquality:fixis clean with no change to the design-token baseline. -
bun run scripts/check-pro-boundary.tsexits 0 andBASELINESequal the printed counts. Reductions are lowered, and the PR description declares the relocation raise.
Tests and verification
Rewritten src/tests/plugins/pro-sync-variant.test.ts ('registry registration', 'active contribution filtering' and the Labs gate), with the same variant matrix as before:
- Registration:
uiExtensionRegistry.has('pro-sync')is true;chromeFor('app-shell-modal')has 3 entries, andviewerTabsFor('collection')has 1;- the overlay slot has none.
- What each variant shows:
- teaser: nothing;
- sign-in: no modal, and the tab
pro-sync/collaboration; - consent: the modal
pro-sync/consent-modal, and the tab; - relogin:
pro-sync/relogin-modal-relogin, and the tab; - connected:
pro-sync/relogin-modal-connected, and the tab.
- Build the keys with a helper from
proSyncExtension.id, so the assertions do not repeat marker strings. import proExtensions from '$lib/plugins/pro-plugin'returns[proSyncExtension]: the same object that is registered.
New src/tests/plugins/ui-extensions.test.ts. It is generic and imports nothing Pro. It registers the fixture, and unregisters it in afterEach.
- Registration:
register,unregister,hasandall;- re-registering the identical object is a silent no-op;
- a different object with the same id keeps the first and logs;
- an
apiVersionmismatch is not registered, and logs; - a duplicate contribution id is dropped, and logs;
registerExtensionswith a non-array argument logs.
- Lookups:
chromeForandviewerTabsForby slot and by node type, in descending priority with ties in registration order, with keys of the form<extension id>/<contribution id>. - Predicates:
whenabsent: active;whenfalse: filtered out;whenthrows: filtered out and warned once, and warned again only if it has returned normally in between.
New src/tests/plugins/chrome-slot-outlet.test.ts:
- It renders the fixture chrome only while its flag is on, in priority order.
- It renders nothing for an empty slot.
- Turning one contribution off unmounts only that outlet: a mount counter on the other one stays at 1.
New src/tests/plugins/extension-outlet.test.ts:
- Props reach the component.
- A rejecting loader renders nothing, and logs.
- A throwing component renders nothing, and logs, while a sibling outlet still renders.
New src/tests/components/collection-node-viewer-extensions.test.ts. Mock the collection reads: $lib/services/collection-service, and whatever else loadCollectionData calls. Then check:
- no tab strip while the fixture tab is hidden;
- Contents plus the fixture tab while it is shown;
- clicking the tab mounts the fixture component with
nodeId; - hiding the selected tab falls back to Contents.
New src/tests/components/collaboration-tab.test.ts. Stub collaboration-view.svelte with a fixture component, and drive the variant through the real stores, as pro-sync-variant.test.ts does.
- sign-in and consent render the locked placeholder.
- relogin and connected render the live view.
- A change from relogin to connected remounts it.
Updated: free-user-guardrail.test.ts uses getActiveViewerTabs.
bun run test:changed
bun run --cwd packages/desktop-app test src/tests/plugins src/tests/components/collection-node-viewer-extensions.test.ts src/tests/components/collaboration-tab.test.ts
bun run --cwd packages/desktop-app test:free-users
bun run --cwd packages/desktop-app quality:fix
bun run --cwd packages/desktop-app build
bun run scripts/check-pro-boundary.ts
Manual smoke test of the free app. Run bun run --cwd packages/desktop-app dev:tauri with an isolated NODESPACE_HOME, then check:
- a collection shows no tab strip;
- Settings is unchanged;
- switching databases works.
Dependencies
- Move the Pro variant machine and DATABASE_SETTINGS_NODE_ID out of the generic registry files #3309: the variant machine and the constant are already out of the generic files.
Risks and rollback
- The Collaboration tab translation. It uses one contribution plus a switch inside
collaboration-tab.svelte, instead of four contributions. The tests pin both the content shown for each variant and the kept selection. - The relogin slot's remount. Kept by the two per-variant contributions.
- Registration now keeps the first extension instead of replacing by id. Only tests re-register, and they unregister first.
- Rollback. Revert the PR. It changes no data, no schema and no Rust code.
Plan key: C3.1b (pro-boundary DAG).
🤖 Generated with Claude Code
Activity
mstomar125 commentedon Sep 30, 2026
Completed in #3374 (merged). Auto-close did not fire; closing manually.
mstomar125 commentedon Sep 30, 2026
Correction to the closing comment above: this issue was completed in #3384 (merged), not the PR named there.