Skip to content

ui: the reverse facade — plugin ui component exports consumable by the core ui (and each other), pluginsClient-style, fully typed #1265

Backlog

Description

@efizzybot

The ask

Today composition flows one way for components: plugins consume the core via the @/ui facade (#1260), while plugin UIs expose only their ./routeConfig. The API side already proved the reverse shape: pluginsClient hands the API typed entries for every composed plugin ({ client, router }), two-phase, zero HTTP. This ticket owns the UI analog — plugin ui workspaces declare component exposes; the core ui (and any plugin) consumes them through a generated, fully typed facade — in the spirit of ADR 0010 §3, which wrote the plugin→plugin half of this and was never built:

"Plugin components are exposed and facaded — never build-time imported. The manifest schema gains a components section ([{ name, expose }])... types generated by bos types gen from the owning plugin's deployed manifest, so remote-only plugins typecheck with zero local source."

Rule 4 gates the core's side: core → plugin stays facade-mediated and optional; nothing hard-depends.

Measured today (what already exists to build on)

  • SSR is already source-agnostic (ui: confirm and optimize the @/ui facade path — preload strategy, expose weight, and SSR for remote components #1260, PR feat(everything-dev,every-plugin,host,ui): the @/ui facade renders server-side; the expose ships primitives only (#1260) #1264): ssrExposeResolverOf in host/src/services/ui-compose.ts resolves exposes for ANY key in the composition's healthy set, integrity-verified through the generation-keyed loader caches. A plugin component expose is server-renderable with no new machinery.
  • The compose payload already carries every plugin remote, and hydrate.tsx registers them all client-side — the client loadRemote path needs no new registration (this is what everything-dev/ui/remote's payload-driven self-registration reads).
  • The discovery surface shipped for the core (ui: confirm and optimize the @/ui facade path — preload strategy, expose weight, and SSR for remote components #1260): manifest.gen.json carries components: [{ expose, exports }]. It needs generalizing to plugin ui sources (today only the provider role fills it).
  • The only hand-rolled precedent: plugins/auth/ui's profile page consumes auth's own section remotes through remoteComponent(section.remote, section.expose, section.namedExport) — the ergonomic gap is that every consumer writes this by hand and hand-maintains prop types.
  • Plugin ui workspaces expose only ./routeConfig (PLUGIN_UI_SHARED_EXPOSES) — component exposes are a build-contract addition (packages/every-plugin/src/build/ui).
  • Shared singletons guarantee one React across all containers (web + node share scopes), so a plugin component renders inside the core's tree with no React duplication; selective hydration keeps server HTML visible until the expose lands.
  • Spike 077 measured the auth profile section expose at 76 KB raw / 19.1 KB gzip, fetched once, cached across routes.

Import shape (to settle by spike, not by debate)

The consumer-side specifier is pure DX — tsconfig paths map it to a generated stub, so it can't collide with source-owned @/components. Candidates:

Shape Read Risk
/$docs/ui $ = federated/cross-source; distinct from @/ui (core) $ is unusual in import specifiers
/ui/docs "the ui of docs" visually adjacent to @/ui; may read as a route path
@docs/ui npm-scope feel collides with real npm scopes
[plugin]/ui bare shortest too easy to confuse with package imports

Recommendation: /$[key]/ui, generated per composed consumer into src/ui-remote.gen/[key].gen.ts, mirroring ui.gen.ts one source at a time. The generated file carries per-export remoteComponent(key, expose, name) + load[Key]Ui() + re-exported prop types — @/ui's exact shape, reversed. A docs-preview route (the 077 pattern) proves the DX before any generator work hardens the shape.

Work items

  1. Plugin ui component exposes (build contract): ui workspaces declare uiExports in the rsbuild factory input (web expose, optionally node for SSR); PLUGIN_UI_SHARED_EXPOSES gains them; the generated plugin routeConfig is untouched. Node exposes ride the same SSR container — the auth profile precedent proves the pattern.
  2. Manifest capability: generalize components: [{ expose, exports }] (shipped for the core in ui: confirm and optimize the @/ui facade path — preload strategy, expose weight, and SSR for remote components #1260) to every ui source, collected at manifest generation; bos mf check grows the consumer-side check — a consumer importing /$docs/ui fails loud when the active docs ui doesn't expose it (capability contract, ADR 0059 §4).
  3. The generator: emitUiFacades is provider-only today (uiFacadeConsumers skips the provider path). Generalize to emit one facade per (consumer, composed source) pair. Types: local sources ride the emitted-declarations tree; remote-only sources read the deployed manifest's published type declarations — the same channel api-types.gen.ts uses, so remote-only plugins typecheck with zero local source.
  4. Preload symmetry: facadePreload is core-only today; extend per-source (only sources whose facades the consuming workspace imports), keeping the "async list is never a preload source" rule. The per-page-usage refinement recorded in ui: confirm and optimize the @/ui facade path — preload strategy, expose weight, and SSR for remote components #1260 lands naturally here.
  5. Degradation: feat(host): a plugin ui slot's compose failure degrades that slot only (#1259 done-when 3) #1263 made a plugin ui slot's compose failure degrade that slot only — component composition inherits that posture: an absent/failed source renders the facade fallback + a named error, never a lost route.
  6. Browser spec + measurements: one request per source surface per session, cached across routes; SSR markup pin for a plugin-exported component rendered by the core; first-use latency before/after on the docs/auth surfaces.
  7. Docs: the ui-integration skill teaches the reverse facade next to @/ui; ADR 0010 §3 gets its "built" note or a superseding ADR.

Performance guardrails (the design is already shaped for them)

  • Coarse per-source exposes — one cached request per /$key/ui, never per-component async boundaries (ADR 0059's standing rule). A plugin exposing 12 components under one expose pays one fetch.
  • Zero cost for non-consumers: facades are generated per consuming workspace and land only in the route chunks that import them; no eager loads, no payload growth for runtimes that don't use the capability.
  • SSR resolves in-process through the compose session (no HTTP, no second bundle); selective hydration defers the client boundary without unmounting server HTML.
  • Preload only composed, imported sources — and only their sync chunks.
  • Loud skew/capability gates before serving: sharedVersions cross-check, bos mf check, and the compose digest all cover the new surface; hydration parity stays free because inputs, not outcomes, are digested.
  • Size budget in discovery: record per-expose gzip size alongside exports so agents and devs see the cost of a capability before adopting it (extends ADR 0059 §4's "types, documentation, examples" catalog).

Explore (spikes, cheap and disposable)

  1. DX/naming spike: one docs-preview route consuming /$docs/ui and one core route consuming a plugin component, both against the generated stub shape — settle the specifier before generator work.
  2. Provider replacement: verdict 077's recorded gap — run a fixture where a child REPLACES a plugin ui and the consumer's facade resolves the replacement (the compose payload's per-source identity should make this free; prove it).
  3. Tenant override interplay: a tenant overriding plugins.<id>.ui must re-point every /$<id>/ui facade by compose-payload identity — verify no per-consumer edits.
  4. Coarse vs split plugin exposes: one plugin surface that mixes a heavy export (charts) with light ones — measure whether a two-expose split (./ui, ./ui/heavy) is worth a second request before generalizing.

Non-goals

  • The core hard-depending on a plugin (rule 4 stands — facades are optional by construction, fallback + named error).
  • A generic /kit namespace or per-component MF shares (rejected by ADR 0059).
  • Making plugin→plugin component consumption mandatory; source ownership stays the default.
  • Policing plugin component barrels — capability exposure is opt-in, declared, and gated.

Relationships

Activity

  1. added
    needs-triage
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions