Files
coder/docs/reference/api/chats.md
T
Hugo Dutka 48ab492f49 feat: agents git watch backend (#22565)
Adds real-time git status watching for workspace agents, so the frontend
can subscribe over WebSocket and show
git file changes in near real-time.

1. Subscription is scoped to a **chat** via `GET
/api/experimental/chats/{chat}/git/watch`.
2. The workspace agent automatically determines which paths to watch
based on tool calls made by the chat (and its ancestor chats).
3. Workspace agent polls subscribed repo working trees on a 30s
interval, on tools calls, and on explicit `refresh` from the client.
4. Scans are rate-limited to at most once per second.
5. Edited paths are tracked **in-memory** inside the workspace agent.
There is no database persistence — state is lost on agent restart. This
will be addresses in a future PR.
6. Messages sent over WebSocket include a full-repo snapshot (unified
diff, branch, origin). A new message is emitted only when the snapshot
changes.

This PR was implemented with AI with me closely controlling what it's
doing. The code follows a plan file that was updated continuously during
implementation. Here's the file if you'd like to see it:
[project.md](https://gist.github.com/hugodutka/8722cf80c92f8a56555f7bc595b770e2).
It reflects the current state of the PR.
2026-03-06 10:47:55 +01:00

1.8 KiB
Generated

Chats

Archive a chat

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/chats/{chat}/archive

POST /chats/{chat}/archive

Responses

Status Meaning Description Schema
204 No Content No Content

Watch git changes for a chat

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/chats/{chat}/git/watch \
  -H 'Coder-Session-Token: API_KEY'

GET /chats/{chat}/git/watch

Parameters

Name In Type Required Description
chat path string(uuid) true Chat ID

Responses

Status Meaning Description Schema
101 Switching Protocols Switching Protocols

To perform this operation, you must be authenticated. Learn more.

Unarchive a chat

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/chats/{chat}/unarchive

POST /chats/{chat}/unarchive

Responses

Status Meaning Description Schema
204 No Content No Content