Moves the chat mutation verbs out of `chatd.go` into `chat_mutations.go`. They share one helper, `Server.updateChat`, instead of each repeating the transition, reload and publish steps. ## Changes - `chat_mutations.go`: `SendMessage`, `EditMessage`, `PromoteQueued`, `DeleteQueued`, `ArchiveChat`, `UnarchiveChat`, `SubmitToolResults`, `InterruptChat`, `CompactChat`, `ClearChat` and `ReconcileInvalidStateChat`, plus their private helpers. They stay `*Server` methods; there is no wrapper type. - `updateChat` runs the transition in one chatstate transaction and reloads the chat inside it, so the result and the sidebar watch event carry the snapshot bump. Then it publishes only the `status_change` watch event. Compact and clear already hold the post-transition row, so they skip the reload. - Edit-target checks reuse `validateEditTarget`. The root-chat archive guard lives only in `setChatFamilyArchived`. `publishChatPubsubEvent(s)` stay in `chatd.go`. - Net diff: +1,125/-1,128 (production -83, tests +80). ## Behavior No intended behavior change. Transaction boundaries, locking, hook order, error strings, publish order and the debug cleanup cutoff match main. The moved code includes main's later changes: inline MCP server replacement on send (#29546), the first-turn fallback title (#27111), configurable limits (#28927), queue wait metrics (#29771) and inline interruption finish (#30259). `auto_archive.go` keeps its own archive path. Its precondition is checked under the lock, it uses the worker's store, and it returns rows for auditing. ## Testing Rebuilt on main `b2c8798e0e0`. A 42-mutant sweep ran on main and on this branch, and nothing main's tests caught goes uncaught here. New tests, each red-green checked by removing the code it guards: - `TestUpdateChat` covers the reload, skipping the reload, and rollback with nothing published. - `TestArchiveStateRejectsChildChat` uses the public methods on a real database, uses `ErrorIs`, and checks both archive flags stay unchanged. It replaces `TestUnarchiveChildChat` and `TestArchiveChat_RejectsChildChat`. - `TestArchivedChatRejectsMutations` covers the in-transaction archived check for six verbs; no test covered it before. - A `title_change` assertion is added to `TestSendMessageFirstUserTurnFallbackTitle`, and `TestArchiveChatDeletesDebugRuns` covers archive debug cleanup. Validation: - `go build ./coderd/... ./enterprise/...`, `go vet ./coderd/x/chatd/...`, `golangci-lint` and `make lint/go/new-code`: clean. - `go test ./coderd/x/chatd/... -count=1` passes on all packages, and a race run on the touched tests passes. - `./coderd` chat tests pass, including `TestInlineMCPServers`, `TestWatchChats` and `TestSubmitToolResults` (158 runs), as do the chat state and hook tests and `./enterprise/coderd` chat tests. - Local pre-push checks were skipped at the author's request; CI is the gate. ## Review record - [Codex OK](https://github.com/coder/coder/pull/28756#issuecomment-6151488087) on head `fc327b8b873`, no unresolved threads. [CI passed](https://github.com/coder/coder/actions/runs/38439818111) on the same head. The first CI run on `3d9b0e83369` caught a test bug: parallel subtests shared one parent context and timed out while waiting for a slot. `fc327b8b873` gives each subtest its own context. - Earlier Codex OKs and @ThomasK33's approval are on superseded heads (`fe038a5f13a` and earlier). This description replaces the old "single mutator" framing. - Independent agent review of the rebuilt branch: GO, with every verb's behavior equal to main. P3 fixes applied: moved code kept in main's formatting, and a retry rationale comment restored. Not added: a unit test of the tool-result validation detail strings, because it would make the PR net-positive. Main also only checks those details through coderd `TestSubmitToolResults`. - This PR and #28757 conflict in `chatd_test.go`. Whichever merges second needs main merged in. > Xum (an AI coding agent) rebuilt this PR on behalf of @ibetitsmike.
Coder is a self-hosted platform for cloud development environments and AI coding agents. Workspaces are defined with Terraform, connected through a secure Wireguard® tunnel, and automatically shut down when not used. Coder Agents runs a native AI coding agent whose loop executes in the control plane on your infrastructure, with no API keys in workspaces.
- Define cloud development environments in Terraform
- EC2 VMs, Kubernetes Pods, Docker Containers, etc.
- Automatically shutdown idle resources to save on costs
- Onboard developers in seconds instead of days
- Delegate coding work to AI agents on your infrastructure
- Bring any model (Anthropic, OpenAI, Google, Bedrock, self-hosted)
- No LLM credentials in workspaces, user identity on every action
- Centralized model governance, cost tracking, and audit logging
Quickstart
Check out our install guides for other methods and a complete tutorial.
Try Coder with the install script on Linux and macOS, or grab the latest binary or installer from GitHub Releases on Windows:
curl -fsSL https://coder.com/install.sh | sh
Start the server and open http://localhost:3000 to create your initial user, create a Docker template, and provision your first workspace:
coder server
For a production deployment, add a PostgreSQL database (version 13 or later) and an external access URL, and see our validated architectures for sizing and infrastructure guidance:
coder server --postgres-url <url> --access-url <url>
Without these flags, Coder uses a built-in database and sets up a *.try.coder.app access URL for evaluation. Use coder --help for the full list of flags and environment variables.
Documentation
Browse the documentation or visit a specific section below:
- Workspaces: Workspaces contain the IDEs, dependencies, and configuration information needed for software development
- Templates: Templates are written in Terraform and describe the infrastructure for workspaces
- Coder Agents: Delegate coding work to AI agents running on your self-hosted infrastructure
- AI Gateway: Centralize authentication, auditing, and cost controls for AI tooling
- Administration: Learn how to operate Coder
- Premium: Learn about paid features built for large teams
- IDEs: Connect your existing editor to a workspace
Support
Open an issue for bugs and feature requests.
For community support, showcasing what you built, and feedback on in-progress features, join our Discord or GitHub Discussions.
Dedicated support is included in Coder Premium. For more information, visit coder.com/pricing.
Integrations
New integrations are always in progress. Open an issue to request one. Contributions are welcome in any official or community repository.
Official
- Coder Registry: Templates, modules, and integrations for common development environments
- Coding Agents: Run agents like Claude Code, Codex, and OpenCode isolated in Coder workspaces
- coderd Terraform Provider: Declaratively manage your Coder deployment configuration as code
- VS Code Extension: Open any Coder workspace in VS Code with a single click
- JetBrains Toolbox Plugin: Open any Coder workspace from JetBrains Toolbox with a single click
- Dev Containers: Build development environments using
devcontainer.jsonon Docker, Kubernetes, and OpenShift - Kubernetes Log Stream: Stream Kubernetes Pod events to the Coder startup logs
- Self-Hosted VS Code Extension Marketplace: A private extension marketplace that works in restricted or airgapped networks integrating with code-server.
- GitHub Actions: An action to set up the Coder CLI in GitHub workflows
Community
- Coder Discord: Chat with the community, get support, and hear about new product updates first
- Community Templates: Community-contributed workspace templates in the Coder Registry
- Community Modules: Community-contributed modules to extend Coder templates
- Coder Template GitHub Action: A GitHub Action that updates Coder templates
- Coder Agents Chat Action: A GitHub Action that starts a Coder Agents chat against a GitHub issue or pull request
Contributing
New contributors are always welcome. If you are new to the Coder codebase, see the contribution guide to get started.
Hiring
Apply on the careers page if you are interested in joining the team.
