DSH plugin slots: props, injection, and hoc remounts
"Two plugins inject into the same slot and the order flipped while props went missing" is usually a wrong input channel, not a broken component. DSH plugin's slots separate owner values, private injection, slot-level injection, and shared stores sharply; pick wrong and you receive data you should not have.
Slots are typed composition; components never see ctx
Slots are the Web Client's typed React composition system.(source)
dsh-client-ui-slots defines the React-free registry and type algebra; dsh-client-ui-renderer binds observable sources into hooks, renders the whole tree, and owns React context internally. Feature plugins contribute UI through ctx.slots.register() and never import another feature plugin's components.
SlotMap is the compile-time registry. Packages write key, cardinality, scope, owner props, keyed props, and an optional slot-level inject face through declaration merging. Runtime declarations are the matching entries the component owning that render position supplies in children.
Components never receive ctx. Values the parent already knows at that render enter through renderSlot's owner argument; shared view state uses a declared store; services and model objects stay in the apply closure, projecting only callbacks or observable sources to components.
Declarations and lifetimes follow Cordis effects
Disposing one entry recursively folds the child slots it declared.(source)
Declaring a child does three things at once: it makes that child key live, authorizes the parent entry to call renderSlot or renderSlotChain, and records the runtime dispatch specification.
Each declaration has exactly one live owner. Registering into an undeclared slot, or redeclaring a child another entry already owns, fails during plugin activation — the error appears at startup rather than at render time.
root is the only built-in declaration and the only key rendered by the Cordis service itself: ui-renderer calls ctx.slots.renderSlot('root', {}), and every descendant renders through the renderSlot or renderSlotChain prop its declaring entry received.
Registration and declaration follow Cordis effect lifetimes. So contributing to another package's slot goes through ctx.slots.inject(key, callback): the callback runs inside each declaration lifetime, its effect is removed when the owner folds, and it runs again when the owner mounts again.
Four input channels
Decide who owns the data, then choose the channel.(source)
A registered component receives assembled inputs at its binding position. The four main channels:
- owner values and standard scope values — derived as
PropsRuntime<K>; - shared view state — after declaring a store, the component receives a selector hook and mutation callbacks typed
PropsStore<H>; - private data and callbacks — supplied by the entry's inject factory as
InjectFace<I>; - authorized child renderers — derived from
childrenkeys asPropsRenderSlots<S>.
Two more exist: the localized t function comes from the entry's locale namespace, and chain-selected values arrive as matched through ComposedProps while hoc-wrapped owner content arrives as children.
When an entry declares a session or session-maybe child, PropsRenderSlots also provides SessionProvider: without a session prop it inherits the outer binding, and an explicit SessionReference or undefined overrides only that subtree. Strict session entries remount when the binding generation changes, while an empty session-maybe entry accepting its first binding does not remount.
Framework hooks come from the slot's scope
Hooks come from the target slot's scope, not from the registering package.(source)
Adapters in the current composition add standard props:
- all scopes —
useSessions,useSessionStatus,useSessionRetainInfo,useSessionAccess(ui-session),useWorkspaces,useWorkspaceAccess(ui-workspace),useRemoteAccess(api-remote-access),usePanelInfo(ui-layout); - session —
sessionId,useSession,useProjection,useAccess, plususeConversation,useInput,inputActions,useChat,useTrajectory; - session-maybe — the same names with optional results.
The renderer also creates useStore from declared stores and t from declared locale namespaces. These are entry-derived props, not global standard props.
Framework and domain adapter owners can extend the standard set through ctx.slots.provideRoot() or ctx.uiSession.provide() along with matching declaration merges. Ordinary feature components should not invent their own React hook props or add global standard props for entry-private data.
inject is a feature-private channel
The hooks object holds raw sources; the renderer does the binding.(source)
An entry's inject option is the usual feature-private injection point. Its factory runs in the plugin's apply world, may close over Cordis services already injected, and returns only the data and callbacks the component needs.
Scope arguments vary by slot: a session slot receives sessionId, session-maybe receives sessionId | undefined, and declaring a store also supplies that store's bound actions.
The hooks object returned holds raw getSnapshot and subscribe sources. The renderer turns hooks: { status } into a component prop useStatus(selector) and caches bindings by source identity. Components never receive the source itself and never call useSyncExternalStore directly.
When every occupant needs the same capability, the slot owner can place an inject face in the child declaration: plain members pass through to all occupants, while function members in the hooks object are hook factories that receive the slot's standard props plus an optional per-render hookContext and return a restricted hook for occupants. conversation.chat.node uses exactly this to provide useTurnData(key) for the node being rendered.
hoc layering and remounts
Order compiles before rendering, and remounts depend on whether the layer chain changed.(source)
The selection rule compresses to one line: values known to the owner at render go through owner props; one entry's callbacks and private observables go through entry inject; capabilities the slot owner controls and all occupants share go through slot-level inject; mutable view state shared across entries or surviving remounts goes through a declared store. React nodes compose through child slots, never through injected values.
priority changes meaning with cardinality: for single, list, keyed, and hoc cells it is shadowing priority; for chain it is election order. Smaller numbers run or render first.
hoc nesting rules: a layer without a key is a wildcard applying to every dispatch; a keyed layer applies only when the owner passes the same entryKey; under one id, an exact-key layer replaces that key's wildcard layer. Layers nest ascending by order, then priority, then registration order, with the smallest outermost.
Each layer receives the same owner props and receives the next inner layer as children (the innermost being the owner's content), rendering at most once; a layer that does not render children replaces everything inside it. Owner props must not use the name children. Omitting children wraps empty content per layer, and when no layer applies the content renders unchanged.
Remount criteria follow the layer chain: adding or removing a layer that applies to this dispatch remounts its inner content; layers in session or session-maybe scope also remount inner content when the Session binding changes; outlets dispatching the same key share one compiled chain, so layers registered for other keys do not remount them; and an outlet switching entryKey moves to another chain, remounting content even when the effective layers are identical.
Error semantics are separate: a crashing layer reports its error as usual and renders its children at that point until that mount ends; the layer stays registered so other occurrences keep it. Errors thrown by wrapped content pass through every layer without being attributed to one.
Verification: two plugins in one slot
Check order, prop provenance, and remount count together.(source)
- Plugin A registers a list item at
order: 100and plugin B atorder: 50; assert B comes first. - Both register a single cell with the same id; assert the smaller priority renders rather than both.
- Declare a store for one item and assert it reads state through
useStore, not through owner props. - Add
injectto one item and assert the factory receivessessionIdand the component receivesuseXxxrather than a raw source. - Add a hoc layer applying to that dispatch at runtime and assert inner content remounts once.
- Switch the outlet's
entryKeyand assert content remounts even with the same effective layers.
If step 5 does not remount, check whether that layer's key truly matches this dispatch — a keyed layer never applies to another entryKey.
For the full cardinality and scope table, see the client slots overview; for client resource lifetime, see client resource lifecycle.
One line to close: components never get ctx, declarations fold with effects, four input channels each have an owner, hooks expose sources only, hoc order compiles early, and remounts follow the layer chain.
FAQ
No. DSH plugin states components never receive ctx. DSH plugin sends parent-known values through owner props, shared view state through stores, and services stay in the apply closure projecting callbacks or observables.
In the plugin's apply world. DSH plugin lets it close over already injected Cordis services, and DSH plugin requires it to return only the data and callbacks the component needs.
No. DSH plugin treats priority as shadowing priority only for single, list, keyed, and hoc. In a DSH plugin chain it is election order, where smaller numbers run first.
It replaces everything inside it, which DSH plugin treats as intentional override. Omitting children wraps empty content per layer, and content renders unchanged when no layer applies.
Related Terms
- SlotMap
- SlotMap is the compile-time registry, extended by declaration merging with key, cardinality, scope, owner props, and an optional slot-level inject face.— packages/client/ui-slots/src/index.ts
- PropsRuntime
- PropsRuntime<K> is the props type a registered component derives from owner values and standard scope values.— packages/client/ui-slots/src/index.ts
- InjectFace
- InjectFace is the private data, callbacks, and observable hooks an entry's inject factory returns to its component.— packages/client/ui-slots/src/index.ts
- hoc layer
- A hoc layer is one wrapper addressed by id and optional key, nested by order, priority, and registration order, smallest outermost.— DeepSeek Harness reference - Web client slots
Sources
- DeepSeek Harness reference - Web client slots· deepseek-ai
- packages/client/ui-slots/src/index.ts· deepseek-ai