Skip to content

[N12] todo.updated stream event and useTodos() for React, Vue and Svelte - #299

Merged
LinuxDevil merged 3 commits into
mainfrom
lou-n12-use-todos
Oct 2, 2026
Merged

LinuxDevil merged 3 commits into
mainfrom
lou-n12-use-todos

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

Every successful todo_write now emits a typed todo.updated event, the shared UI reducer keeps the list, and useTodos() (React, Vue) / loushoTodos() (Svelte) expose it with counts, the current item and progress. isAgentEvent() is exhaustive, which also fixes remote clients dropping agent.drift.

Closes #254

Changes

  • todo_write brands its result (non-enumerable Symbol.for('lousho.todoList')); toolSettled emits todo.updated { todos, counts, toolCallId } right after tool.done (sub-agents too, with subagent). todo_read is not branded.
  • EVENT_TYPE_MAP: Record<AgentEventType, true> replaces the hand-written list (adds agent.drift and todo.updated; schema version stays 1).
  • AgentUIState.todos (kept across turns, cleared by ui.reset, sub-agent updates ignored); todoView() in src/ui/todos.ts.
  • useTodos(agent) (React, memoized), useTodos(agent) (Vue, one ComputedRef per field), loushoTodos(agent) (Svelte); useLoushoAgent / loushoAgent expose todos.
  • toUIMessageStream() sends a data-lousho-todos part { todos, counts } (id todos).
  • Agent Forge: no exhaustive switch over event.type exists, nothing to change; its four checks pass.

For the docs site

New headings (appended at the end of the page, so existing heading positions are unchanged): ## Todos in docs/react.md, docs/vue.md and docs/svelte.md. No new page.
Edited without new headings: docs/stream-events.md (new todo.updated row in the event table), docs/tools.md ("Todo tools": one added sentence), docs/ai-sdk-ui.md (new table row), docs/react.md (todos row in "Returned state"), docs/vue.md and docs/svelte.md (todos added to the state lists).

Verification (after merging origin/main, 814add8)

  • npx tsc --noEmit: clean. npm run lint: zero warnings. npm run build and the create-lousho-agent build: ok.
  • npm run test:types: 13 files passed, no type errors. docs:verify-snippets -- --skip-build: all 210 snippets type-check, 8 run. docs:llms:check: ok.
  • npm run test:coverage: 230 files passed (one run hit a load-related timeout in http.test.ts "rejects near the configured timeout"; it passes alone and on the re-run). npm run fallow: 0 above threshold, exit 0.
  • Agent Forge: typecheck, typecheck:server clean; test 112 passed; test:server 122 passed.
  • npm run pack-smoke: all checks passed.
  • typecheck-ai7 steps (ai@7, tsc, full vitest) and typecheck-zod4 steps (zod@4, tsc, test:types, full vitest): passed locally before the merge; default dependencies restored with npm ci, no lockfile change.

Live test spend: none (no live calls).

🤖 Generated with Claude Code

LinuxDevil and others added 3 commits October 2, 2026 19:38
…ct, Vue and Svelte

Every successful todo_write emits todo.updated; the UI reducer keeps the list
(AgentUIState.todos), the three bindings expose a todo view, and the AI SDK UI
stream sends a data-lousho-todos part. isAgentEvent() is now exhaustive via a
Record<AgentEventType, true>, which fixes remote clients dropping agent.drift.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@LinuxDevil
LinuxDevil merged commit ae714cc into main Oct 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[N12] todo.updated stream event and useTodos() for React, Vue and Svelte

1 participant