bindThreadRuntime
Connect one assistant-ui ThreadRuntime and send its public events to a core runtime supplied by your app.
Signature and import
Create one binding per thread scope and dispose it when that subscription owner unmounts.
import { bindThreadRuntime } from "@generative-a11y/assistant-ui";
const binding = bindThreadRuntime({
runtime,
scopeId: "support-thread",
thread,
maxTrackedEntities: 1_000,
});
// Removes only the subscription and adapter state.
binding.dispose();How this code works
- 01Use the app runtime
ThreadBinding sends events to core without disposing your runtime.
- 02Separate thread IDs
scopeIdprevents ID collisions across mounted conversations. - 03Read public thread state
ThreadBinding needs only getState and subscribe from ThreadRuntime.
- 04Dispose the binding
dispose removes the subscription without changing the thread runtime.
Options and return values
runtimePick<GenerativeA11yRuntime, 'dispatch'>Required
Receives adapter events while remaining under your app's control.
- Default
n/a
scopeIdstringRequired
Stable non-empty namespace for message, tool, approval, and citation identity.
- Default
n/a
threadThreadRuntimeSourceRequired
Borrowed getState and subscribe surface from assistant-ui.
- Default
n/a
maxTrackedEntitiesnumberOptional
Bounds message, part, tool, and approval identity tracking.
- Default
1000
returnThreadBindingReturn
An idempotent dispose method for the adapter subscription.
- Default
n/a
Events reported from thread state
Each public thread snapshot is compared with its previous value, and confirmed changes become events.
| assistant-ui state | generative-a11y event | Source |
|---|---|---|
| Assistant message starts running | response.started | Public message state |
| Text grows | response.text.delta | New text only |
| Message finishes, stops, or fails | completed, interrupted, failed | Public message status |
| Tool call and result parts | tool lifecycle | Public content parts |
| Approval state | approval requested or resolved | Public content parts |
| Source parts | citation.available | Optional content parts |