Files
wehub-resource-sync e30e75b5d4
Changesets / Create Version PR (push) Waiting to run
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:40:13 +08:00
..

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_taskBoard tool with partial scalar updates and array operations
  • Collection edits go through tasks.add, tasks.update, tasks.remove, and tasks.clear on the generated update tool

Sticky Notes

  • unstable_useInteractable("notes", config) — registers the sticky-note collection and selectedId as one state object
  • Auto-generated update_notes manages 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 via useAui, with a load/save adapter
  • unstable_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, and set operations on the same update_{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