Repository navigation
Description
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
componentssection ([{ name, expose }])... types generated bybos types genfrom 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):
ssrExposeResolverOfinhost/src/services/ui-compose.tsresolves 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.tsxregisters them all client-side — the clientloadRemotepath needs no new registration (this is whateverything-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.jsoncarriescomponents: [{ 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 throughremoteComponent(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
- Plugin ui component exposes (build contract): ui workspaces declare
uiExportsin the rsbuild factory input (web expose, optionally node for SSR);PLUGIN_UI_SHARED_EXPOSESgains them; the generated pluginrouteConfigis untouched. Node exposes ride the same SSR container — the auth profile precedent proves the pattern. - 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 checkgrows the consumer-side check — a consumer importing/$docs/uifails loud when the active docs ui doesn't expose it (capability contract, ADR 0059 §4). - The generator:
emitUiFacadesis provider-only today (uiFacadeConsumersskips 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 channelapi-types.gen.tsuses, so remote-only plugins typecheck with zero local source. - Preload symmetry:
facadePreloadis 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. - 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.
- 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.
- 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
syncchunks. - Loud skew/capability gates before serving:
sharedVersionscross-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
exportsso 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)
- DX/naming spike: one docs-preview route consuming
/$docs/uiand one core route consuming a plugin component, both against the generated stub shape — settle the specifier before generator work. - 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).
- Tenant override interplay: a tenant overriding
plugins.<id>.uimust re-point every/$<id>/uifacade by compose-payload identity — verify no per-consumer edits. - 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
/kitnamespace 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
- ADR 0010 §3 (the unbuilt half — this generalizes it to core→plugin) and §4 (the gate).
- ADR 0059 §4 (the forward facade; this is its mirror).
- 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): the SSR resolver, discovery surface, preload machinery, and browser-spec pattern this ticket extends.
- Plan 081 phases 3–5: the migrations there stay core-forward; this ticket adds the reverse lane without touching them.
Activity