Skip to content

Add UI-extension registry for two-axis Pro-sync surfaces (ADR-053) - #1607

Merged
mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:ns/issue-1537-registry-pro-ui
Jul 10, 2026
Merged

mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:ns/issue-1537-registry-pro-ui

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Adds a declarative UI-extension registry that resolves the active Pro-sync surface from two independent signals and renders it through generic extension slots, replacing the hard-coded pill/modal wiring in the app shell.

Part of the ADR-053 multi-database epic (#1537): the Pro-sync surface must react per active database, not just per daemon build.

Two-axis variant resolution

  • Axis 1 — build tier (proSync.tier, app-global): a non-Pro daemon resolves to the static upgrade teaser.
  • Axis 2 — active database (DatabaseSettingsNode.sync_enabled / auth_status, per-database): a Pro daemon resolves to enable-prompt → sign-in → connected.

The resolver (lib/plugins/ui-extensions.svelte.ts) maps the two signals to one variant and returns only the chrome contributions / viewer extensions matching it. Both reads are reactive, so a tier change or a DatabaseSettingsNode update (including a database switch) re-resolves the surface.

What changed

  • New UiExtensionRegistry (lib/plugins/ui-extensions.ts) + reactive resolver + built-in Pro extension definition (pro-plugin.ts) + ExtensionOutlet.
  • App-shell overlay/modal slots and the collection-node viewer render registry contributions via ExtensionOutlet instead of importing pill/modal components directly.
  • Re-login orchestration moves out of the app shell into a registry slot component (pro-relogin-slot.svelte); the presentational ProReloginModal is unchanged.
  • Dependent stores (membership, recovered-items) gate on the two-axis isProSyncActive() instead of the tier-only proSync.isPro.
  • database.svelte.ts hydrates the DatabaseSettingsNode on load and after a database switch so the variant re-resolves for the active database.

Community build unchanged

Non-Pro builds resolve to the static teaser only; every daemon-backed Pro surface stays gated. The test:free-users guardrail covers this.

Testing

  • bun run test — 3989 passed
  • bun run test:free-users — 11 passed
  • bun run quality:check (eslint + svelte-check) — 0 errors, 0 warnings
  • Full pre-push pyramid (frontend + core-lib + headless e2e + Tauri-seam) green

Follow-up

  • Backend gap: there is no per-database "enable sync" intent command yet, so enable-sync-pill opts a database into sync via the existing interactive sign-in (pro_initiate_oauth), which flips sync_enabled / auth_status on bind. A dedicated set-sync_enabled command is a backend follow-up.
  • Live desktop UI validation of the variant transitions is pending.

Co-Authored-By: Claude Opus 4.8 [email protected]

@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE — well-structured, community-safe two-axis Pro-UI registry. The failing test:e2e is an infra flake unrelated to this PR (analysis below); re-run to green the gate.

Community-safety verified at the source, not just the test

The one invariant that matters for a Pro-UI PR — a community build must never render a daemon-backed Pro surface — holds by construction. resolveProSyncVariant() gates on the tier first and short-circuits:

if (proSync.tier !== 'pro') return 'teaser';   // non-Pro (and pre-probe 'unknown') → teaser, unconditionally
const settings = activeDatabaseSettings();
if (settings?.sync_enabled !== true) return 'enable-prompt';
if (settings.auth_status === 'connected') return 'connected';
return 'sign-in';

So the per-database axis-2 (sync_enabled/auth_status) is never even read for a non-Pro build — no DatabaseSettingsNode value can flip a community install into a Pro surface. Backed by: every contribution is lazy () => import(...) (Pro components aren't pulled unless their variant is active), and the free-user-guardrail test asserts community resolves to teaser only, modal + collaboration slots contribute [], and the pre-probe unknown tier is teaser-only too (no Pro flash). test:free-users 11/11, test:all (frontend 3989 + skill + Rust) green.

The state machine + gating change are correct

  • teaser (non-Pro) → enable-prompt (Pro, sync off) → sign-in (Pro, sync on, not connected) → connected — coherent, and the slot table (overlay/modal/collab-tab per variant) maps cleanly.
  • isProSyncActive() = sign-in || connected (Pro and sync_enabled) now gates membership/recovered-items, replacing the tier-only proSync.isPro. That's a deliberate tightening — those features no longer light up on a Pro daemon whose active database hasn't enabled sync. Correct per the epic's per-database intent; just flagging it's a real behavior change (a Pro-but-sync-disabled DB now hides membership/recovered-items until enabled).
  • database.svelte.ts re-hydrates the DatabaseSettingsNode on load + after a switch, so the surface re-resolves per active database. Consistent with Desktop: live database switcher + client-side routing (ADR-053) #1598's switch flow.

⚠️ CI: test:e2e FAILURE is an infra flake, not this PR

All 3 failures are in adapter-contract.e2e.ts (HttpAdapter → dev-proxy → daemon round-trips), each with the identical root error: connect ENOENT …/daemon.sock — the headless daemon never bound its socket in the runner, so 3 daemon-dependent tests couldn't connect (21/24 passed). This PR is frontend-only (Svelte/TS UI-extension registry, stores, components) and touches no daemon/adapter/socket/Rust code, so it cannot have caused a daemon-startup failure. Consistent with the impl's "pre-push e2e green locally." Re-run test:e2e to clear the merge gate — no code change needed. (If the daemon-socket-ENOENT e2e flake recurs across PRs, it's a candidate for the same infra hardening the OpenSSL flake got in #1602.)

Follow-up (documented, fine)

No per-database "enable sync" intent command yet, so enable-sync-pill opts in via the existing interactive sign-in (pro_initiate_oauth), which flips sync_enabled/auth_status on bind — a dedicated setter is a backend follow-up. Reasonable to defer.

Net: approve the code; the only thing between it and merge is a test:e2e re-run for the daemon-socket flake. (Core = I re-review on any new head SHA.)

Introduce a declarative UI-extension registry that resolves the active
Pro-sync surface from two independent signals: the daemon build tier
(app-global) and the active database's DatabaseSettingsNode
(sync_enabled / auth_status, per-database). A reactive resolver maps the
signals to one of four variants — teaser, enable-prompt, sign-in,
connected — and returns only the chrome contributions and viewer
extensions matching it.

App-shell overlay/modal slots and the collection-node viewer now render
registry contributions through an ExtensionOutlet instead of hard-coded
pill/modal wiring; the re-login orchestration moves into a registry slot
component, and its dismissal state is held on the sync store so it
survives the slot remounting on a variant flip. The membership store
gates on the two-axis isProSyncActive() rather than the tier-only
proSync.isPro; the recovered-items log stays tier-gated (its trigger is
the one-shot tier confirmation and the log is per-user, not
per-database). database.svelte.ts hydrates the DatabaseSettingsNode on
load and after a database switch so the variant re-resolves for the
active database.

The community build resolves to the static upgrade teaser only; every
daemon-backed Pro surface stays gated, leaving the free experience
unchanged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE

Reviewed as an independent correctness pass over the full diff (registry data class, reactive resolver, variant↔component↔slot mapping, app-shell rewire, per-database settings hydration, and the two-axis store gates).

Two issues surfaced and were fixed before this approval:

  1. (High) Recovered-items regression — gate/trigger signal mismatch. The store's load() gate had been widened to the two-axis isProSyncActive(), but its only runtime trigger is the tier-only one-shot proSync.onProConfirmed. At boot, tier resolves (often synchronously) before the active database's DatabaseSettingsNode hydrates on its separate, strictly-longer chain — so the one-shot fired while the gate was still unsatisfied, load() returned empty, and the recovery log never loaded for the whole session. Fixed by reverting the gate to the tier-only proSync.isPro (the recovery log is per-user, not per-database, so the two-axis narrowing bought nothing but the race) and adding a pro-path regression test (tests/stores/recovered-items.test.ts).

  2. (Latent) Re-login dismissal lost on variant remount. Dismissal state lived inside pro-relogin-slot, which the modal slot mounts via {#each … (c.variant)}; a sign-in↔connected flip (both map to the same slot) remounts it and reset the dismissed-episode to -1, re-arming an already-dismissed modal. This is state the shell used to hold outside the remounting subtree. Fixed by hoisting it to proSync.dismissedReloginEpisode so dismissal survives the remount.

What checked out: complete/correct variant→component→slot mapping (all four variants; app-shell requests exactly the two slots pro-plugin registers); reactive SharedNodeStore reads (not cached snapshots); correct re-hydration after clearAll() on switch (epoch guard captured post-bump); no $derived/$effect loops; membership gate sense preserved.

Verification after fixes: bun run test 3991 passed (156 files) · test:free-users 11 passed · quality:check 0 errors / 0 warnings · full pre-push pyramid (frontend + core-lib + e2e + Tauri-seam) green.

@mstomar125
mstomar125 merged commit 9821b79 into NodeSpaceAI:main Jul 10, 2026
2 checks passed
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.

1 participant