You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add persistence API to interactables with exportState/importState, debounced setPersistenceAdapter, per-id isPending/error tracking, flush() for immediate sync, and auto-flush on component unregister.
| `setSelected` | `(selected:boolean) =>void` | Mark this interactable as selected |
255
+
| `isPending` | `boolean` | Whether a persistence save is in-flight |
256
+
| `error` | `unknown` | Error from the last failed save |
257
+
| `flush` | `() =>Promise<void>` | Force an immediate persistence save |
255
258
256
259
### `Interactables`
257
260
@@ -274,6 +277,62 @@ When you call `useAssistantInteractable("taskBoard", config)`:
274
277
5. **Partial merge** — only the fields the AI sends are updated; the rest are preserved.
275
278
6. **Bidirectional updates** — when the AI calls the tool, the state updates and React re-renders. When the user updates state via `setState`, the model context is notified so the AI sees the latest state on the next turn.
276
279
280
+
## Persistence
281
+
282
+
By default, interactable state is in-memory and lost on page refresh. You can add persistence by providing a save callback:
// Imported state is picked up when components next register
334
+
```
335
+
277
336
## Combining with Tools
278
337
279
338
You can use `Interactables` alongside `Tools`:
@@ -284,3 +343,12 @@ const aui = useAui({
284
343
interactables: Interactables(),
285
344
});
286
345
```
346
+
347
+
## Full Example
348
+
349
+
See the complete [with-interactables example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-interactables) for a working implementation featuring:
350
+
351
+
- **Task Board** — single-instance interactable with a custom `manage_tasks` tool
352
+
- **Sticky Notes** — multi-instance interactables with selection and partial updates
353
+
- **localStorage persistence** — state survives page refresh via `setPersistenceAdapter`
354
+
- **Sync indicator** — spinning icon while a save is in-flight (`isPending`)
0 commit comments