Skip to content

feat(api): add POST /session/:sessionID/todo endpoint for plugin todo management#18201

Open
josephbharrison wants to merge 2 commits intoanomalyco:devfrom
josephbharrison:feature/todo-update-endpoint
Open

feat(api): add POST /session/:sessionID/todo endpoint for plugin todo management#18201
josephbharrison wants to merge 2 commits intoanomalyco:devfrom
josephbharrison:feature/todo-update-endpoint

Conversation

@josephbharrison
Copy link
Contributor

Issue for this PR

Closes #17456

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a POST /session/:sessionID/todo endpoint so plugins can write todo items to the TUI sidebar programmatically.

Why this approach: I audited every alternative for plugin-to-TUI todo communication:

  • Plugin tools cannot access Todo from the core package (not in their dependency graph)
  • The Hooks API is reactive only (no proactive writes)
  • The Bus is internal to the core package
  • Extending PluginInput would create a parallel API surface

An HTTP endpoint follows the established pattern: routes → SDK → client. Every other mutating operation in the session routes works this way.

Changes (2 commits):

  1. packages/opencode/src/server/routes/session.ts — Added POST endpoint with:

    • SessionID.zod for param validation (consistent with all other session routes)
    • Todo.Info array body validation via z.object({ todos: z.array(Todo.Info) })
    • Returns the written Todo[] (matches other mutating endpoints)
    • operationId: "session.todoUpdate" (flat naming — generates session.todoUpdate())
    • Also updated GET /:sessionID/todo param validator to use SessionID.zod for consistency
  2. packages/sdk/js/src/v2/gen/ — Regenerated SDK. Adds typed Session.todoUpdate() method, SessionTodoUpdateData, SessionTodoUpdateErrors, SessionTodoUpdateResponses types.

How did you verify your code works?

  • turbo typecheck passes all 13 packages
  • SDK regeneration via bun run script/build.ts completes cleanly
  • Endpoint follows the exact same pattern as existing session mutation routes

Screenshots / recordings

N/A — server-side API change only

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add endpoint to update session todos programmatically. This enables plugins
to sync their todo lists to the TUI sidebar by calling Todo.update() which
publishes the todo.updated Bus event that the TUI subscribes to.

This is needed for plugins like speckit that manage their own todo lists
and want them to appear in the opencode sidebar.
- Validate session existence using Session.get.schema instead of bare z.string()
  (matches pattern used by GET /:sessionID/todo and all other session routes)
- Return the written todo array instead of boolean (matches other mutating endpoints)
- Fix operationId from session.todo.update to session.todoUpdate to generate
  a flat Session.todoUpdate() method instead of a nested Todo subclass
- Regenerate SDK: adds typed todoUpdate() method on Session class
- Also fix GET /:sessionID/todo param validator for consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add Todo List Update API to SDK

1 participant