Skip to content

Adopt the extension contribution contract: ids, when() predicates, keyed and isolated outlets - #3384

Merged
mstomar125 merged 7 commits into
mainfrom
issue-3310-extension-contract
Sep 30, 2026
Merged

mstomar125 merged 7 commits into
mainfrom
issue-3310-extension-contract

Conversation

@mstomar125

@mstomar125 mstomar125 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3310

Summary

Switches the UI-extension registry from Pro variants to the frontend extension contract (ADR-082, proposed): an extension is { id, apiVersion, chrome?, viewerTabs? }, each contribution is { id, when?, priority?, load }, and hosts key it by <extension id>/<contribution id>. Neither app changes visibly.

  • Registry (ui-extensions.ts): EXTENSION_API_VERSION, Contribution, ChromeContribution, ViewerTabContribution, NodespaceExtension, Keyed, registerExtensions(). chromeFor(slot) / viewerTabsFor(nodeType) return keyed contributions in descending priority, ties in registration order, and never evaluate when. register() never throws: a duplicate extension id keeps the first, an apiVersion mismatch is not registered, a repeated contribution id (across all of an extension's lists) is dropped, each logged. Registering the identical object twice is a silent no-op. No variant field remains.
  • Reactive wrapper (ui-extensions.svelte.ts): isContributionActive() (a throwing when() is false and warned once per key until it next returns normally); getActiveChromeContributions and getActiveViewerTabs (renamed from getActiveViewerExtensions).
  • Outlets: new ChromeSlotOutlet (prop name, each contribution in its own keyed ExtensionOutlet); ExtensionOutlet now logs and renders nothing for a rejected load() and isolates a throwing component in a boundary.
  • Hosts: the app shell uses ChromeSlotOutlet for both slots (.pro-sync-pill-slot becomes .extension-overlay-slot); the collection viewer keys its tabs by contribution key.
  • Built-in extension (pro-plugin.ts): proSyncExtension (renamed from proSyncUiExtension), translated one to one into when() predicates over the variant machine via a whenVariant helper, with export default [proSyncExtension] for a build entry. It still registers itself (transitional, per the issue).
  • Collaboration tab: the four per-variant tab contributions become one (collaboration), so the selected tab survives a variant change. collaboration-tab.svelte is now the locked/live switch ({#key variant} keeps the remount on every variant change). The relogin modal keeps two contributions so it still remounts between relogin and connected.
  • Fixture and tests: src/tests/fixtures/test-extension/ plus generic registry, outlet and viewer tests that import nothing Pro (see below).

Deviations from the issue text

  1. Boundary placement in ExtensionOutlet. The issue says to wrap the render in <svelte:boundary>. I put the boundary inside the {#await ... then} branch, around the component, not around the {#await}. Svelte builds the then-branch inside a promise callback, so a boundary further out never sees a component's throw: with Svelte 5.56.8 the first version surfaced as an unhandled rejection and the sibling test failed. The comment in the file says why.
  2. The lazyLoad acceptance grep. grep -rnE 'pro-sync-pill|lazyLoad|...' packages/desktop-app/src cannot return nothing: node-type plugins (plugin-registry.ts, the core plugins and their tests) legitimately use lazyLoad. Scoped to the extension files and terms it returns nothing. I also reworded the last two pro-sync-pill mentions in comments (account-settings.svelte, account-settings.test.ts) so the rest of that grep is clean.
  3. Contents tab highlight is !activeTab, not activeView === 'contents'. With per-contribution keys, a selected tab can disappear while other tabs remain; the strip then shows Contents content, so it must also show Contents as selected. activeView is left as-is, so the tab is re-selected if it comes back (same as before).
  4. Registration validates shape (non-empty string ids, load is a function, lists are arrays) on top of the issue's list, and wraps the whole thing in try/catch, to hold "never throws" and to stop a malformed contribution failing later inside an outlet. It also drops a contribution whose <extension id>/<contribution id> key another extension already holds: ids may contain /, and a repeated key throws in a keyed {#each}. register also stores keyed contributions, so all() still returns the original extension objects (the default-export test relies on that identity).
  5. Fixture additions. Besides the five flags in the issue: modalSecondary and tabSecondary (a second contribution per host), test-chrome-secondary.svelte, testExtensionMounts and resetTestExtension(). Priority order and "turning one off unmounts only that outlet" need two distinguishable siblings in one slot; the issue's fixture had none.
  6. pro-sync-variant.test.ts also asserts, per variant, that the active modal and tab load() resolve to the same components as before (first-pro-consent-slot, pro-relogin-slot, collaboration-tab). The issue's matrix implied this, but a key-only assertion would not pin it.
  7. ExtensionOutlet contains more than a rejected load(). A load() that throws synchronously, returns a non-promise, or resolves to a module with no default component is logged and renders nothing, like a rejected import. The issue specified load().catch(...), which lets those escape the outlet's own block; a review found it and a test reproduced it before the fix.

Pro-boundary ratchet

bun run scripts/check-pro-boundary.ts exits 0 on this branch rebased onto origin/main (with #3376). No count rises, so no raise class is claimed. I lowered the two baselines this change reduces and left the unrelated cloudSyncHooks headroom to its owner.

marker baseline before baseline now count now
proSyncModule 370 368 368
proWording 294 282 282
cloudBindState 203 203 203

Where it moves (added / removed marker lines):

  • Generic files lose them: ui-extensions.ts and ui-extensions.svelte.ts (the variant filter, ProSyncVariant, the Pro wording in their docs), app-shell.svelte, collection-node-viewer.svelte, and one stale comment in account-settings.svelte.
  • The relocation gains a few (the variant comparison moved out of the generic files into the Pro extension, as the issue anticipated): pro-plugin.ts +3 proSyncModule (the ./pro-sync-variant.svelte import, the ProSyncVariant parameter, the resolveProSyncVariant() call) and collaboration-tab.svelte +2 (the import and the call). They are offset by the generic-file reductions above, so the net is negative.
  • The new tests add almost none: one shared seeding helper (helpers/sync-variant-fixtures.ts, no pro in its name) that replaces per-file copies, with a local variant union and one compact settings builder to keep its marker lines down.

Tests

New: ui-extensions.test.ts (29), chrome-slot-outlet.test.ts (7), extension-outlet.test.ts (8), collection-node-viewer-extensions.test.ts (6), collaboration-tab.test.ts (7), collection-node-viewer-collaboration.test.ts (3). Rewritten: pro-sync-variant.test.ts (same variant matrix). Updated: free-user-guardrail.test.ts.

Mutation check. I scripted 43 mutations of the source (break each behaviour, run the relevant suites, restore the file). All 43 are caught on the final tree. Two first survived, both because the test was weak, and I fixed the tests and re-ran every mutation:

  • A malformed contribution without a load was only asserted through a lookup by slot, but the malformed entry had no slot, so it could never appear. Fixed by giving it a slot.
  • "Tabs never share a selection" used two tabs with different contribution ids, so keying by contribution id instead of key survived. Fixed with the same contribution id in two extensions.

The mutations cover: identical-object no-op, first registration kept, apiVersion check, duplicate contribution id (within a list and across lists), sort by priority, tie order, try/catch in register, non-finite priority, key format, non-array guard, lookups evaluating when, when try/catch, warn-once, warn re-arming, when ignored, unkeyed {#each}, slot name ignored, rejected load not caught, no boundary, boundary that never logs, props not forwarded, Contents highlight, tab selected/clicked by id instead of key, wrong node type, missing nodeId, collab tab always live / always locked / relogin treated as locked / no remount, and each when list, key and default export in the built-in extension.

Verification

  • bun run test:changed: passed (frontend Happy-DOM, scripts tier, browser tier). The scripts tier includes the ratchet's own tests.
  • test:free-users: 9 passed. quality:fix: clean, design-token baseline unchanged (50). bun run --cwd packages/desktop-app build: passes; the Pro components are still separate lazy chunks.
  • Real app, isolated daemon (NODESPACE_HOME in scratch, private socket), driven with Playwright against dev:browser:
    • Free app: a collection page has no tab strip; the overlay slot keeps its anchor styles (position: absolute; top: 8px; right: 12px; z-index: 10) and is empty; Settings opens with its usual sections (Database, Display, Import Sources, Integrations, Labs, About); no extension-logger messages and no page errors.
    • Same bundle with the real Pro stores flipped from the page: sign-in shows Contents + Collaboration, the locked placeholder shows in the selected tab; the tab stays selected from consent through to connected while the content swaps locked to live; turning the Labs toggle off removes the strip and returns Contents.
    • Not exercised: switching databases. Browser mode has no Tauri IPC (the Databases list only shows "Default" and creating/opening a database is a Tauri command), and a full dev:tauri build was out of scope on the shared machine. By construction the free path never reads the settings node (the Labs gate returns teaser first), so it is unaffected; a desktop pass would confirm it.

Risks and rollback

Registration now keeps the first extension instead of replacing by id; only tests re-register, and they unregister first. Revert the PR to roll back: no data, schema or Rust changes.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review Type: Initial Review

Requirements Check (issue #3310)

Contract

  • Met. ui-extensions.ts exports EXTENSION_API_VERSION, Contribution, ChromeSlot, ChromeContribution, ViewerTabContribution, NodespaceExtension, Keyed, registerExtensions and the registry, with the shapes the issue specifies. No variant field remains.
  • Met with deviation (justified). The literal lazyLoad grep cannot return nothing. I checked the remaining hits and they are only the node-type plugin system (plugin-registry.ts, core-plugins.ts, types.ts, node-viewers.ts and their tests). pro-sync-pill|viewerExtensions|UiExtensionDefinition|getActiveViewerExtensions|viewersFor|proSyncUiExtension return nothing anywhere in the repo.
  • Met. proSync, labsFlags, ProSyncVariant, resolveProSyncVariant, DATABASE_SETTINGS_NODE_ID and "pro" wording do not appear in ui-extensions.ts, ui-extensions.svelte.ts, extension-outlet.svelte or chrome-slot-outlet.svelte. The only hit is the transitional import './pro-plugin' (its comment is neutral).
  • Met. Registration follows section 2: identical object is a debug no-op, a different object with the same id keeps the first and logs, an apiVersion mismatch is logged and not registered, a repeated contribution id is dropped across both lists, and register() is wrapped in try/catch and stores nothing until both lists are keyed (no partial state).

No behaviour change

  • Met. I compared the old pro-plugin.ts with the new one. The three modals load the same components (first-pro-consent-slot, pro-relogin-slot x2), the when() sets equal the old per-variant matrix, and the single collaboration tab plus {#key variant} reproduces the old locked/live split (locked for sign-in/consent, live for relogin/connected, remount on every variant change). pro-sync-variant.test.ts asserts the resolved component identity per variant, not just keys.
  • Met. The tab stays selected from consent to connected. The key is constant, and collection-node-viewer-collaboration.test.ts pins it against the real registry.
  • [~] Partly verified. test:free-users passes (9/9, I ran it). The author's manual free-app smoke test is reported but not re-run here. Switching databases is not exercised (acknowledged in the PR; the free path never reads the settings node).

Isolation

  • Met for load() rejections and render throws (see Improvement 1 for one uncovered path: a load() that throws synchronously).

Checks

  • Tests: I ran ui-extensions, extension-outlet, chrome-slot-outlet, pro-sync-variant (60 tests) and free-user-guardrail, collection-node-viewer-extensions, collaboration-tab, collection-node-viewer-collaboration, account-settings (40 tests). All pass. test:changed, quality:fix and the build are author-reported, not re-run (shared machine). The diff has no lint suppressions, any, console.*, {@html} or #NNNN comment references.
  • [~] Deviation (justified, blocked upstream). scripts/check-pro-boundary.ts is not on origin/main (Add the Pro-boundary ratchet check and the Pro/sync placement rule #3376 is open), so there are no BASELINES to paste or lower. The PR declares the deltas.

Code Review Summary

This is a clean, well-scoped translation. The registry is small, plain data, and hard to misuse. register() cannot leave partial state, keyed contributions are stored once, so identities are stable across lookups and the outlets are never spuriously remounted. all() returns the original objects. The reactive layer is thin and correct: isContributionActive mutates only a non-reactive Set and calls the logger (which touches no $state), so it is safe inside a $derived/each expression. A throwing when() cannot re-log or loop, because the throw is caught, warned once per key, and the dependencies read before the throw stay tracked.

Svelte 5 points I checked and found correct:

  • ExtensionOutlet. $derived(load().catch(...)) re-runs only when the load prop identity changes. Callers pass stable Keyed objects, so it runs once per mount (the "one attempt" assertion pins this). The boundary belongs inside the then branch, as the PR explains, and the empty failed snippet plus onerror gives the ADR §2.4 behaviour.
  • ChromeSlotOutlet. The keyed {#each} over the accessor call re-evaluates when predicate state changes.
  • Collection viewer.
    • A stale activeView never matches a remaining tab, because keys are unique.
    • The !activeTab highlight is correct.
    • The tab returns to selected if it comes back, which matches the old behaviour.
    • {#key activeTab.key} inside {#if activeTab} tears down safely (same shape as before, and covered by the fallback tests).
  • collaboration-tab.svelte. variant and live derive from the same store, and {#key variant} destroys the inner {#if} before it re-evaluates, so there is no locked/live flash.
  • Relogin remount. Two per-variant modal contributions still remount pro-relogin-slot between relogin and connected.
  • Free app. No new eager Pro import: ui-extensions.svelte -> pro-plugin -> pro-sync-variant.svelte reaches the same modules as the old wrapper did. The overlay <div> is still emitted with the same styles, and the modal slot adds no wrapper element, so nothing changes in the DOM when nothing contributes.

Test spot-checks (reading tests against source, the three riskiest mutations):

  • Unkeyed {#each} would be caught by chrome-slot-outlet.test.ts:87-105. The removed contribution (modal-secondary, priority 10) is first in the list, so index-based reconciliation would hand the survivor a new load and remount it. The element-identity and mount-counter assertions would fail. The priority choice is what makes this test bite.
  • Tab selection by contribution id instead of key would be caught by collection-node-viewer-extensions.test.ts:113-148 (same contribution id in two extensions).
  • Removing {#key variant} would be caught by collaboration-tab.test.ts:69-80 (a relogin to connected change must replace the DOM node).

I found no tautological test. Isolation is good: the fixture is unregistered and the flags and mount counters are reset in afterEach, and warnedKeys (module-global) is exercised with distinct keys.

Findings

Critical Issues

None.

Suggested Improvements

  1. [Improvement] A load() that throws synchronously, or returns a non-promise, escapes the outlet's isolation.
    packages/desktop-app/src/lib/plugins/extension-outlet.svelte:30-35 (the boundary is at :43).
    load().catch(...) calls load() synchronously inside the $derived, which is read by the {#await} expression. The <svelte:boundary> only wraps the component inside the then branch (deliberately, per deviation 1), so an exception thrown by load() itself, or undefined.catch when a contribution's load returns a non-thenable, is thrown from the outlet's own block effect, outside the boundary. That is the failure class ADR §2.4 says core must contain. Registration validates only typeof load === 'function' (ui-extensions.ts:122), so this contribution is accepted. The path is not covered by the tests (all three "failure" tests use a rejected promise or a throwing component). I reasoned this from the Svelte block/derived semantics and could not run a probe (vite will not load a scratch test outside the package root), so treat the exact consequence as likely rather than confirmed. A one-line hardening would close it, and would need one test (load: () => { throw ... } renders nothing and logs):
    const loaded = $derived(
      new Promise<{ default: Component<Props> }>((resolve) => resolve(load())).catch(...)
    );
    The Promise constructor turns a synchronous throw into a rejection and wraps a plain value.

Nitpicks

  1. Nit: ids containing / can produce a duplicate host key. ui-extensions.ts:101-141 (key built at :138).
    Extension a/b with contribution c and extension a with contribution b/c both key to a/b/c. A duplicate key in a keyed {#each} throws in dev and misrenders in production, which is the "never blank the app" hazard register() otherwise closes. Rejecting / in extension and contribution ids at registration (log and skip) costs three lines.

  2. Nit: the "nothing happens" waits.
    chrome-slot-outlet.test.ts:77-85 (20 ms) and collaboration-tab.test.ts:82-92 (20 ms). Acceptable, since the failure mode is a false pass and never a flaky fail.

    • The first can false-pass when run in isolation (-t): the fixture chunk is then a cold dynamic import, and a wrongly started load might not land within 20 ms. In the full file, earlier tests have already warmed it. Pre-warming with await import('../fixtures/test-extension/test-chrome.svelte') first would make it deterministic.
    • The second can simply use await tick(), because Svelte flushes on a microtask.
  3. Nit: no rendered test for a throwing when(). The registry-level tests cover it (ui-extensions.test.ts:446-466), but the fixture's throwingWhen flag is never used through ChromeSlotOutlet, so "siblings keep rendering and nothing loops" is asserted only at the accessor. One short test alongside the throwing-component test would pin ADR §2.4 row 2 at the host.

  4. Nit: collaboration-tab.svelte:14-15 statically imports both views. Sign-in and consent (locked) now also fetch the live CollaborationView chunk, where before only collaboration-locked loaded. Pro-only and small, so acceptable for a transitional file, but it is a small regression in lazy loading for those two variants. Ignore if the file is going away with Move the Pro sync and collaboration UI out of core #3333.

  5. Nit: isContributionActive's parameter type (ui-extensions.svelte.ts:37) is Pick<Keyed<ChromeContribution>, 'key' | 'when'> but is also used for viewer tabs. Pick<Keyed<Contribution>, 'key' | 'when'> reads more honestly.

Follow-up for whoever merges second (#3376 vs this PR): rebase and paste the printed BASELINES. The cloudBindState +8 raise comes from the shared test helper, not from the relogin/variant relocation the issue anticipated, so confirm #3376's rule accepts it (the PR declares it).

Recommendation: APPROVE (no blockers; Improvement 1 is worth taking before merge, but it is low-likelihood hardening rather than a defect in the shipped Pro/free paths).

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125
mstomar125 force-pushed the issue-3310-extension-contract branch from f0b7bae to 501f867 Compare September 30, 2026 11:03
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review summary (round 1)

Review: APPROVE, no blockers, one improvement and five nits. Pushed as 501f867a (rebased onto origin/main with #3376).

Addressed (5 of 6)

  • Improvement 1: a load() that throws synchronously or returns a non-promise escaped the outlet. Reproduced first: two new tests failed on the old code (the throw surfaced out of the render, and undefined.catch on a non-promise). ExtensionOutlet now builds the promise with new Promise((resolve) => resolve(load())), so both take the same log-and-render-nothing path as a rejected import. While there I found the non-promise case then resolved to undefined and rendered nothing silently, so a resolved module without a default component is now rejected and logged too (a third test).
  • Nit 2: ids containing / can produce a duplicate host key. The registry now also drops a contribution whose <extension id>/<contribution id> key an earlier extension holds, and logs it. The check runs across extensions, so it also catches the same-extension case; the cross-list test now asserts the more precise "Duplicate contribution id" message so the per-extension guard stays pinned.
  • Nit 3: the wall-clock waits. The empty-slot test warms the fixture chunk before its wait; the "stays mounted" test uses tick().
  • Nit 4: no rendered test for a throwing when(). Added through ChromeSlotOutlet: the sibling renders, and a later contribution still appears after the predicate recovers.
  • Nit 6: isContributionActive parameter type is now Pick<Keyed<Contribution>, 'key' | 'when'>.

Skipped (1)

Ratchet (the follow-up the review flagged). #3376 landed while this was in review. On the rebased branch bun run scripts/check-pro-boundary.ts first failed (proSyncModule 375 vs 370, cloudBindState 211 vs 203), all from test scaffolding. Rather than claim a raise, I cut the scaffolding (a local variant union instead of the source type, one compact settings builder, seedVariant in the variant test, one default-export assertion). It now exits 0: proSyncModule 368, cloudBindState 203 (unchanged), proWording 282. I lowered the two baselines this change reduces (proSyncModule 370 to 368, proWording 294 to 282). The PR body is updated; no raise class is claimed.

Verification. quality:fix clean; test:changed passed (frontend, scripts, browser); 43 of 43 mutations caught (four new ones for the changes above; two first survived and I fixed the test and a flawed mutation).

Re-Review Decision

Decision: RE-REVIEW NEEDED

Rationale: the outlet's promise chain and the registry's registration path both changed, and BASELINES was edited. The re-review should cover only the new commits since the last review.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review Type: Re-Review (commits 53f736ca and 501f867a only)

Previous Review Summary: 6 recommendations (1 improvement, 5 nits). Addressed: 5, all correctly (Improvement 1, Nits 2, 3, 4, 6). Not addressed: 1 (Nit 5, collaboration-tab.svelte static imports), skipped with a reason I accept (transitional Pro-only wrapper that #3333 deletes). New issues found: 0 blocking, 1 trivial nit.

What I verified

Improvement 1 (extension-outlet.svelte): correct.

  • new Promise((resolve) => resolve(load())) runs load() synchronously in the executor, so a synchronous throw becomes a rejection and a plain value or undefined is wrapped. load is still the only reactive dependency read inside the $derived (log is a constant, and props is read only in the template). The chain therefore re-runs only when the load prop identity changes, exactly as before, and callers pass stable Keyed objects. Nothing loops or re-logs.
  • The chain ends in .catch(... return null), so there is no unhandled rejection. log.error runs in a promise callback, outside the reactive context.
  • Rejecting a module with no default function is right for Svelte 5, where compiled components (and legacy class wrappers) are typeof 'function'. mod?.default also covers a resolved undefined. Previously that case rendered nothing silently.
  • Tests read against the code:
    • The sync-throw test fails on the old load().catch (the throw surfaces from the render).
    • The non-promise and no-default tests both need the new typeof mod?.default check, because otherwise {#if mod} is false or {@const Loaded} is undefined and failed to load is never logged. I confirmed the no-default test cannot pass without the check: if the component instead threw during render, the boundary would log Extension component threw, which does not match the test's stringContaining('failed to load') plus TypeError assertion. log.error is mockCleared in beforeEach, so no stale calls make the assertions pass.

Nit 2 (key collision): correct, no partial state.

  • takenKeys is a local Set built from the live map by registeredKeys() at each registration. Both keyContributions calls run before this.extensions.set(...) is evaluated, so a throw stores nothing, and the outer try/catch is unchanged.
  • unregister frees keys, because they are recomputed each time. The seenIds per-extension check still runs first, so the same-extension duplicate keeps its own message (now pinned by the cross-list test).
  • The order is first-registered wins, and the extension itself stays registered (has('a') is asserted). No legitimate registration changes: without a / in ids, <ext>/<id> collisions were already impossible across extensions.

Nits 3, 4, 6: fine.

  • The empty-slot test now warms the same fixture module the contribution's load imports.
  • tick() is enough in the "stays mounted" test, because the collaboration tab imports both views statically, so any wrongly caused remount is synchronous within the flush.
  • The new throwing-when() test would fail if a throw were treated as true (the fixture's throwing-when loads test-chrome, so the marker list would be ['test-chrome', 'test-chrome']) or if it escaped the {#each}. The recovery half works because when reads the flag before it throws, so the dependency stays tracked.
  • Pick<Keyed<Contribution>, ...> is correct for both callers.

Ratchet commit: correct.

  • bun run scripts/check-pro-boundary.ts exits 0, "No count is above its baseline". Printed counts: proSyncModule 368 (baseline 368), proWording 282 (282), cloudBindState 203 (203), every other marker equal to its baseline.
  • The BASELINES diff touches exactly two lines, proSyncModule 370 to 368 and proWording 294 to 282, matching the printed counts.
  • The script also prints an optional notice that cloudSyncHooks is now 0 against a baseline of 4. That is not from this PR (it only matches get_multi_membership_edges, which Generalize get_multi_membership_edges into member_of_edges with caller-supplied filters #3383 already renamed on main, and this diff touches no Rust). It can be lowered in a separate change.
  • The branch is based on the latest origin/main (d4a4ab26).
  • I ran the six affected test files (extension-outlet, chrome-slot-outlet, ui-extensions, pro-sync-variant, collaboration-tab, collection-node-viewer-collaboration): 75/75 pass.

Helper sync-variant-fixtures.ts after trimming: still sound.

  • The local Variant union is a subset of ProSyncVariant by design. If the source union is renamed, the helper still produces the same settings state, and the tests that consume it assert resolved behaviour: the variant matrix in pro-sync-variant.test.ts pins the real resolveProSyncVariant() outputs, and collaboration-tab.test.ts pins the locked/live split. That drift risk is acceptable.
  • seedSettings now takes Record<string, unknown>, so a key typo would typecheck, but every caller asserts the resolved variant, so a typo fails loudly.
  • Object.assign(proSync, { tier: 'unknown', userEmail: '' }) is equivalent to the two assignments it replaces.

Mutation spot-check (by reading, not applied): removing the typeof mod?.default !== 'function' check is caught by two tests (no-default: toHaveBeenCalledWith('failed to load', TypeError); non-promise: toHaveBeenCalled(), since {#if mod} would swallow undefined silently). Reverting to load().catch(...) is caught by the sync-throw test.

Findings

Critical Issues

None.

Suggested Improvements

None.

Nitpicks

  1. Nit: stale doc comment. packages/desktop-app/src/lib/plugins/extension-outlet.svelte:12 says "a rejected load() renders nothing and is logged". It now also covers a load() that throws synchronously, returns a non-promise, or resolves to a module without a default component (the inline comment at :30-34 says so). Widening the header sentence keeps the two consistent. Optionally, the non-promise test at extension-outlet.test.ts could assert the failed to load message like its siblings instead of a bare toHaveBeenCalled(), so it cannot pass on an unrelated log.

Recommendation: APPROVE. Both new commits are correct, the earlier findings are closed, and the ratchet passes at exactly the printed counts.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review (re-review): APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125
mstomar125 force-pushed the issue-3310-extension-contract branch from 501f867 to 758d90b Compare September 30, 2026 11:10
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review summary (round 2)

Re-review: APPROVE, no blockers, no improvements, one trivial nit. Pushed as 758d90b4 (rebased over #3385, which is Rust-only; the ratchet still exits 0).

Addressed (1 of 1)

  • Nit: stale header comment in extension-outlet.svelte. It now lists every case the outlet contains (rejects, throws synchronously, returns a non-promise, resolves to a module with no default component). I also tightened the non-promise test to assert the failed to load message and a TypeError, like its siblings, so it cannot pass on an unrelated log. Mutation check: removing the typeof mod?.default !== 'function' check, or reverting to load().catch(...), fails the tests.

Verification. quality:fix clean; test:changed passed (frontend, scripts, browser); scripts/check-pro-boundary.ts exits 0 (proSyncModule 368, proWording 282, cloudBindState 203, none above baseline).

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the only change since the approving re-review is a comment and one test assertion; no source logic changed.

mstomar125 and others added 7 commits September 30, 2026 13:16
…yed and isolated outlets

The UI-extension registry now follows the frontend extension API: an extension
is { id, apiVersion, chrome?, viewerTabs? } and each contribution is
{ id, when?, priority?, load }. Hosts key contributions by
<extension id>/<contribution id>, order them by descending priority then
registration order, and never evaluate when() in a lookup.

Registration never throws: a duplicate extension id keeps the first, an
apiVersion mismatch is not registered, and a repeated or malformed
contribution is dropped, each logged. registerExtensions() registers a build's
list. The reactive wrapper filters through isContributionActive(); a throwing
when() counts as false and is warned once per key.

ExtensionOutlet logs and renders nothing for a rejected load() and isolates a
throwing component in a boundary inside the await branch. ChromeSlotOutlet
replaces the app shell's inline slot loops, and the collection viewer keys its
tabs by contribution key and falls back to Contents when the selected tab goes
away.

The built-in extension is translated one to one into when() predicates over the
variant machine, with a default export for the build entry. The four
Collaboration tab variants become one contribution so the selected tab survives
a variant change; collaboration-tab.svelte switches locked/live inside.

Adds a test-extension fixture plus generic registry, outlet and viewer tests.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…est waits

- ExtensionOutlet: a load() that throws synchronously, returns a non-promise, or
  resolves to a module with no default component is logged and renders nothing,
  like a rejected import. It previously escaped the outlet's own block.
- Registry: a contribution whose <extension id>/<contribution id> key is already
  held by another extension is dropped and logged. Ids may contain '/', and a
  repeated key throws in a keyed each block.
- Tests: a throwing when() through ChromeSlotOutlet; a warmed chunk before the
  empty-slot wait; tick() instead of a wall-clock wait; the cross-list duplicate
  message is pinned.
- isContributionActive takes Pick<Keyed<Contribution>, 'key' | 'when'>.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…his change reduces

The new sync test helper and the variant test no longer add marker lines: a
local variant union instead of the source type, one compact settings builder,
seedVariant in the variant test, and one default-export assertion. proSyncModule
goes 370 -> 368 and proWording 294 -> 282; cloudBindState stays at 203.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3310-extension-contract branch from 758d90b to 6290935 Compare September 30, 2026 11:16
@mstomar125
mstomar125 merged commit a7a1906 into main Sep 30, 2026
@mstomar125
mstomar125 deleted the issue-3310-extension-contract branch September 30, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt ADR-082's contribution contract: ids, when() predicates, keyed and isolated outlets

1 participant