with-interactables
Demonstrates interactable components — persistent UI components whose state can be read and updated by both the user and the AI assistant.
Features Demonstrated
Task Board
unstable_useInteractable("taskBoard", config)— registers a single interactable- Auto-generated
update_taskBoardtool with partial scalar updates and array operations - Collection edits go through
tasks.add,tasks.update,tasks.remove, andtasks.clearon the generated update tool
Sticky Notes
unstable_useInteractable("notes", config)— registers the sticky-note collection andselectedIdas one state object- Auto-generated
update_notesmanages both note collection edits and selected-note focus - Selection: click a note to set
selectedId; the AI can change focus by updating the same normal state field - Partial updates: AI can change just one note field with
notes.update: [{ id, color: "pink" }]
Getting Started
# Install dependencies (from monorepo root)
pnpm install
# Set your OpenAI API key
cp .env.example .env.local
# Edit .env.local and add your OPENAI_API_KEY
# Run the development server
pnpm --filter with-interactables dev
Open http://localhost:3000 to see the example.
Key Concepts
unstable_Interactables({ persistence })— scope resource registered viauseAui, with aload/saveadapterunstable_useInteractable(name, config)— returns[state, { id, setState, isPending, error, flush }]- Partial updates — auto-generated tools use partial schemas; AI only sends changed fields
- Array operations — array fields support generated
add,update,remove,clear, andsetoperations on the sameupdate_{name}tool - Selection as state — focused UI state lives in the interactable's normal schema (
selectedId), not in a separate manage tool sendAutomaticallyWhen— auto-sends follow-up messages when tool calls complete