Repository navigation
feat(coderd): add the chat todo list routes - #36
Conversation
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.
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
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.
There was a problem hiding this comment.
💡 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".
A watcher rereads the list every 30 seconds, so a write whose event was never published, or whose reread failed, still reaches the client.
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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.
Gates checked on head |
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}/todosreturnscodersdk.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/watchis a websocket: the current list first, then the latest list after writes. It subscribes before it accepts, likewatchChats, 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.httpmw.RequireExperiment). Other paths under/chats/forkstill answer 404: the middleware sits on an inline router, because a{chat}subrouter would run it for every path under the mount.Client.ChatTodosandClient.WatchChatTodos. The items decode moves tocodersdk.DecodeChatTodoItems, so the tool and the route return the same shape.@x-apidocgen {"skip": true}like the neighbouring chat routes, sodocs/reference/apidoes not change.typesGenerated.tsis 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) andTestForkChatRoutespass against Postgres 17, the watch test also with-race;TestEndpointsDocumentedpasses;codersdktests pass.UAT on a dev instance with a local model (d7b0670; the resync added later only adds a ticker):
GETreturned the stored list and version (404 for an unknown chat, 401 without a session), andWatchChatTodossent the current list, then the next version 7 seconds after the model calledtodo_write.