Skip to content

Registry-driven Pro UI surfaces resolved from daemon capability and DatabaseSettingsNode state #1537

Closed

Description

@malibio

Overview

Pro-edition GUI surfaces (sync pill, re-login modal, collaboration tab) are hardcoded into shared components behind scattered {#if proSync.isPro} guards. Replace this with a small UI-extension registry whose contributions resolve their rendered variant from two signals: the daemon build-variant capability (app-global) and the active database's DatabaseSettingsNode (node-held, per ADR-053). Shared components import nothing Pro; community builds render upsell teasers in the same slots.

Problem Statement

  • app-shell.svelte imports ProSyncPill/ProReloginModal directly and owns Pro-specific $effect orchestration (relogin state, recovered-items load-once).
  • collection-node-viewer.svelte hardcodes the collaboration tab behind proSync.isPro (lines ~185, ~206).
  • The single boolean proSync.isPro conflates two independent questions that ADR-053 separates: "can this daemon sync?" (build variant, app-global, static per session) and "is sync enabled/authenticated for the active database?" (held on that database's DatabaseSettingsNode, changes on database switch or settings edit). A Pro daemon with a non-synced active database currently cannot be represented.
  • Community edition hides Pro surfaces entirely instead of showcasing upgrade paths (ADR-039 calls for upgrade CTAs in place of sync controls but provides no mechanism).

Proposed Solution

A sibling registry to the existing node-type PluginRegistry — do NOT extend PluginDefinition (different keys, lifecycles, and consumers). One UiExtensionDefinition for Pro sync with a resolveVariant() state machine over the two signals; the registry exposes contributions through a $derived-friendly reactive wrapper.

Variant state machine

Condition Variant Component
proSync.tier !== 'pro' teaser pro-teaser-pill.svelte (new) — upgrade CTA
Pro + sync_enabled: false enable-prompt enable-sync-pill.svelte (new) — enable sync for this database
Pro + enabled + auth_status: 'local' sign-in sign-in pill state
Pro + enabled + auth_status: 'connected' connected existing pro-sync-pill.svelte, unchanged internally

sync_enabled/auth_status are read reactively from sharedNodeStore.getNode('database-settings') (fixed symbolic ID) — no bespoke database-settings.svelte.ts store; DatabaseSettingsNode flows through SharedNodeStore like any other node.

Core types

export type ChromeSlot = 'app-shell-overlay' | 'app-shell-modal';

export interface ChromeContribution {
  slot: ChromeSlot;
  variant: string; // which resolveVariant() output this renders for
  lazyLoad: () => Promise<{ default: Component }>;
  priority?: number;
}

export interface ViewerExtension {
  tab: { appliesTo: string; id: string; label: string };
  variant: string;
  lazyLoad: () => Promise<{ default: Component<{ nodeId: string }> }>;
  priority?: number;
}

export interface UiExtensionDefinition {
  id: string;
  name: string;
  version: string;
  chrome?: ChromeContribution[];
  viewerExtensions?: ViewerExtension[];
  resolveVariant?: () => string | null; // null = contribute nothing
}

Registry stays a plain class holding declarative data (mirrors PluginRegistry); reactivity is layered on top in a thin .svelte.ts wrapper exposing getActiveChromeContributions(slot) / getActiveViewerExtensions(nodeType) that read proSync.tier + the database-settings node and filter by the freshly resolved variant. Do not bake $state into the class methods.

Implementation Approach

Phase 1: Registry + reactive wrapper

  • Add lib/plugins/ui-extensions.ts (types + UiExtensionRegistry class + singleton), mirroring plugin-registry.ts structure
  • Add lib/plugins/ui-extensions.svelte.ts reactive wrapper ($derived.by over tier × database-settings node)

Phase 2: Pro plugin definition + variant components

  • Add lib/plugins/pro-plugin.ts — one proSyncUiExtension definition with the four-variant chrome array and the collaboration viewerExtensions entry
  • New components: pro-teaser-pill.svelte, enable-sync-pill.svelte (small, static copy — do not make teaser content data-driven)
  • Existing pro-sync-pill.svelte / pro-relogin-modal.svelte / collaboration-view.svelte unchanged internally; only their mounting moves to lazy-loaded registry entries

Phase 3: Rewire mount points (delete old gating in the same change — no transition code)

  • app-shell.svelte: delete ProSyncPill/ProReloginModal imports, Pro $effect/$derived blocks, and the hardcoded pill slot div; replace with a generic overlay-slot renderer iterating getActiveChromeContributions('app-shell-overlay')
  • collection-node-viewer.svelte: delete the proSync import and hardcoded {#if proSync.isPro} tab strip; replace with a registry-driven tab strip from getActiveViewerExtensions('collection'). Locked/teaser tab state renders when sync is not enabled for the active database, even on a Pro daemon

Phase 4: Two-axis gating in dependent stores

  • membership.svelte.ts: isPro getter becomes proSync.tier === 'pro' && dbSettings?.properties?.sync_enabled === true (has_role edges are per-database under ADR-053)
  • recovered-items.svelte.ts: fold sync_enabled/auth_status into the existing no-op guard (recovered items only exist for databases that have actually synced)
  • pro-sync.svelte.ts: unchanged in shape; re-document isPro as "daemon binary can sync" (axis 1 only), not "sync is active"
  • tauri-sync-listener.ts: NO change — its coalescing is a data-sync concern, not a rendering surface; leave its proSync.isPro gate as-is

Acceptance Criteria

  • app-shell.svelte and collection-node-viewer.svelte contain zero Pro component imports and zero proSync.isPro conditionals
  • All four pill variants render correctly per the state machine (community teaser; Pro+disabled enable-prompt; Pro+local sign-in; Pro+connected live pill)
  • Collaboration tab shows locked/teaser state on a Pro daemon when the active database has sync_enabled: false
  • Variant re-resolves reactively when the database-settings node changes (no $effect misuse — derived reads only)
  • No new bespoke store for database-settings state — read via sharedNodeStore.getNode('database-settings')
  • membership.svelte.ts and recovered-items.svelte.ts use the two-axis check
  • Existing Pro components (pro-sync-pill, pro-relogin-modal, collaboration-view) unchanged internally
  • No new responsibilities added to base-node-viewer.svelte
  • Tests pass (bun run test:all)
  • Code passes bun run quality:fix

Technical Specifications

Reference Files

  • PluginRegistry: packages/desktop-app/src/lib/plugins/plugin-registry.ts — structural template (plain class, lazy-load-and-cache); do NOT extend PluginDefinition in types.ts
  • Schema loader precedent: packages/desktop-app/src/lib/plugins/schema-plugin-loader.ts — DB-state-materializes-as-plugin pattern
  • Current mount points: packages/desktop-app/src/lib/components/layout/app-shell.svelte, packages/desktop-app/src/lib/components/viewers/collection-node-viewer.svelte
  • Axis-1 signal: packages/desktop-app/src/lib/stores/pro-sync.svelte.ts (tier, isPro derived)
  • Stores to re-gate: packages/desktop-app/src/lib/stores/membership.svelte.ts, packages/desktop-app/src/lib/stores/recovered-items.svelte.ts
  • Reactivity pattern: ADR-049 (canonical reactivity-store pattern) — plain data class + layered $state/$derived
  • Architecture basis: ADR-053 (one daemon, N databases; per-database identity) — Pro UI surfaces are views of the active database's DatabaseSettingsNode

Database-switch requirement (coordination note)

Node IDs are unique only within a database. The restart-free database switcher (ADR-053, not yet built) MUST fully repopulate SharedNodeStore on switch; when it does, database-settings re-resolves to the new database's node and all variants re-derive automatically — no on-switch hook needed in this registry. This is the switcher's obligation; record it in that issue when created.

Standards

  • Svelte 5 runes; derived values over $effect
  • createLogger, no raw console
  • No any types; bun run test, never bun test
  • Greenfield: delete replaced gating code in the same PR, no dual-mode support

Dependencies

Related Issues

Non-Goals

  • The database switcher UI and its store (separate ADR-053 follow-up work)
  • A database-switcher-row chrome slot or pill placement inside the switcher region (real coupling, deliberately deferred until the switcher exists; ChromeSlot stays a string union so the slot can be added without registry changes)
  • Data-driven/node-authored resolveVariant() or teaser copy — the four variants are a fixed hand-written state machine
  • Settings-section slots (no current consumer)
  • Changes to tauri-sync-listener.ts coalescing or backend/Tauri commands

Activity

  1. self-assigned this
    on Jul 7, 2026
  2. mstomar125 commented on Jul 7, 2026

    @mstomar125
    Contributor

    Not picked up today — hard-blocked on #1398.

    The sync_enabled / auth_status properties the pill state machine reads don't exist until #1398 lands, and re-gating membership.isPro on sync_enabled before #1398 populates that property would regress every existing Pro daemon (the property would be permanently undefined → collaboration tab + live-sync pill silently lost). Even after #1398 it's ~1–2 days (new registry subsystem + reactive .svelte.ts wrapper + Pro plugin + two teaser components + rewiring the ~820-line app-shell + re-gating two stores + a test layer). Ordered after #1398.

  3. mstomar125 commented on Jul 10, 2026

    @mstomar125
    Contributor

    Development complete — merged in PR #1607 (9821b795). Leaving this issue open pending live desktop UI validation.

    What landed

    The Pro-sync UI is now driven by a declarative UI-extension registry with two-axis variant resolution:

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

    The resolver returns only the chrome contributions / viewer extensions matching the current variant; app-shell overlay/modal slots and the collection-node viewer render them through a generic ExtensionOutlet instead of hard-coded pill/modal wiring. Membership and recovered-items stores now gate on the two-axis isProSyncActive() (was tier-only). DatabaseSettingsNode is hydrated on load and after a database switch so the surface re-resolves per active database. Community build resolves to the teaser only — the free experience is unchanged (test:free-users guardrail green).

    Verified: bun run test 3989 passed · test:free-users 11 passed · quality:check (eslint + svelte-check) 0/0 · full pre-push pyramid green.

    Backend follow-up (tracked here)

    There is no per-database "enable sync" intent command yet. enable-sync-pill therefore opts a database into sync via the existing interactive sign-in (pro_initiate_oauth), which flips sync_enabled / auth_status on tenant bind. A dedicated set-sync_enabled command would let a Pro user enable sync for a database without immediately signing in — worth adding when the multi-tenant-per-machine surfaces land.

    Pending

    Live desktop UI validation of the variant transitions (teaser → enable → sign-in → connected across database switches) is still to do — batched with the other live checks. Issue stays open until that passes.

  4. malibio commented on Aug 17, 2026

    @malibio
    CollaboratorAuthor

    Triage (2026-08-17): open for 38 days solely on live UI validation.

    Last update (2026-07-10) reports development complete and merged in PR #1607 (9821b795), left open "pending live desktop UI validation." That validation has not happened since.

    The registry surface is present in the tree — pro-plugin.ts, enable-sync-pill.svelte, pro-sync-pill.svelte, all wired through app-shell.svelte — consistent with the merge report.

    Ask: @malibio this needs either a 10-minute manual pass in the desktop app (non-Pro teaser → Pro enable-prompt → sign-in → connected, across a database switch) or a decision to close on the strength of the merged implementation and reopen if something surfaces in use. Holding an issue open for over a month on an unscheduled manual check mostly costs signal — it reads as in-flight work when the code has shipped.

    Note this overlaps #1535's remaining criterion "Sync pill reflects the active database only; per-database status is correct after switches" — the same manual pass would settle both.

    No action taken — triage note only.

  5. mstomar125 commented on Sep 1, 2026

    @mstomar125
    Contributor

    Verified independently (2026-09-01): this is already fully implemented and shipped.

    • 9821b795 "Add UI-extension registry for two-axis Pro-sync surfaces (ADR-053)" (PR Add UI-extension registry for two-axis Pro-sync surfaces (ADR-053) #1607, merged 2026-07-10) implements the issue's exact spec — confirmed a direct ancestor of current main (git merge-base --is-ancestor).
    • ~20 follow-up PRs since then evolved the variant machine further (4 → 5 variants: teaser/sign-in/consent/relogin/connected), reflecting real product decisions made after this issue was written — a superset of the original spec, not a gap.
    • Re-checked every acceptance criterion against the current tree: app-shell.svelte and collection-node-viewer.svelte have zero proSync.isPro/ProSyncPill/ProReloginModal hardcoded references. membership.svelte.ts uses the two-axis isProSyncActive(). recovered-items.svelte.ts deliberately stays tier-only (documented, reasoned deviation — it's per-user not per-database).
    • Independently ran the regression suite fresh: ui-extensions.test.ts (16), free-user-guardrail.test.ts (11), pro-teaser-pill.test.ts (2), enable-sync-pill.test.ts (2) — 31/31 passing.

    The only thing keeping this open was a manual live-desktop-UI click-through pass requested in the 2026-08-17 triage comment — not a formal acceptance criterion, and not something this environment can run (no browser/GUI/OAuth capability here, same standing limitation as other interactive validation). Closing on the strength of the merged, tested implementation; reopen if that manual pass surfaces something real.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions