Skip to content

fix: regenerate API docs for the chat todo routes - #55

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

ibetitsmike merged 4 commits into
mainfrom
mike/apidoc-todo-routes-regen

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Closes #54

coderd/apidoc on main has no entry for the chat todo routes from #36 or for the ChatTodo schemas. This PR regenerates it and adds a fork-ci check so this kind of drift fails CI.

Changes

  • Ran make -B coderd/apidoc/.gen and committed the output: coderd/apidoc/docs.go, swagger.json, and the two docs/reference/api pages that changed. schemas.md gains the ChatTodo types. In general.md, the experiments example now shows fork-chat-todos instead of example.
  • Added .github/fork/check-apidoc.sh and a step that runs it in the chat-tests job, right after the Swagger annotation tests. The script runs swaginit with SWAG_OUTPUT_DIR set to a temp dir, which swaginit supports. It then compares the output with the committed docs.go (the embedded spec and the Go code after it) and swagger.json.

Why the check does not diff docs.go directly

swag does not produce the same output on every run. It collects constants by ranging over a map of a package's files (ParseTypes in swag v1.16.6 packages.go). codersdk.Experiment is declared in two files, deployment.go and the fork's fork_experiments.go, so the fork experiments land at either the start or the end of the enum arrays. In 6 runs of swaginit on the same tree, I got two different docs.go hashes, about half each. A plain diff would therefore fail about half the time. The script parses both specs with jq -S and sorts the values of codersdk.Experiment before it compares them. Each value's x-enum-varnames and x-enum-descriptions entries move with it, so a stale value-to-name mapping still fails. Every other enum keeps its order, so an intentional reorder still fails. codersdk.Experiment is the only enum that carries the fork values, and the 6 runs above produced exactly two outputs, which fits one cross-file enum. The parse writes to files and runs under set -e, so a parse failure fails the step and cannot pass as an empty diff.

The same randomness means a local make gen can reorder those enum arrays and the general.md example. The check ignores that.

Validation

  • Before the regen, the check fails on current main. It reports only additions: the todo route and the ChatTodo schemas.
  • After the regen, the check passes 6 of 6 runs, which covers both Experiment orders.
  • Controls, each of which makes the check fail: appending a byte to swagger.json (exit 5); swapping two codersdk.Experiment varnames; swapping the first two codersdk.ChatTodoStatus values together with their names. The first Codex fix caught the varname swap, and the second caught the reorder.
  • Rendered pages under docs/reference/api are not checked. Their enum order is random as well, and rendering them needs the Node toolchain. See the review thread.
  • shellcheck .github/fork/check-apidoc.sh is clean.
Check output on main before the regen (exit 1)
--- $tmp/committed-spec.json	2026-11-09 14:35:11
+++ $tmp/generated-spec.json	2026-11-09 14:35:11
@@ -4766,7 +4766,51 @@
         "ChatTitleSourceGenerated",
         "ChatTitleSourceUser"
       ]
+    },
+    "codersdk.ChatTodo": {
+      "properties": {
+        "content": {
+          "type": "string"
+        },
+        "id": {
+          "type": "string"
+        },
+        "status": {
+          "$ref": "#/definitions/codersdk.ChatTodoStatus"
+        }
+      },
+      "type": "object"
+    },
+    "codersdk.ChatTodoList": {
+      "properties": {
+        "todos": {
+          "items": {
+            "$ref": "#/definitions/codersdk.ChatTodo"
+          },
+          "type": "array"
+        },
+        "version": {
+          "description": "Version is the revision of Todos. It lets a watcher drop an event for\na version it has already sent.",
+          "type": "integer"
+        }
+      },
+      "type": "object"
     },
+    "codersdk.ChatTodoStatus": {
+      "enum": [
+        "pending",
+        "in_progress",
+        "done",
+        "cancelled"
+      ],
+      "type": "string",
+      "x-enum-varnames": [
+        "ChatTodoStatusPending",
+        "ChatTodoStatusInProgress",
+        "ChatTodoStatusDone",
+        "ChatTodoStatusCancelled"
+      ]
+    },
     "codersdk.ChatUnsupportedProvider": {
       "properties": {
         "display_name": {
@@ -23132,6 +23176,84 @@
           }
         ],
         "summary": "Create chat file download URL",
+        "tags": [
+          "Chats"
+        ],
+        "x-apidocgen": {
+          "skip": true
+        }
+      }
+    },
+    "/api/v2/chats/fork/{chat}/todos": {
+      "get": {
+        "description": "Returns the todo list that the todo_write tool keeps for this\nchat, or an empty list at version 0 when the chat has none.",
+        "operationId": "get-the-chat-todo-list",
+        "parameters": [
+          {
+            "description": "Chat ID",
+            "format": "uuid",
+            "in": "path",
+            "name": "chat",
+            "required": true,
+            "type": "string"
+          }
+        ],
+        "produces": [
+          "application/json"
+        ],
+        "responses": {
+          "200": {
+            "description": "OK",
+            "schema": {
+              "$ref": "#/definitions/codersdk.ChatTodoList"
+            }
+          }
+        },
+        "security": [
+          {
+            "CoderSessionToken": []
+          }
+        ],
+        "summary": "Get the chat todo list",
+        "tags": [
+          "Chats"
+        ],
+        "x-apidocgen": {
+          "skip": true
+        }
+      }
+    },
+    "/api/v2/chats/fork/{chat}/todos/watch": {
+      "get": {
+        "description": "Streams the todo list of the chat over a websocket: the current\nlist first, then the latest list after writes to it. Writes close\ntogether can arrive as one list.",
+        "operationId": "watch-the-chat-todo-list",
+        "parameters": [
+          {
+            "description": "Chat ID",
+            "format": "uuid",
+            "in": "path",
+            "name": "chat",
+            "required": true,
+            "type": "string"
+          }
+        ],
+        "produces": [
+          "application/json"
+        ],
+        "responses": {
+          "200": {
+            "description": "OK",
+            "schema": {
+              "$ref": "#/definitions/codersdk.ChatTodoList"
+            }
+          }
+        },
+        "security": [
+          {
+            "CoderSessionToken": []
+          }
+        ],
+        "summary": "Watch the chat todo list",
         "tags": [
           "Chats"
         ],
--- $tmp/committed-swagger.json	2026-11-09 14:35:11
+++ $tmp/generated-swagger.json	2026-11-09 14:35:11
@@ -4766,7 +4766,51 @@
         "ChatTitleSourceGenerated",
         "ChatTitleSourceUser"
       ]
+    },
+    "codersdk.ChatTodo": {
+      "properties": {
+        "content": {
+          "type": "string"
+        },
+        "id": {
+          "type": "string"
+        },
+        "status": {
+          "$ref": "#/definitions/codersdk.ChatTodoStatus"
+        }
+      },
+      "type": "object"
+    },
+    "codersdk.ChatTodoList": {
+      "properties": {
+        "todos": {
+          "items": {
+            "$ref": "#/definitions/codersdk.ChatTodo"
+          },
+          "type": "array"
+        },
+        "version": {
+          "description": "Version is the revision of Todos. It lets a watcher drop an event for\na version it has already sent.",
+          "type": "integer"
+        }
+      },
+      "type": "object"
     },
+    "codersdk.ChatTodoStatus": {
+      "enum": [
+        "pending",
+        "in_progress",
+        "done",
+        "cancelled"
+      ],
+      "type": "string",
+      "x-enum-varnames": [
+        "ChatTodoStatusPending",
+        "ChatTodoStatusInProgress",
+        "ChatTodoStatusDone",
+        "ChatTodoStatusCancelled"
+      ]
+    },
     "codersdk.ChatUnsupportedProvider": {
       "properties": {
         "display_name": {
@@ -23131,6 +23175,84 @@
           }
         ],
         "summary": "Create chat file download URL",
+        "tags": [
+          "Chats"
+        ],
+        "x-apidocgen": {
+          "skip": true
+        }
+      }
+    },
+    "/api/v2/chats/fork/{chat}/todos": {
+      "get": {
+        "description": "Returns the todo list that the todo_write tool keeps for this\nchat, or an empty list at version 0 when the chat has none.",
+        "operationId": "get-the-chat-todo-list",
+        "parameters": [
+          {
+            "description": "Chat ID",
+            "format": "uuid",
+            "in": "path",
+            "name": "chat",
+            "required": true,
+            "type": "string"
+          }
+        ],
+        "produces": [
+          "application/json"
+        ],
+        "responses": {
+          "200": {
+            "description": "OK",
+            "schema": {
+              "$ref": "#/definitions/codersdk.ChatTodoList"
+            }
+          }
+        },
+        "security": [
+          {
+            "CoderSessionToken": []
+          }
+        ],
+        "summary": "Get the chat todo list",
+        "tags": [
+          "Chats"
+        ],
+        "x-apidocgen": {
+          "skip": true
+        }
+      }
+    },
+    "/api/v2/chats/fork/{chat}/todos/watch": {
+      "get": {
+        "description": "Streams the todo list of the chat over a websocket: the current\nlist first, then the latest list after writes to it. Writes close\ntogether can arrive as one list.",
+        "operationId": "watch-the-chat-todo-list",
+        "parameters": [
+          {
+            "description": "Chat ID",
+            "format": "uuid",
+            "in": "path",
+            "name": "chat",
+            "required": true,
+            "type": "string"
+          }
+        ],
+        "produces": [
+          "application/json"
+        ],
+        "responses": {
+          "200": {
+            "description": "OK",
+            "schema": {
+              "$ref": "#/definitions/codersdk.ChatTodoList"
+            }
+          }
+        },
+        "security": [
+          {
+            "CoderSessionToken": []
+          }
+        ],
+        "summary": "Watch the chat todo list",
         "tags": [
           "Chats"
         ],
coderd/apidoc is out of date. Run make -B coderd/apidoc/.gen and commit the result.
EXIT=1
Check output after the regen (exit 0)
EXIT=0

Regenerates coderd/apidoc for the fork chat todo routes and schemas, and
adds a fork-ci step that fails when coderd/apidoc drifts from the API
annotations. The step ignores enum order, which swag emits in map order
for an enum declared across files.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@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-09T13:38:37.703103Z f4a1fc0 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: d1594e64e6

ℹ️ 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 .github/fork/check-apidoc.sh Resolved
Comment thread .github/fork/check-apidoc.sh Resolved
… check

Sorting enum, x-enum-varnames and x-enum-descriptions independently let a
stale value-to-name mapping pass. Sort them as tuples keyed by the value.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@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: b457a8b5cc

ℹ️ 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 .github/fork/check-apidoc.sh Resolved
Sorting every enum let an intentional reorder of an ordinary enum pass.
Only codersdk.Experiment spans files, so only its order is random.
@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. Breezy!

Reviewed commit: f4a1fc086f

ℹ️ 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".

…es-regen

# Conflicts:
#	coderd/apidoc/docs.go
#	coderd/apidoc/swagger.json
@ibetitsmike
ibetitsmike merged commit ab33ec5 into main Nov 9, 2026
9 checks passed
@ibetitsmike

Copy link
Copy Markdown
Owner Author

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

Merged at 9613ed7, paired as a CI and generated-docs change with #52 in the same deploy slot, after these checks:

Closes #54.

@ibetitsmike
ibetitsmike deleted the mike/apidoc-todo-routes-regen branch November 9, 2026 14:52
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.

fix(coderd/apidoc): regenerate API docs for the chat todo routes

1 participant