Skip to content

docs: generate Chats API docs from swagger annotations#24830

Merged
david-fraley merged 11 commits into
mainfrom
dfraley/exp-chats-swagger
May 5, 2026
Merged

docs: generate Chats API docs from swagger annotations#24830
david-fraley merged 11 commits into
mainfrom
dfraley/exp-chats-swagger

Conversation

@david-fraley
Copy link
Copy Markdown
Collaborator

@david-fraley david-fraley commented Apr 29, 2026

Adds swagger annotations to all 16 endpoints under /api/experimental/chats so they autogenerate into docs/reference/api/chats.md. Replaces the hand-maintained docs/ai-coder/agents/chats-api.md with the generated reference.

Authorization for the AGENTS.md exception (no swagger annotations on coderd/exp_chats.go): CODAGT-250 (created by Cian Johnston, May Beta milestone).

Endpoints documented

REST:

Method Route Summary
GET /experimental/chats List chats
POST /experimental/chats Create chat
GET /experimental/chats/{chat} Get chat by ID
PATCH /experimental/chats/{chat} Update chat
GET /experimental/chats/{chat}/messages List chat messages
POST /experimental/chats/{chat}/messages Send chat message
PATCH /experimental/chats/{chat}/messages/{message} Edit chat message
POST /experimental/chats/{chat}/interrupt Interrupt chat
POST /experimental/chats/{chat}/title/regenerate Regenerate chat title
GET /experimental/chats/{chat}/diff Get chat diff contents
POST /experimental/chats/files Upload chat file
GET /experimental/chats/files/{file} Get chat file

WebSockets (annotated like the existing watchWorkspaceWS in coderd/workspaces.go):

Method Route Summary
GET /experimental/chats/watch Watch chat events for a user via WebSockets
GET /experimental/chats/{chat}/stream Stream chat events via WebSockets
GET /experimental/chats/{chat}/stream/git Watch chat workspace git state via WebSockets
GET /experimental/chats/{chat}/stream/desktop Connect to chat workspace desktop via WebSockets

Intentionally not annotated

Admin endpoints (retention config, usage limits, compaction thresholds, workspace overrides) keep their existing @x-apidocgen {"skip": true} markers. They are not part of the May Beta integration surface.

Side effect: codersdk.Chat.LastInjectedContext doc comment

The pre-existing emdash in this comment propagated through the regenerated apidoc and tripped scripts/check_emdash.sh once chats.md was regenerated. Replaced with a comma. No semantic change; this also flows through to site/src/api/typesGenerated.ts.

Manifest and link cleanup

  • docs/ai-coder/agents/chats-api.md: removed.
  • docs/manifest.json: removed the Chats API entry.
  • docs/ai-coder/agents/getting-started.md: 3 in-prose links retargeted to ../../reference/api/chats.md.
  • coder.com redirect: filed as a separate PR on coder/coder.com.

Validation

  • make gen succeeds and is idempotent (no diff on rerun).
  • bash scripts/check_emdash.sh: clean.
  • pnpm exec markdownlint-cli2 'docs/ai-coder/agents/**/*.md' 'docs/reference/api/chats.md' 'docs/reference/api/schemas.md': 0 errors.
  • python3 -c "import json; json.load(open('docs/manifest.json'))": valid.
  • go build ./coderd/... and go vet ./coderd/ ./codersdk/: clean.

UI proof

Screenshots of the generated reference (rendered via headless Chrome from the markdown) are attached to the chat where this PR was prepared. David: please drag chats-endpoints.png and chats-endpoint-send-message.png into this description before marking ready for review. (These predate the WebSocket additions; the live page on coder.com after merge will include all 16 endpoints.)

Linear and authorization context

Generated by Coder Agent on behalf of @david-fraley.

Adds @Summary/@Router/@tags annotations to the 12 public endpoints under
/api/experimental/chats so they render in the autogenerated API reference
at docs/reference/api/chats.md. Replaces the hand-maintained chats-api.md
with the generated reference.

Authorization for the AGENTS.md exception (no swagger annotations on
coderd/exp_chats.go): CODAGT-250.

Endpoints documented:
- GET, POST /experimental/chats
- GET, PATCH /experimental/chats/{chat}
- GET, POST /experimental/chats/{chat}/messages
- PATCH /experimental/chats/{chat}/messages/{message}
- POST /experimental/chats/{chat}/interrupt
- POST /experimental/chats/{chat}/title/regenerate
- GET /experimental/chats/{chat}/diff
- POST /experimental/chats/files
- GET /experimental/chats/files/{file}

Admin endpoints (retention, usage limits, compaction thresholds,
workspace overrides) and WebSocket endpoints (/stream, /watch, *.gen)
remain unannotated for now and continue to use @x-apidocgen skip.

Also fixes a stray emdash in codersdk.Chat.LastInjectedContext doc
comment that propagated through the generated apidoc and tripped
scripts/check_emdash.sh once chats.md regenerated.

Generated by Coder Agent on behalf of @david-fraley.
@github-actions
Copy link
Copy Markdown

Docs preview

📖 View docs preview

@david-fraley david-fraley changed the title docs(coderd/exp_chats): generate Chats API docs from swagger annotations docs: generate Chats API docs from swagger annotations Apr 29, 2026
Adds @Summary/@Router/@tags annotations to the 4 chat WebSocket
handlers so they render alongside the REST endpoints in the
autogenerated reference:

- GET /experimental/chats/watch (watchChats)
- GET /experimental/chats/{chat}/stream (streamChat)
- GET /experimental/chats/{chat}/stream/git (watchChatGit)
- GET /experimental/chats/{chat}/stream/desktop (watchChatDesktop)

Pattern matches watchWorkspaceWS in coderd/workspaces.go: swag handles
WebSocket endpoints fine. Earlier 'follow-up needed' note was wrong.

Generated by Coder Agent on behalf of @david-fraley.
@david-fraley david-fraley marked this pull request as ready for review April 29, 2026 21:11
Three changes that surface stability information for the experimental
Chats API:

1. Adds @description "Experimental: this endpoint is subject to
   change." to all 16 chat handler annotations. swag renders the
   description as a paragraph below the route line on each endpoint
   page (same pattern as 'Get all templates' in coderd/templates.go).

2. Sets state: ["experimental"] on the Chats reference manifest entry
   so the docs sidebar shows a stability badge. (Companion change in
   coder/coder.com adds the badge style.)

3. Teaches scripts/apidocgen/postprocess/main.go to preserve existing
   state, description, and icon_path on REST API child entries when
   regenerating the manifest. Without this the badge would be wiped on
   the next make gen.

Generated by Coder Agent on behalf of @david-fraley.
Add swagger annotations to the GET /experimental/chats/models
handler. The endpoint was previously neither documented nor marked
skip; this brings it into the autogenerated reference.
Copy link
Copy Markdown
Collaborator Author

Added swagger annotations to the GET /api/experimental/chats/models handler. It was the one public-facing chat endpoint that was neither documented nor marked @x-apidocgen {"skip": true}. Now part of the generated reference; make gen is idempotent.

This is Coder Agents responding on @david-fraley's behalf.

david-fraley added a commit that referenced this pull request Apr 30, 2026
- Drop CODER_EXPERIMENTS=agents references; the flag was removed by #24432
- Keep 'coder exp agents' per @david-fraley's direction (the API is still
  experimental) even though #24432 also graduated the CLI to 'coder agents'
- Repoint chats-api.md link to ../../reference/api/chats.md (deletion in #24830)
- Flip manifest state to beta to match the rest of /agents/ post-#24826
- Clarify that 'waiting' is both the initial idle state and the post-
  completion idle state in the status mapping table
Comment thread docs/manifest.json Outdated
johnstcn and others added 3 commits May 1, 2026 11:57
Addresses some notes in the swagger definitions

- interruptChat: 204 -> 200 codersdk.Chat
- postChatMessages: 201 -> 200 to match handler
- streamChat: {array} -> {object} to match watchWorkspaceWS
- chatFileByID: widen @produce to actual MIME list
- postChatFile: drop redundant Content-Type @Param
- watchChatDesktop: note raw binary stream in @description
mattvollmer added a commit that referenced this pull request May 4, 2026
…#24929)

Updates `docs/ai-coder/index.md`, `docs/ai-coder/best-practices.md`, and
`docs/ai-coder/ai-governance.md` to point readers at Coder Agents and
the AI Governance Add-On instead of Coder Tasks and Agent Firewall
(CODAGT-157).

## Changes

- `docs/ai-coder/index.md`:
- Rename `## Agents with Coder Tasks` to `## Coder Agents`. Drop the
Devin / ChatGPT Codex name-drops and the Tasks pitch. New copy points at
`./agents/index.md`, names the agent loop in the control plane, and
notes that workspaces can be completely network isolated. Image swapped
from `tasks-ui.png` to `agents-hero-image.png` (the hero shot added in
#24915).
- Replace the `## Secure Your Workflows with Agent Firewall` section
with `## Govern AI activity with the AI Governance Add-On`. The new
section opens with adoption-first framing (visibility, guardrails, cost)
and links to `./ai-governance.md`, with bulleted callouts for AI
Gateway, Agent Firewall, and the expanded Agent Workspace Build
allowance the add-on bundles.
- `docs/ai-coder/best-practices.md`:
- In the use-case table, swap `[Tasks](./tasks.md)` to `[Coder
Agents](./agents/index.md)` for the developer-led-investigation and
prototyping rows, and swap the "Tasks API *(in development)*" cell to
`[Coder Agents API](./agents/chats-api.md)` for the background-jobs row.
Retitle the Security section link from "securing agents with Coder
Tasks" to "securing AI agents" since `security.md` does not actually
mention Tasks. Re-ran `markdown-table-formatter` to repad column widths.
- In `## Provide Agents with Proper Context`, add a paragraph describing
how context is provided in Coder Agents (admin-configured system
prompts, centrally registered MCP servers, and skills shipped from repos
or templates under `.agents/skills/`), with a transition line clarifying
that the existing Memory and Tools subsections cover BYO-agent patterns.
- `docs/ai-coder/ai-governance.md`: drop the "Additional Tasks Use (via
Agent Workspace Builds)" bullet from the intro feature list and the
"Expanding the use of Coder Tasks for AI-driven background work" bullet
from the audience list. The `## How Coder Tasks usage is measured`
section and the rest of the Tasks-related prose on this page are
intentionally left for a follow-up PR.

## Notes for the reviewer

- The `[Coder Agents API](./agents/chats-api.md)` link in
`best-practices.md` will need to be retargeted if #24830 (which replaces
`agents/chats-api.md` with auto-generated `reference/api/chats.md`)
lands first.
- This is the first slice of the Tasks-references audit. Remaining files
(`tasks-core-principles.md`, `tasks-lifecycle.md`, `tasks-migration.md`,
`cli.md`, `github-to-tasks.md`, `agent-compatibility.md`, the rest of
`ai-governance.md`, `custom-agents.md`,
`ai-gateway/clients/claude-code.md`, `manifest.json`,
`reference/api/tasks.md`, the `task*` CLI references, the ESR upgrade
guide, `feature-stages.md`, `workspace-scheduling.md`,
`shared-workspaces.md`) will land in follow-up PRs against the same
Linear ticket. Open PRs #24831, #24833, and #24841 cover separate slices
and do not touch any file in this PR.
- Validation: `markdownlint-cli2`, `markdown-table-formatter`,
`scripts/check_emdash.sh`, and `make pre-commit-light` all pass.

PR generated with Coder Agents.
- docs/ai-coder/agents/getting-started.md: use 'beta' wording from main,
  keep generated docs link from this branch
- docs/manifest.json: accept 'beta' state for Extending Agents, keep
  Tasks to Chats Migration entry from main, keep removal of Chats API
  entry (replaced by generated reference)
- docs/ai-coder/agents/chats-api.md: keep deleted (replaced by generated
  docs/reference/api/chats.md)
- coderd/apidoc/docs.go, coderd/apidoc/swagger.json: regenerated via
  make gen
The deleted chats-api.md was referenced from best-practices.md.
Retarget to the generated reference at ../reference/api/chats.md.
@david-fraley david-fraley enabled auto-merge (squash) May 5, 2026 16:40
Keep entries from both branches: Security & Agent Firewall and
GitHub to Tasks Workflow from main, plus Tasks to Chats API
Migration from this branch.
The merge from main re-introduced the chats-api.md manifest entry
that this PR originally removed. Also fix trailing whitespace in
best-practices.md markdown table.
@david-fraley david-fraley merged commit e7360da into main May 5, 2026
50 of 52 checks passed
@david-fraley david-fraley deleted the dfraley/exp-chats-swagger branch May 5, 2026 18:52
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants