Skip to content

feat(coderd): add the chat todo list routes - #36

Merged
ibetitsmike merged 5 commits into
mainfrom
mike/todo-transcripts-4-todo-routes
Nov 9, 2026
Merged

ibetitsmike merged 5 commits into
mainfrom
mike/todo-transcripts-4-todo-routes

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #10. Follows #34 (merged); independent of #35.

Adds the read side of the chat todo list for the UI panel that comes next in the stack. Behind fork-chat-todos, like the tools.

  • GET /api/v2/chats/fork/{chat}/todos returns codersdk.ChatTodoList{todos, version}: an empty list at version 0 when the chat has none. The read runs as the request actor, so dbauthz enforces read access to the chat.
  • GET /api/v2/chats/fork/{chat}/todos/watch is a websocket: the current list first, then the latest list after writes. It subscribes before it accepts, like watchChats, so no write between the first read and the stream is lost. The pubsub callback only wakes one send loop, which rereads the list and sends it when its version is newer: writes close together coalesce, a dropped-messages error forces a resync, and API shutdown ends the stream. The loop also rereads every 30 seconds, so a write whose event was never published, or whose reread failed, still reaches the client.
  • With the experiment off both answer 403 (httpmw.RequireExperiment). Other paths under /chats/fork still answer 404: the middleware sits on an inline router, because a {chat} subrouter would run it for every path under the mount.
  • SDK: Client.ChatTodos and Client.WatchChatTodos. The items decode moves to codersdk.DecodeChatTodoItems, so the tool and the route return the same shape.
  • Swagger annotations use @x-apidocgen {"skip": true} like the neighbouring chat routes, so docs/reference/api does not change. typesGenerated.ts is regenerated.

Validation: TestForkChatTodos (empty, after writes), TestForkChatTodosExperimentOff, TestForkChatTodosPermission (another member gets 404), TestForkChatTodosWatch (initial list, then an update), TestForkChatTodosWatchResync (a write without an event arrives after the mock clock passes 30 seconds) and TestForkChatRoutes pass against Postgres 17, the watch test also with -race; TestEndpointsDocumented passes; codersdk tests pass.

UAT on a dev instance with a local model (d7b0670; the resync added later only adds a ticker): GET returned the stored list and version (404 for an unknown chat, 401 without a session), and WatchChatTodos sent the current list, then the next version 7 seconds after the model called todo_write.

Serve the chat todo list over the API so the UI can read and watch it
while the todo_write tool works on a chat.

GET /api/v2/chats/fork/{chat}/todos returns the stored list, and
GET .../todos/watch streams it over a websocket: the current list first,
then the new list after every write. Both read as the request actor, so
dbauthz enforces read access to the owning chat, and both sit behind the
fork-chat-todos experiment inside the reserved /chats/fork mount.

The fork routes take their middleware from an inline router rather than
a {chat} subrouter, because chi mounts a subrouter on a prefix and would
then run the experiment and chat parameter middleware for fork paths
that match no route, replacing the reserved 404 with a 403 or a 400.

The items decode moves to codersdk.DecodeChatTodoItems so the tool and
the route answer the same way, including an empty list rather than null.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T09:25:54.847432Z de74d22 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4de11f5e9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/fork_chat_todos.go Resolved
Comment thread coderd/fork_chat_todos.go Resolved
Comment thread coderd/fork_chat_todos.go Resolved
Comment thread coderd/fork_chat_todos.go Resolved
The pubsub callback now only wakes the handler, which reads and sends the latest list itself. Concurrent callbacks can no longer race on the encoder, a dropped-messages error forces a resync, API shutdown ends the stream, and the docs say that close writes can coalesce.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

Addressed all four Codex findings in d7b0670 (one send loop).

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7b06700e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/fork_chat_todos.go Resolved
Comment thread coderd/fork_chat_todos.go Resolved
A watcher rereads the list every 30 seconds, so a write whose event was
never published, or whose reread failed, still reaches the client.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: de74d221a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The resync const sat between the annotations and the func, which drops
the route from swagger.
@ibetitsmike
ibetitsmike merged commit 1e37dc0 into main Nov 9, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/todo-transcripts-4-todo-routes branch November 9, 2026 11:15
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Gates checked on head 326391eaaf: fork-ci green on this head, including the swagger annotation tests from #41; 0 unresolved review threads; mergeable and clean against main 01de159086. Codex found no issues on de74d221a8; the only change after it, besides a merge of main, moves chatTodosWatchResync out of the swagger comment block of watchChatTodos (I compared the PR patch before and after). UAT on d7b06700e2: GET todos 200, unknown chat 404, no session 401, and the websocket watch sent the initial list and then the update after todo_write. The 30-second resync added after UAT is covered by TestForkChatTodosWatchResync, which fails without it. Merged after 01de159086 deployed healthy.

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.

1 participant