feat(api): add POST /session/:sessionID/todo endpoint for plugin todo management#18201
Open
josephbharrison wants to merge 2 commits intoanomalyco:devfrom
Open
feat(api): add POST /session/:sessionID/todo endpoint for plugin todo management#18201josephbharrison wants to merge 2 commits intoanomalyco:devfrom
josephbharrison wants to merge 2 commits intoanomalyco:devfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #17456
Type of change
What does this PR do?
Adds a
POST /session/:sessionID/todoendpoint so plugins can write todo items to the TUI sidebar programmatically.Why this approach: I audited every alternative for plugin-to-TUI todo communication:
Todofrom the core package (not in their dependency graph)An HTTP endpoint follows the established pattern: routes → SDK → client. Every other mutating operation in the session routes works this way.
Changes (2 commits):
packages/opencode/src/server/routes/session.ts— Added POST endpoint with:SessionID.zodfor param validation (consistent with all other session routes)Todo.Infoarray body validation viaz.object({ todos: z.array(Todo.Info) })Todo[](matches other mutating endpoints)operationId: "session.todoUpdate"(flat naming — generatessession.todoUpdate())/:sessionID/todoparam validator to useSessionID.zodfor consistencypackages/sdk/js/src/v2/gen/— Regenerated SDK. Adds typedSession.todoUpdate()method,SessionTodoUpdateData,SessionTodoUpdateErrors,SessionTodoUpdateResponsestypes.How did you verify your code works?
turbo typecheckpasses all 13 packagesbun run script/build.tscompletes cleanlyScreenshots / recordings
N/A — server-side API change only
Checklist