mirror of
https://github.com/coder/coder.git
synced 2026-11-20 09:58:59 +08:00
main
2138
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7f245d8296 |
chore!: remove legacy AI Gateway metric aliases (#32381)
Removes the deprecated `coder_aibridged_*` and `coder_aibridgeproxyd_*` Prometheus metric aliases, which were scheduled for removal in v2.37. The embedded AI Gateway and AI Gateway Proxy now emit only `coder_ai_gateway_*` and `coder_ai_gateway_proxy_*`. - Replace `NewMetricAliasRegisterer` with `prometheus.WrapRegistererWithPrefix` in `cli/server.go` and `enterprise/cli/aibridgeproxyd.go`. - Delete `coderd/prometheusmetrics/metricalias.go` and its test (no remaining callers). - Drop alias support from the metrics docs scanner. - Update the AI Gateway monitoring and rebranding migration docs: legacy names are removed as of v2.40. **Breaking:** dashboards and alerts that still use the legacy names stop matching. The monitoring docs show a temporary `metric_relabel_configs` bridge. Closes AIGOV-447. <details> <summary>Implementation plan</summary> | File | Change | |---|---| | `cli/server.go` | Remove the `TODO(deprecation)` comment; register embedded gateway metrics with `prometheus.WrapRegistererWithPrefix(aibridgemetrics.PrometheusMetricPrefix, ...)`. | | `enterprise/cli/aibridgeproxyd.go` | Same swap with the `coder_ai_gateway_proxy_` prefix; drop the unused `prometheusmetrics` import. | | `coderd/prometheusmetrics/metricalias.go`, `metricalias_test.go` | Delete; the two call sites above were the only callers. | | `scripts/metricsdocgen/scanner/prefix.go` | Remove `NewMetricAliasRegisterer` from `prefixFuncs`. | | `scripts/metricsdocgen/scanner/scanner_test.go` | Remove the alias fixture and the legacy-alias assertion; the remaining literal-prefix case already covers plain `WrapRegistererWithPrefix`. | | `scripts/metricsdocgen/README.md` | Drop the `NewMetricAliasRegisterer` mention. | | `docs/ai-governance/ai-gateway/monitoring.md` | State that legacy names are no longer emitted as of v2.40; reword the relabel snippet as a temporary bridge and explain its cost. | | `docs/ai-governance/ai-gateway/rebranding-migration.md` | Mark metrics as "No (removed in v2.40)"; rewrite the Metrics section; remove the now-obsolete "dropping the old names" section. | Release note: the `!` title applies `release/breaking`, so the change is listed under breaking changes in the v2.40 release notes. Verification: `make gen` (no metrics reference changes), `make lint`, `pnpm run format-docs`, `pnpm run lint-docs`, doc-check and test-audit self-review, and targeted tests for `enterprise/cli` (AI Gateway / proxy), `cli` (AI Gateway), `scripts/metricsdocgen`, and `coderd/prometheusmetrics`. </details> Code written by @mollymaefraser, with Coder Agents used as a guide. |
||
|
|
707083166a |
test(cli): fix flake due to UDP crosstalk (#32102)
fixes ENT-252 In a port forward test for UDP, there are actually 2 UDP socket on the remote side (the local side uses a mocked network). There is the target socket where our echo server is listening, and the UDP socket that the workspace agent opens up to talk to it. We must be getting crosstalk on the workspace agent socket, because the echo server was already filtering based on prefix. The solution in this PR is to move the filtering all the way back to the test function itself, so if crosstalk comes either on the echo socket or the workspace agent socket, we'll forward it across the tailnet, but ultimately filter it in the test function before asserting. --------- Signed-off-by: Spike Curtis <spike@spikecurtis.com> |
||
|
|
a1751d1887 |
fix: timeout agent dial in coder support bundle so unreachable agents wont hang (#31697)
if `coder support bundle <workspace>` is run when the workspace agent had a record but was unreachable, this would cause the command to hang. This command uploads a number of diagnostics from both the server and agent, including `pprof`. If the agent is unreachable, this should still be able to write out as much of the bundle as possible without timing out. The agent dial now has a configurable time limit (`Deps.AgentDialTimeout`, default 30s). On timeout the bundle logs a warning, skips the sections that need a live agent connection (ping, peer diagnostics, magicsock, manifest, agent logs over tailnet, listening ports, workspace files, agent pprof), and still writes out the bundle. This includes agent logs fetched through the API. The CLI prints a warning and records it in `cli_logs.txt`; exit status stays 0. Other changes: - Each request over an established agent connection has a 10s limit, and workspace file collection has a 60s limit, so an agent that drops mid-collection can't stall the bundle either. - Agent pprof is skipped when the first dial already failed, instead of waiting through a second dial. Server pprof collection is unchanged. - `support.AgentInfo` now takes the dial timeout and also reports whether the agent was reachable. <details> <summary>Verification and decision log</summary> **Reproduction.** An end-to-end CLI test seeds a workspace whose build has an agent record but never starts an agent process, then runs `coder support bundle <ws> --yes` with a 90s outer deadline. | Tree | Result | |---|---| | `main` | Hung until the 90s deadline. | | This branch | Returned in 30.0s with exit 0 and wrote a 33-file zip. `logs.txt` contains `agent unreachable, skipping agent-connected sections` and `cli_logs.txt` contains `could not connect to workspace agent`. | `TestRun/AgentUnreachable` in `support/support_test.go` covers both `--pprof` off and on. **Decisions.** - The hang was in `DialAgent` itself (`workspacesdk.go`, `AwaitReachable(dialCtx)`), not in `Ping`, so the time limit goes on the context passed to `DialAgent`. That function keeps the connection alive on a separate background context, so cancelling the dial context after a successful dial doesn't close the connection. - The regression test uses a real agent record with no agent process rather than the random agent ID the ticket suggested. A random ID fails fast during agent lookup and never reaches the code that hangs. - Limits follow the existing 10s and 45s timeouts used elsewhere in the bundle collector, plus the ticket's 30s dial target and its worst case of about 60s for an unreachable agent. </details> |
||
|
|
1baff57cb0 |
fix: resolve docs and code conflicts found in the main docs audit (#32158)
## Summary Addresses 106 of the 113 conflicts between the docs and the code that the November audit of `main` found: 102 are fixed and 4 have an interim docs fix. Every finding was re-checked against the code before it was fixed. Most fixes are docs-only. Three are small code fixes where the docs described the intended behavior and the code was wrong, each in its own commits so it can be split out. No change in this PR alters template build or agent behavior. ## Changes Fixes by area (finding counts): templates 28, install 13, integrations and monitoring 13, auth and security 12, networking 11, Coder Agents 9, AI governance 7, reference 7, workspaces 6. Code fixes. Each needs a look from the code owner. If an owner prefers not to take one, drop its commits and I will change the docs to describe the current behavior instead. | Commits | Change | Risk to check | |---------|--------|---------------| | `fix: keep built-in listener defaults in packaged coder.env`, and three follow-up commits | `coder.env` comments out `CODER_HTTP_ADDRESS=` and the three `CODER_TLS_*` lines, so an untouched package install listens on `127.0.0.1:3000` as the docs say. Only the `CODER_HTTP_ADDRESS=` line changed behavior. The TLS options default to empty, so commenting them out is for consistency. The Lima examples rewrite the commented line and fail if the line is not found. A test compares every option that the file sets against the built-in defaults. | The deb and RPM packages were not built or installed. Every released package through v2.39.0 ships the empty line, and upgrades keep an existing file (`config\|noreplace`), so the upgrade pages now say how to fix it. | | `fix(cli/clilog): accept log sinks that are all disabled`, and three follow-up commits | `--log-human=/dev/null` with no other log location no longer fails with "no loggers provided". It is the documented way to disable logging. An empty location still fails with that error when no other sink is set, as before. | Behavior change: with `/dev/null`, the server and the provisioner daemon can start with no log output. | | `fix(cli): detect CODER_PROC_PRIO_MGMT by presence`, and a comment follow-up | Log line only. With the variable set to an empty value, the agent now logs that process priority management is enabled, which is what `agentexec` already does. No detection or behavior change. | Low. | Two option descriptions in `codersdk/deployment.go` are corrected, with the CLI reference, configuration reference, and golden files regenerated: the default quiet hours schedule (the max deadline is the quiet hours window on the next day that the template's autostop requirement applies) and `--experiments` (`*` opts in to the experiments marked safe, also in `enterprise/cli/provisionerdaemonstart.go`). ### Code fixes that were reverted after review Two code fixes from the first version of this PR are reverted in the branch. The net diff has no change under `agent/` or `coderd/`. The docs now describe what the code does, and both issues stay open for the owner. - **`error` merge strategy for `coder_env` (DOCS-1669).** The fix made `merge_strategy = "error"` fail whenever a name was set twice, whatever the resource order. Existing template versions that pair an `error` entry with a later `replace` or `append` entry would start to fail every build after `terraform apply`. That is a breaking change that needs its own PR and release note. The fix and its tests are in `dff8e7c6ce` and can be cherry-picked. `environment-variables.md` now says the check runs only when the `error` resource is processed. - **Nice value before the capability drop (DOCS-1687).** The fix let `coder agent-exec` apply a negative nice value by calling `setpriority` before it drops effective capabilities. The current order is deliberate: with the fix, any local process could run the agent binary with `--coder-nice=-20` when the binary has the `CAP_SYS_NICE` file capability. `process-priority.md` now says a nice value below the agent's own is not applied, and no longer tells admins to grant `CAP_SYS_NICE`. ## Not included Seven findings are left out. - DOCS-1629: covered by #31639. - DOCS-1703 and DOCS-1724: covered by #31980. - DOCS-1584, DOCS-1683, DOCS-1685, DOCS-1686: each needs an owner decision, and no neutral docs wording exists until that decision is made. The validation comment on each issue names the decision. Four fixes are interim, so their issues stay open: - DOCS-1600: the AI Gateway pages now agree that the legacy metric names are deprecated and "will be removed in a future release". The code still emits them, and its TODO names v2.37, which has shipped. The owner still needs to set the removal release. - DOCS-1689: the page now says **New Template** opens the builder only for users with the Owner role, because the page gates on read access to the deployment config. Whether Template Admins should get the builder is still open. - DOCS-1669 and DOCS-1687: docs-only for now. Refer to [Code fixes that were reverted after review](#code-fixes-that-were-reverted-after-review). ## Review notes - Claims that describe product intent and need an owner's yes: the Premium qualifier on per-organization workspace sharing (the API route has no license check, the dashboard needs multiple organizations), `organization` port sharing in OSS, the telemetry field list, and the `1-5` cron range in the prebuilds schedule example. - Not run end to end: the PostgreSQL TLS procedure on a cluster, the OpenShift and air-gapped examples, the BSD `date` and `tar` forms on macOS, the Windows command on the multiple Kubernetes clusters page, and the keep-alive script in `docs/reference/index.md` (only its comparison logic was run, against sample values). Nothing was checked on a live deployment. - Likely merge conflicts with open PRs: #31990 (`mcp-server.md`, `feature-stages.md`, `docker-in-workspaces.md`), #31982 (`workspace-management.md`), #31980 (`health-check.md`), #31977 (`manage-provisioner-jobs.md`), #31869 (`airgap.md`), #30486 (`add-envbuilder.md`), and #31326 and #31531 (`codersdk/deployment.go` and generated files). ## Testing - `make pre-commit` (gen, fmt, lint, slim build), before the PR opened and again after the review changes. - `go test` for `./cli/clilog/...`, `./codersdk/`, `./cli/` (`TestServer`, `TestAgent`, and golden files), and `./enterprise/cli/` (provisioner, server, and help golden files). `./agent/agentexec/...` and `./coderd/provisionerdserver/...` pass after the reverts. Linux only. CI covers macOS and Windows. - The `coder.env` test fails against the file on `main` and passes against the new one. It reads the file with `godotenv`, which accepts CRLF line endings. - An empty `CODER_HTTP_ADDRESS=` was confirmed end to end with a full build of the server (output below). - The new `sed` and `grep` lines in the Lima examples were run with GNU tools against the old and the new form of `coder.env`. The Lima VMs were not started. - `--log-human=/dev/null` and `CODER_LOGGING_HUMAN=` were confirmed with the same build (output below). - `coder agent-exec --coder-nice=-5 -- echo` from a full build, as a non-root user: `coder-agent: failed to adjust niceness to -5 ...: permission denied` on stderr, the command output on stdout, exit code 0. - `postgres-ssl.md` rendered with the GitHub Markdown API: two ordered lists with three and five items, where `main` has six lists. - markdownlint, the table formatter, `make lint/emdash`, `make lint/docs-html`, `make lint/docs-manifest`, `make lint/docs-redirects`, `make lint/style-claims`, and Vale on the changed lines. - A doc-check self-review of the docs diff by four independent reviewers. It found six problems, which are fixed. The accuracy and coverage lenses ran on every area. The language and structure lenses ran in full on only part of the diff. <details> <summary>Test and terminal output for the code fixes (Linux)</summary> ```console $ go test ./codersdk/ -run TestPackagedCoderEnvKeepsDefaults -count=1 -v --- PASS: TestPackagedCoderEnvKeepsDefaults (0.00s) ok github.com/coder/coder/v2/codersdk 0.071s $ go test ./cli/clilog/ -run TestBuilder -count=1 -v --- PASS: TestBuilder (0.00s) --- PASS: TestBuilder/NoSinks (0.00s) --- PASS: TestBuilder/NoSinks/JSONDevNull (0.00s) --- PASS: TestBuilder/NoSinks/StackdriverDevNull (0.00s) --- PASS: TestBuilder/NoSinks/NoConfiguration (0.00s) --- PASS: TestBuilder/NoSinks/HumanDevNull (0.00s) --- PASS: TestBuilder/WithHuman (0.00s) --- PASS: TestBuilder/WithFilter (0.00s) --- PASS: TestBuilder/WithJSON (0.00s) --- PASS: TestBuilder/Verbose (0.00s) --- PASS: TestBuilder/FromDeploymentValues (0.01s) --- PASS: TestBuilder/FromDeploymentValues/Defaults (0.00s) --- PASS: TestBuilder/FromDeploymentValues/EmptyHumanEnv (0.00s) --- PASS: TestBuilder/FromDeploymentValues/Override (0.00s) ok github.com/coder/coder/v2/cli/clilog 0.171s $ TMPDIR=$HOME/.cache/agentexec-tmp go test ./agent/agentexec/... ./coderd/provisionerdserver/... -count=1 ok github.com/coder/coder/v2/agent/agentexec 4.236s ok github.com/coder/coder/v2/coderd/provisionerdserver 2.404s # Full build of the server (go build ./cmd/coder). An empty value stops it before it connects to the database. $ CODER_HTTP_ADDRESS= coder server --postgres-url 'postgres://127.0.0.1:1/x?sslmode=disable' Encountered an error running "coder server", see "coder server --help" for more information error: TLS is disabled. Enable with --tls-enable or specify a HTTP address # With the variable unset, the server passes that check and goes on to the database. $ coder server --postgres-url 'postgres://127.0.0.1:1/x?sslmode=disable' 2026-11-13 02:19:41.901 [warn] ping postgres: retrying error="dial tcp 127.0.0.1:1: connect: connection refused" try=11 Encountered an error running "coder server", see "coder server --help" for more information error: connect to postgres: connect to postgres: unable to connect after 11 tries; last error: dial tcp 127.0.0.1:1: connect: connection refused # An empty log location with no other sink still stops the server. $ CODER_LOGGING_HUMAN= coder server --postgres-url 'postgres://127.0.0.1:1/x?sslmode=disable' Encountered an error running "coder server", see "coder server --help" for more information error: make logger: no loggers provided, use /dev/null to disable logging # /dev/null passes the logger check. The server prints no log lines and goes on to the database. $ coder server --log-human=/dev/null --postgres-url 'postgres://127.0.0.1:1/x?sslmode=disable' Encountered an error running "coder server", see "coder server --help" for more information error: connect to postgres: connect to postgres: unable to connect after 11 tries; last error: dial tcp 127.0.0.1:1: connect: connection refused ``` </details> ## Linear Fixes DOCS-1583, DOCS-1585, DOCS-1586, DOCS-1587, DOCS-1588, DOCS-1589, DOCS-1590, DOCS-1591, DOCS-1592, DOCS-1593, DOCS-1594, DOCS-1595, DOCS-1596, DOCS-1597, DOCS-1598, DOCS-1599, DOCS-1601, DOCS-1602, DOCS-1603, DOCS-1604, DOCS-1605, DOCS-1606, DOCS-1607, DOCS-1608, DOCS-1609, DOCS-1614, DOCS-1618, DOCS-1619, DOCS-1620, DOCS-1624, DOCS-1635, DOCS-1639, DOCS-1644, DOCS-1651, DOCS-1652, DOCS-1653, DOCS-1654, DOCS-1655, DOCS-1656, DOCS-1657, DOCS-1658, DOCS-1659, DOCS-1660, DOCS-1661, DOCS-1662, DOCS-1663, DOCS-1664, DOCS-1665, DOCS-1666, DOCS-1667, DOCS-1668, DOCS-1670, DOCS-1671, DOCS-1672, DOCS-1673, DOCS-1674, DOCS-1675, DOCS-1676, DOCS-1677, DOCS-1678, DOCS-1679, DOCS-1680, DOCS-1681, DOCS-1682, DOCS-1684, DOCS-1688, DOCS-1690, DOCS-1691, DOCS-1692, DOCS-1693, DOCS-1694, DOCS-1695, DOCS-1696, DOCS-1697, DOCS-1698, DOCS-1699, DOCS-1700, DOCS-1701, DOCS-1702, DOCS-1704, DOCS-1705, DOCS-1706, DOCS-1707, DOCS-1708, DOCS-1709, DOCS-1710, DOCS-1711, DOCS-1712, DOCS-1713, DOCS-1714, DOCS-1715, DOCS-1716, DOCS-1717, DOCS-1718, DOCS-1719, DOCS-1720, DOCS-1721, DOCS-1722, DOCS-1723, DOCS-1725, DOCS-1726, DOCS-1727 Part of DOCS-1600, DOCS-1689, DOCS-1669, DOCS-1687 <details> <summary>Decision log</summary> ### Scope - One PR for all findings, as agreed with the reviewer. The code fixes are separate commits so an owner can ask for any of them to move to its own PR. Nothing in the PR is a breaking change, so the title has no `!`. - A finding was skipped only when an open PR already covers it, or when every available wording would assert an undecided product behavior. - Each validation comment on the Linear issues records the evidence, the corrections to the original finding, and what was not verified. ### Docs or code - The default was a docs-only fix that describes what the code does. - A code fix was chosen when the docs describe a behavior the code plainly intended and the code change is small and testable: the packaged env file, the log sink check, and the log line for the environment variable presence check. - The `error` merge strategy and the nice value ordering started as code fixes and went back to docs-only after review. The first breaks existing template versions. The second weakens a deliberate security ordering. - The SCIM `userName` finding (DOCS-1609) took the docs path. The handler is unchanged. ### Wording choices worth a second look - `feature-stages.md` says `--experiments=*` enables only the experiments marked safe, and points to the "Get safe experiments" API. It does not list the other experiments, because the list would drift and those experiments are hidden on purpose. The `--experiments` flag help now says the same. - `agent-metadata.md` replaces the writes-per-second formula with a description of the batcher (each server replica writes one statement every 5 seconds, or sooner at 500 entries). - `extending-templates/index.md` no longer calls `startup_script` deprecated. The provider documents it as an alias for a `coder_script`. - `postgres-ssl.md` separates client verification from server verification, so the server verification steps work alone. - `rpm.md`, `upgrade.md`, and the 2.29 to 2.34 ESR upgrade page explain the empty `CODER_HTTP_ADDRESS=` line that older packages shipped, because upgrades keep the old file. The behavior changed in v2.34.0 with the serpent upgrade in #24926. - The keep-alive script in `docs/reference/index.md` reads the current deadline and skips the request when it is already later. The comparison is on text, so it applies only when the API returns a UTC timestamp, which needs the database to use the UTC time zone. Otherwise the script sets the deadline on every pass, as it did before, and the page says so. - `external-auth.md` anchors the new GitHub Enterprise regex example. The older unanchored examples on that page and on `git-providers.md` are not changed here. ### Self-review findings that were rejected - "The builder opens for Template Admins": the Templates page needs a successful deployment config read, which the Template Admin role does not have. - "Organization Admins can set AI model prices": the price write authorizes against a site-level object, which organization-scoped grants do not match. - "The provisioner chart sets no default resources": `helm/libcoder/templates/_coder.yaml` applies 2000m and 4096Mi when `coder.resources` is empty. ### Automated review, round 1 The `coder-agents-review` app left 45 findings on `8853332`. Fixed: the two reverts above, the anchored regex, the `coder.env` follow-ups (Lima examples, upgrade notes, a comment in the file, and a test that covers every option in the file), the clilog change, the two option descriptions, and the docs findings (CORS behavior, token lifetime example, keep-alive script, agent metadata, refresh token errors, `switch` form type, `dbcrypt` skip list, and a stray line in a YAML example). Declined, with the reason on each thread: - Refactoring the `agentexec` logging and renaming its log field: not related to a docs conflict. - Rewording the "process priority management not enabled (linux-only)" log message: the docs quote the message, and the wording predates this PR. - Problems in code and docs that this PR does not change (the `Capabilities` subtest, the Helm values comment, the AWS provider path in `airgap.md`, and others in the review's out-of-scope list). ### Automated review, round 2 The app left 14 new findings on `04925bd`, and accepted the three declined threads on `cli/agent.go`. All 14 are fixed. The main one: the round 1 change that removed the "no loggers provided" error went too far, because an empty log location would then start a server with no logs. The error is back for every case except `/dev/null`. Reported by the app as out of scope and not changed: the swagger annotation for `GET /api/v2/experiments/available` declares an array, but the handler returns an object with a `safe` array. Three Storybook fixtures keep the old `--experiments` description. ### Automated review, round 3 The app confirmed that all round 2 findings are fixed, and left 10 small findings on `f55cb6d` (8 P4, 2 Nit). All are fixed: the TLS condition and the release range in the `coder.env` notes, one place for the `/dev/null` rule in `clilog`, two test cases, a clearer test failure, and the CPU example in `agent-metadata.md`. ### Automated review, rounds 4 and 5 Round 4 left one P4 on `8fffb38` (name the `--trace` option in the logging note), which is fixed. Round 5 on `2ce754e` reports no new findings and says every earlier finding is fixed or closed. The app did not post an approval: it leaves its out-of-scope items and the code fixes to a human reviewer. Two threads on `cli/agent.go` stay open on purpose for the code owner. ### Doc-check review The doc-check workflow left 12 comments on `2ce754e` (10 blocking, 2 suggestions). All are fixed in `c888885`: "refer to" or "visit" in place of "see" for cross-references on the lines this PR added, the **New template** label as the dashboard shows it, one instruction per step in the server verification procedure of `postgres-ssl.md`, and two wording changes in `process-priority.md`. The `CAP_SYS_NICE` sentence keeps a short reason, which differs from the suggested text. The `coder-agents-review` app then reviewed that commit (rounds 6 and 7). Round 6 left two P4 findings, fixed in `30b2c79`: the `failed to adjust niceness` message is described once, in the troubleshooting entry, with where it appears, and the client verification steps in `postgres-ssl.md` render as one numbered list. Round 7 reports no new findings. `2a6035c` then softens one sentence from that fix, because the agent logs the stderr of devcontainer CLI commands. The app was not run again on that commit. ### Adjacent gaps found and not fixed here - `add-envbuilder.md` has the same `zip` command that `template-from-scratch.md` had. - `template-from-scratch.md` leaves the reader in `build/` after `cd $_`, before a step that runs from `template-tour`. </details> --- _Generated by Coder Agents on behalf of @nickvigilante._ --------- Co-authored-by: Ben Potter <me@bpmct.net> |
||
|
|
bd268cb28d |
feat: add output formats to coder organizations members edit-roles (#30145)
Uses the `cliui` output helpers from #30508. `coder organizations members edit-roles` printed only `Member roles updated to [...]`, while `members list` supports `-o table|json` and `-c`. It now accepts `-o text|table|json` and `-c`. Table and JSON show the updated member using the `members list` row type and columns. **Behavior change:** Additive. Default text output is unchanged. The command now fetches the member after updating roles, on every invocation; if that read fails, it exits with an error even though the roles were already updated. <details> <summary>Decisions</summary> - The update endpoint doesn't return user data, so the member is re-read to build the table and JSON rows. </details> Closes [CLI-27](https://linear.app/codercom/issue/CLI-27) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
32e1f2502f |
feat: add JSON output to coder tokens create (#30135)
Uses the `cliui` output helpers from #30508. `coder tokens create` printed only the new token's secret, so scripts had to call `tokens view` afterwards to get the token's ID, expiry, and scopes. This adds `-o/--output` with `text` (default) and `json`. The JSON document contains the token's metadata from `APIKeyByID` plus the one-time `key`. **Behavior change:** Additive. The default output is still just the secret, so `$(coder tokens create ...)` keeps working. The command now makes one extra API call after creating the token; if it fails, the command prints a warning to stderr and still outputs the secret rather than exiting with an error. <details> <summary>Decisions</summary> - The metadata lookup uses the key ID parsed from the `<id>-<secret>` token, the same convention `tokens view` and `tokens remove` use. - A failed metadata lookup never fails the command, because the token already exists and the secret can't be shown again. </details> Closes [CLI-14](https://linear.app/codercom/issue/CLI-14) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
e307f1d5cf |
feat: add the user-scoped chat-automations experiment (#32064)
## Why The Automations RFC controls availability with one user-scoped experiment. Its text: "The user-scoped `chat-automations` experiment controls availability. Operators configure defaults with `--experiments` and can change per-user rules while Coder is running. Each surface checks the relevant caller or automation's owner, and experiment evaluation fails closed." The later backend PRs (management routes, the `manage_automations` tool, `Publish`) need that check first. This PR registers the experiment and proves the per-user, fail-closed check. Nothing consumes it yet. Part of CODAGT-1135 ## What changed - Registers `chat-automations` in `ExperimentsKnown` and `ExperimentsUserScoped`. An earlier experiment with this name was removed in #30412, and this PR restores none of its consumers. - Keeps it out of `ExperimentsSafe`, so `--experiments=*` does not turn it on. Automations act with their owner's authority, and a test pins the choice. - Adds the name to the `userScopedExperimentStaticCheck` ruleguard rule, so server code cannot decide it from the static list. `TestExperimentsUserScopedRuleguard` keeps the rule in step with `ExperimentsUserScoped`. - Regenerates the swagger files, `docs/reference/api/schemas.md` and `typesGenerated.ts`. - Adds tests for the real experiment name. The evaluator tests cover the startup default, stored `on`, `off` and condition rules for two users, and an off decision on a rules read error, a malformed rule, an unknown mode, an attribute read error, a condition error and a nil subject. A coderd test with a real database checks the same per-user behavior through `api.ExperimentEvaluator` and `GET /api/v2/experiments`. ## Scope No routes, tool, UI or chatd change. I added no helper: `Evaluator.Enabled(ctx, userID, ex)` already decides per user and fails closed, and API handlers reach it through `api.ExperimentEvaluator`. chatd has no evaluator handle on main, because #31327 removed the unused field. The first chatd consumer adds it together with its read. ## Blast radius With the experiment off, which is the default, behavior on main does not change. Two things become visible. `GET /api/experimental/experiments/rules` and `coder exp experiment-rules list` show a `chat-automations` row, and an administrator can store a rule for it. A deployment that already passes `--experiments=chat-automations` sees three small differences: the startup log reports an opted-in hidden experiment where it reported an unknown one, the deployment Overview page stops flagging the name as invalid, and the rules row shows the static default as on. Nothing reads the experiment yet, so no feature turns on. ## Live check A local `./scripts/develop.sh` deployment built from this head ran with no flag, with `--experiments=*` and with `--experiments=chat-automations`. `GET /api/v2/experiments` lists `chat-automations` for the owner and for a member only when the startup list or a rule turns it on, and `--experiments=*` does not turn it on. A condition rule `user.username == "member"` turned it on for the member and off for the owner without a restart, and `reset` restored the startup default. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_ |
||
|
|
412d998777 | test(cli): skip devcontainer VS Code test until netstack fix (#32058) | ||
|
|
1126533c31 |
feat: export workspace last used time to Prometheus (#31346)
Add an opt-in coderd_workspace_last_used_timestamp_seconds gauge that reports workspaces.last_used_at, the value the dormancy threshold measures inactivity from. To enable it, set --prometheus-collect-workspace-stats or CODER_PROMETHEUS_COLLECT_WORKSPACE_STATS. A separate WorkspaceStats collector refreshes the gauge once a minute in the background from a new GetWorkspaceLastUsedForMetrics query. Each series has a workspace_id label, so a workspace that reuses a deleted workspace's name starts a new series. Workspaces owned by deleted users are excluded. Closes CLIENT-1065 |
||
|
|
0a7ef88af9 |
feat: add option to disable the embedded AI Gateway (#31967)
Adds `--ai-gateway-embedded-enabled` / `CODER_AI_GATEWAY_EMBEDDED_ENABLED` (default `true`) so standalone-only deployments can stop `coderd` from starting the in-memory AI Gateway. `CODER_AI_GATEWAY_ENABLED` stays the global switch: the AI Gateway entitlement, `/api/v2/ai-gateway/serve`, and cost-control metrics still depend only on it. The embedded daemon now starts only when both options are `true`. | `ENABLED` | `EMBEDDED_ENABLED` | Result | |---|---|---| | `true` | `true` | Unchanged | | `true` | `false` | No embedded gateway; standalone gateways keep working | | `false` | any | No AI Gateway | Refs AIGOV-514 ## Open questions for reviewers - **Coder Agents does not work with the embedded gateway disabled.** `chatd` still starts, but model calls fail with "AI Gateway transport factory is not configured" because there is no in-process transport. AIGOV-597 (routing Agents through standalone gateways) was canceled. The docs and option help state that Agents requires the embedded gateway. Is that acceptable, or should `chatd` also be turned off in this mode? - **Option name:** the ticket proposed `CODER_AI_GATEWAY_EMBEDDED_ENABLED` tentatively. OK to keep? ## Verification ``` $ go test ./cli/ -run 'TestServer_AIGateway' -count=1 ok github.com/coder/coder/v2/cli 0.518s $ go test ./enterprise/coderd/ -run 'TestAIGatewayServe' -count=1 ok github.com/coder/coder/v2/enterprise/coderd 0.755s ``` `TestServer_AIGatewayEmbedded` fails when the new check is removed. <details> <summary>Implementation notes</summary> - `codersdk/deployment.go`: new option and `AIBridgeConfig.EmbeddedEnabled` field; updated `--ai-gateway-enabled` description. - `cli/server.go`: outer `if Enabled` sets up cost-control metrics and the blocked-users collector (the standalone `/serve` endpoint uses these too). Inner `if EmbeddedEnabled` creates the daemon, registers the in-memory handler, and adds its cleanup. - `cli/server_test.go`: `TestServer_AIGatewayEmbedded` covers the three modes by checking for the embedded daemon's startup log. - `enterprise/coderd/aibridgeserve_test.go`: `TestAIGatewayServeEmbeddedDisabled` checks the entitlement and `/serve` still work with embedded disabled. - `docs/ai-governance/ai-gateway/standalone.md`: new "Disable the embedded gateway" section. - Remaining files are generated by `make gen`. - Found during review: keeping metrics inside the embedded check would have dropped cost-control metrics for standalone gateways. </details> --- Generated with Coder Agents; reviewed, revised, and verified by @mollymaefraser. |
||
|
|
dca5c97e24 |
feat(cli)!: warn when --column is used without table output (#30147)
`-c/--column` only affects table output, but it was silently ignored with `-o json` or on commands whose default format is text, such as `coder organizations show`. A root middleware next to `PrintDeprecatedOptions` now prints `WARN: --column only applies to table output; add -o table to use it` to stderr (via `cliui.Warn`) when `-c` is passed explicitly and the resolved output format isn't `table`. **Behavior change:** New stderr warning in that case only. Stdout, exit codes, and behavior are unchanged. No warning when `-c` isn't passed, when output is `table`, or on commands without `-o`. <details> <summary>Decisions</summary> - Checked special cases: `users suspend/activate` has `-c` but no `-o` (no warning); `features list` declares its flags directly (still matched); `templates versions list` only changes the default columns (no false positive). </details> Closes [CLI-30](https://linear.app/codercom/issue/CLI-30) _This PR was generated by Coder Agents on behalf of @nickvigilante._ --------- Co-authored-by: Samuel Volin <untra@users.noreply.github.com> |
||
|
|
a0be9d0e1d |
feat: make message_agent always steer (#31175)
`message_agent` no longer takes an `interrupt` flag, and always steers. If the child is busy, it gets the message before its next model call and keeps working. To correct or redirect a busy child, the parent just calls `message_agent`, and `interrupt_agent` only stops it, which is the same split the API has after #31174. The tool result also drops `interrupted`, as it was just whether the child was running before the send. That was the last caller of the interrupt busy behaviour, so chatd and chatstate drop it too. `SendMessage` never interrupts now. On a busy chat it only ever adds the message to a lane, so the sends that moved a running chat to interrupting, or a `requires_action` chat back to running, are gone, along with the send's inline interruption finish for chats with no worker. Most of the diff is deleted tests. A steer send to a paused chat, or to an errored chat whose next message is being edited, no longer fails with a 429 at the queue limit when it's delivered straight away, which is whenever the message being edited is a queue message. Part of CODAGT-1140 |
||
|
|
b798061108 |
perf: reuse import-time lock file and cache terraform version (#29825)
Workspace builds now reuse the lock file that `terraform init` wrote during template import, which takes a minimal Docker build from about 3.1s to 1.65s, measured from build created to agent connected. --------- Co-authored-by: Jon Ayers <jon@coder.com> |
||
|
|
34a14cb552 |
fix: only add the session token to trusted app links in coder open app (#31721)
`coder open app` filled in `$SESSION_TOKEN` for every external app defined in a template, wherever the link pointed. Since #31208 the dashboard only does that when the link opens a known Coder IDE handler and its `url` param is this deployment, so a template app like `vscode://coder.coder-remote/open?url=https://attacker.example&token=$SESSION_TOKEN` was blocked in the dashboard but still got the token from the CLI. This ports the same check to the CLI. A link is trusted when its `url` matches the URL the CLI is logged in to or the deployment's dashboard URL from build info. Links that fail the check are printed with a warning and not opened, the same way sub-agent apps with the placeholder already are. The Go check mirrors `isSessionTokenDestinationTrusted` in `site/src/modules/apps/apps.ts` and the unit tests reuse its cases. Params are parsed like `URLSearchParams`, which is what the IDE extensions use. Where Go can't match the browser exactly, the CLI rejects the link instead: non-ASCII hosts (browsers map them through IDNA) and invalid percent escapes. Heads up that template apps the dashboard already blocks will now stop getting a token from `coder open app` too. This also adds a short section to the template apps docs on when external app links get a session token, since that wasn't documented for the dashboard either. Fixes CLI-57 Follow-up to CORE-783: https://linear.app/codercom/issue/CORE-783/security-coordinate-backend-validation-for-session-token-app-url 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ae6b1faea3 |
fix: make SSH connection hints consistent across CLI, dashboard and docs (#31188)
SSH hints across the CLI, dashboard and docs used different, sometimes broken, workspace names. This makes them consistent with minimal, non-breaking changes and no new syntax: - Plain `ssh` hostnames: `<agent>.<workspace>.<owner>.<suffix>` (or `<workspace>.<suffix>` for single-agent workspaces). Works with `config-ssh` (with or without `--no-wildcard`) and Coder Connect. - `coder` CLI arguments: `[<owner>/]<workspace>[.<agent>]`, with the owner unless the workspace was given by its bare name. Built on #31192, which is now merged into `main`. ## Changes - **`coder ping` multi-agent error**: now suggests `coder ping <workspace>.<agent>` instead of listing agents without a runnable command. Owner-qualified and UUID inputs retain `<owner>/<workspace>`. JSON-mode errors leave stdout empty, and ping still does not autostart stopped workspaces. - **`coder ssh` multi-agent error**: when run directly (no `--ssh-host-prefix`/`--hostname-suffix`), it suggested `ssh coder.dogfood.matifali`, which never resolves without a matching SSH config entry or Coder Connect. For an agent named `dev`, it now suggests `coder ssh dogfood.dev`, or `coder ssh bob/dogfood.dev` if the workspace was given as `owner/name` or by ID. Here `.dev` selects the agent; it is not an SSH hostname suffix. The ProxyCommand path used by `config-ssh` and the IDE plugins still suggests the full hostname. - **`coder show` / `coder create`**: the access column dropped the owner, so `coder show bob/dogfood` or `coder show <id>` suggested `coder ssh dogfood.dev`. It now keeps the owner unless the workspace was given by its bare name. - **`coder config-ssh`**: the example `ssh <workspace>.coder` is ambiguous for multi-agent workspaces. It now names an agent, `ssh <agent>.<workspace>.<owner>.coder`, reading a stopped workspace’s known agents from its latest successful start using the same template version. With `--no-wildcard`, the hint reuses the workspace snapshot and resources used to write the Host entries. - **Dashboard "Connect via SSH"**: rendered `...<owner>.undefined` when the deployment has no hostname suffix. It now falls back to `coder ssh <owner>/<workspace>` for single-agent workspaces, or `coder ssh <owner>/<workspace>.<agent>` otherwise. With a hostname suffix, owned single-agent workspaces show `ssh <workspace>.<suffix>` unless that hostname collides with the deployment’s legacy prefix block. Prefix collisions, shared workspaces and multi-agent workspaces retain the full agent/workspace/owner hostname. The count includes agents across all resources and devcontainers. Commands remain undefined while the SSH config loads, with a spinner instead of a premature fallback. If the initial load fails, it displays the error while keeping the CLI command available. - **Docs**: workspace access docs said `config-ssh` prints `ssh coder.<workspace>`; it prints `ssh <workspace>.coder`. Added the multi-agent hostname, noted it in the Desktop docs, and updated the Gateway host and the networking page to `<workspace>.coder`. ## Before / after ```console $ coder ssh dogfood error: multiple agents found, please specify the agent name, available agents: [coder dev] Try running: $ ssh dev.dogfood.matifali # before: does not resolve $ coder ssh dogfood.dev # after: dev is the agent name ``` ## Compatibility Hostname parsing (`findWorkspaceAndAgentByHostname`, `normalizeWorkspaceInput`) is unchanged, so every hostname that resolves today still does. The VS Code, JetBrains Gateway and Toolbox plugins write their own `Host` entries and run `coder ssh --stdio --ssh-host-prefix <prefix>`, so they don't reach the changed hints. `TestSSH_AgentHostnames` connects with their `<prefix>--<owner>--<workspace>.<agent>` form, and with the `<agent>.<workspace>.<owner>` forms used by `config-ssh` and the dashboard. ## Verification CLI/resource race tests pass, including the complete original `TestSSH` suite and the new agent-hostname round trips. `TestConfigSSH_Example` checks running two-agent and stopped one-/two-agent workspaces whose import defaults differ, with and without `--no-wildcard`. It verifies the hint has a matching generated Host entry and reuses workspace history once per stopped workspace. `TestShow` covers bare names, owner-qualified names and UUIDs; `TestCreate/CreateForOtherUser` checks the owner-qualified preview. Mutation checks confirmed the new assertions fail when the protected behavior is removed. `TestPing_AgentSuggestions` covers bare names, owner-qualified names, UUIDs and JSON-mode errors with a shared fixture. The tests fail without the new hints; an owner-omission control also fails the qualified/UUID cases. The original network-heavy `TestPing` suite remains unchanged and passes its normal race run. Normal and strict new-code Go lint, frontend checks/lint/typechecking, all eleven SSHButton stories, and docs checks pass. Browser checks verified copied SSH/CLI commands and keyboard dismissal; screenshots were visually inspected. The single-agent follow-up adds 25 command-copy cases covering ownership, agents across resources, subagents, and zero/unknown counts. All 53 affected SSHButton, AgentRow, and AgentDevcontainerCard stories pass, with browser validation of both real callers and regression/mutation controls for the command-selection guards. <details> <summary>CI follow-up and validation commands</summary> After #31192 merged, the parent commits were dropped and the remaining eleven commits were rebased onto the merge commit `fb6d287528`. Range-diff and full-tree comparisons confirm no implementation changes. Revalidated the complete SSH/ping/config race suite and strict lint after that rebase. Latest rebase preserves the implementation and carries the docs edits to main’s renamed `docs/workspaces/` paths. The SSHButton documentation links and preview URL use the new routes. Revalidated the full SSH/ping/config CLI race suite, strict lint, 25 frontend tests, 53 stories, and docs/manifest/redirect checks. The local shell’s Oh My Zsh update prompt interrupted the first race run; the unchanged suite passed with `DISABLE_AUTO_UPDATE=true` scoped to the test process. Latest review follow-up: connection commands remain undefined during initial loading, and each instruction is gated on its own command. A cached SSH suffix remains usable after a failed refetch; a story captures that state. Rebased directly onto `main` at `fb6d287528` after #31192 merged. The P2 follow-up preserves native hostnames that collide with legacy prefix blocks, uses workspace-specific history for stopped agents, and retains safe precreated devcontainer names. Earlier stress runs of the unmodified `TestSSH` suite exceeded the 6,144 MiB guard under 35-repeat stress. Its existing scenarios remain unchanged. The three added agent-qualified hostname cases have independent full SSH round-trip coverage in `TestSSH_AgentHostnames`, with a shared fixture. The current top-PR changed-test selector chooses seven tests without the unrelated `TestSSH` scenarios, and the complete selected set passes 35 repetitions at parallelism 16 with the same memory guard. No test cases, repetitions, parallelism or memory checks were removed. ```sh go test -race -tags=testsmallbatch ./cli ./cli/cliui -run '^TestSSH$|^TestSSH_AgentHostnames$|TestPing|TestConfigSSH|TestShow|TestCreate|Test_agentSSHSuggestion|Test_suggestWithOwner|TestWorkspaceResources|Test_noWildcardHostNames|Test_previousStartResources|TestCommandHelp' -count=1 -parallel=4 GOMEMLIMIT=6GiB golangci-lint run --allow-serial-runners --concurrency=4 --new-from-rev=origin/main ./cli/... GOMEMLIMIT=6GiB make lint/go/new-code GO_LINT_CONCURRENCY=4 CODER_TEST_MEMORY_LIMIT_MIB=6144 TS_DEBUG_DISCO=true TS_DEBUG_DERP=true go test -tags=testsmallbatch -p=4 -count=35 -parallel=16 -shuffle=1 -timeout=10m -run '^(TestConfigSSH_Example|TestCreate|TestPing_AgentSuggestions|TestSSH_AgentHostnames|TestShow|Test_agentSSHSuggestion|Test_suggestWithOwner)(/.*)?$' ./cli cd site pnpm check pnpm lint pnpm test src/modules/resources/SSHButton/SSHButton.test.tsx pnpm test:storybook src/modules/resources/SSHButton/SSHButton.stories.tsx src/modules/resources/AgentRow.stories.tsx src/modules/resources/AgentDevcontainerCard.stories.tsx --run ``` </details> Follow-up to #19943. Tracks [CLI-67](https://linear.app/codercom/issue/CLI-67/fix-coder-ssh-suggestions-for-multi-agent-workspaces). Preview: https://coder.com/docs/@fix%2Fssh-multi-agent-hint/workspaces/workspace-access > 🤖 This PR was created with the help of Coder Agents, and has been reviewed by my human. 🧑💻 |
||
|
|
fb6d287528 |
fix: write agent host entries with config-ssh --no-wildcard (#31192)
`coder config-ssh --no-wildcard` writes one `Host` entry per workspace and none per agent. OpenSSH only applies exact `Host` matches, so with `--no-wildcard` (and without Coder Desktop): - `ssh <agent>.<workspace>.<owner>.coder`, the hostname the dashboard's **Connect via SSH** button shows and Coder Connect serves, doesn't resolve. - Agents in multi-agent workspaces can't be reached with plain `ssh`; `ssh <workspace>.coder` hits "multiple agents found". Before wildcard hosts (#14986), `config-ssh` wrote an entry per agent. `--no-wildcard` (#26753) brought back per-workspace entries only. ## Change With `--no-wildcard`, also write an `<agent>.<workspace>.<owner>` entry for each agent, using the same prefix/suffix as workspace entries: ``` Host dogfood.coder # unchanged Host coder.dogfood.matifali.coder # new Host dev.dogfood.matifali.coder # new ``` `coder ssh --stdio` already parses `agent.workspace.owner`, so no ProxyCommand changes are needed. - **Non-breaking**: existing `<workspace>` entries are unchanged; agent entries are added after them. Without `--no-wildcard` the config is unchanged. - **Workspaces without agents on their latest build** (stopped, or a start that is pending or failed): known agents come from that workspace’s most recent successful start using the same template version, not template-import defaults. Lookups are cached per workspace and bounded to eight concurrent requests. Missing or incompatible history leaves only the workspace entry; lookup failures also produce a warning. - **Devcontainers**: while a workspace runs, its sub-agents get entries too. - **Validation**: workspace and owner names retain `codersdk.NameValid` checks. Agent components permit safe ASCII letters, digits, underscores and hyphens, preserving Terraform-precreated names such as `dev_box` while rejecting SSH syntax, leading options and doubled-hyphen delimiters. Workspace entries are written as before, including legacy names (related: SEC-378). The flag description, generated CLI reference/help, and workspace access and Gateway tips describe known agents. The guide explains when stopped workspaces have only a workspace entry and how to populate their agent entries. ## Verification `TestConfigSSH_NoWildcard` verifies two stopped workspaces sharing a template version but having different actual agents, import defaults that differ from both, a precreated `dev_box` agent, and injection rejection. History tests cover pagination, failed/newer builds, version changes and request failures. Regression controls failed before the fixes and passed afterward. Race tests, strict Go lint and docs checks pass on the refreshed stack. <details> <summary>Validation commands</summary> Latest rebase preserves the implementation and carries the docs edits to main’s renamed `docs/workspaces/` paths. The SSHButton documentation links and preview URL use the new routes. Revalidated the full SSH/ping/config CLI race suite, strict lint, 25 frontend tests, 53 stories, and docs/manifest/redirect checks. The local shell’s Oh My Zsh update prompt interrupted the first race run; the unchanged suite passed with `DISABLE_AUTO_UPDATE=true` scoped to the test process. Review decision: use workspace-specific build history because template imports cannot represent chosen workspace parameters. Preserve the last-start template-version boundary rather than inventing agents when no compatible history exists. Both stack branches are rebased onto `main` at `63b5c4d64a`. ```sh go test -race -tags=testsmallbatch ./cli -run 'TestConfigSSH|Test_noWildcardHostNames|Test_previousStartResources|TestCommandHelp' -count=1 -parallel=4 GOMEMLIMIT=6GiB make lint/go/new-code GO_LINT_CONCURRENCY=4 ``` Docs validation also passed emdash, HTML-table and manifest checks, targeted markdownlint, table formatting and Vale. </details> Fixes [CLI-68](https://linear.app/codercom/issue/CLI-68/config-ssh-no-wildcard-does-not-write-host-entries-for-workspace). #31188 is stacked on this PR. Preview: https://coder.com/docs/@fix%2Fconfig-ssh-no-wildcard-agents/workspaces/workspace-access > 🤖 This PR was created with the help of Coder Agents, and has been reviewed by my human. 🧑💻 |
||
|
|
a7f3e3b685 |
docs: promote the AI sections and Templates to the top level of the sidebar (#31645)
> [!NOTE] > Generated by Coder Agents. The branch and this description were written by an AI agent and need human review. ## Summary First of three stacked PRs for the docs IA overhaul (Proposal 1, section 3). This PR dissolves `docs/ai-coder/` into four top-level sidebar sections, in this order, where "Run AI coding agents in Coder" used to be: **Coder Agents**, **AI Governance** (with Agent Firewall and AI Gateway nested under it), **Agent Relay**, and **MCP server**. - Files move with `git mv`, so `git log --follow` keeps their history. The move includes every file in the moved folders, including pages that are not in the sidebar, such as `agent-firewall/example-policy.md`, and pages added to `main` after the first version of this PR, such as `agents/projects.md` (#30684) and `agents/acp-subagents.md` (#31430). - `docs/ai-coder/index.md`, `best-practices.md`, and `ide-agents.md` are deleted. Each has a redirect (see below). - `docs/manifest/` mirrors the new folders: `coder-agents.yml` (+ `coder-agents/`), `ai-governance.yml` (+ `ai-governance/`), `agent-relay.yml`, and `mcp-server.yml`. `ai-coder.yml` is deleted. The Projects and ACP subagents entries from `main` move with Coder Agents. - Every relative link and image path is fixed, both in the moved pages (their base directory changed) and in pages that link to them. This was done in one scripted pass from a clean `main` checkout. Every link was then checked to resolve on disk. - Commit 2, `chore: point in-product docs links at the new docs paths`, updates docs URLs outside `docs/`: `site/` `docs()` links, Go error strings and comments, `README.md`, `server.json`, templatebuilder modules, and the doc-check skill. Commit 4 reverts the unversioned `https://coder.com/docs/...` URLs among them (see below), so after this PR only these differ from `main` outside `docs/`: the `site/` `docs()` links, the versioned `cli/cliui` troubleshooting links, and repo file paths in comments and the doc-check skill's examples (`docs/coder-agents/...`, `docs/templates/...`). You can drop commit 2; the redirects cover the old URLs. - **#31646 (Templates) was squash-merged into this branch** as `98377a3a3b`. This PR now also carries the Templates move (`docs/admin/templates/**` → `docs/templates/**`, plus `template-from-scratch.md` and `testing-templates.md`) and its chore changes. Refer to #31646 for that part's move map, redirects, and review. - Commit 4, `fix: keep docs links healthy before the release`, keeps links working on the live site until a release that includes this stack becomes the default docs version: - Hand-written pages that linked to moved pages with absolute `https://coder.com/docs/...` URLs now use relative links, anchors kept. The new paths 404 on the live site today, but relative links resolve for every version and are checked locally. - Hardcoded, unversioned `https://coder.com/docs/<new path>` URLs outside `docs/` that the chore commits introduced (Go strings including the prebuilds metric help, CLI help, the `agentFallbackTroubleshootingURL` default, `README.md`, `server.json`, examples, templatebuilder files, and one `site/` constant) go back to their current paths. Then `make gen` regenerated the generated table in `docs/admin/integrations/prometheus.md`, `scripts/metricsdocgen/generated_metrics`, the CLI golden files, and `docs/reference/cli/templates/{create,edit}.md`. See "Post-release follow-up". - The `site/` `docs()` changes and the `cli/cliui` links stay, because those URLs are versioned (`/docs/@vX.Y.Z/...`) and resolve once the release ships. - Commit 5, `docs: prefix relative links in the moved pages with ./`, adds `./` to 13 relative links that the move script wrote without it, in `docs/mcp-server.md` and three Templates pages. They resolved, but every other relative link in the docs starts with `./` or `../`. - Commit 6, `docs: keep the coding agent module guidance in the templates docs`, adds an **AI agent modules** section to `docs/templates/extending-templates/modules.md`. Deleting `docs/ai-coder/index.md` removed the only instructions for adding a terminal coding agent to a template with a registry module. The example (`registry.coder.com/coder/claude-code/coder`, `version = "~> 5.2"`) passes `terraform validate`, and the Template Builder labels it cites match `site/src/pages/TemplateBuilder/ModuleSelectStep.tsx`. Stack: **this PR** (with #31646 squash-merged in) → `docs/ia-tutorials-nav` (#31647, Tutorials + nav renames) → `docs/ia-workspaces-folder` (#31650, folder rename). Refs: Linear DOCS-1154, DOCS-1179, and DOCS-1479 for the coder.com and router redirect fix. ## Move map | Old | New | | --- | --- | | `docs/ai-coder/agents/**` (25 files) | `docs/coder-agents/**` | | `docs/ai-coder/ai-governance.md` | `docs/ai-governance/index.md` | | `docs/ai-coder/agent-firewall/**` (9 files) | `docs/ai-governance/agent-firewall/**` | | `docs/ai-coder/ai-gateway/**` (26 files) | `docs/ai-governance/ai-gateway/**` | | `docs/ai-coder/agent-relay/**` (3 files) | `docs/agent-relay/**` | | `docs/ai-coder/mcp-server.md` | `docs/mcp-server.md` | | `docs/ai-coder/index.md` | deleted | | `docs/ai-coder/best-practices.md` | deleted | | `docs/ai-coder/ide-agents.md` | deleted | ## Redirects added Appended to `docs/redirects.json`, using the absolute `/docs/...` format that `main` validates today. Wildcards cover every page under each moved folder, including pages that are not in the sidebar and the pages added to `main` since the first version of this PR. | Source | Destination | | --- | --- | | `/docs/ai-coder` | `/docs/coder-agents` (deleted hub, **please confirm**) | | `/docs/ai-coder/best-practices` | `/docs/coder-agents` (deleted, **please confirm**) | | `/docs/ai-coder/ide-agents` | `/docs/user-guides/workspace-access` (deleted, **please confirm**) | | `/docs/ai-coder/ai-governance` | `/docs/ai-governance` | | `/docs/ai-coder/mcp-server` | `/docs/mcp-server` | | `/docs/ai-coder/agents/:path*` | `/docs/coder-agents/:path*` | | `/docs/ai-coder/agent-firewall/:path*` | `/docs/ai-governance/agent-firewall/:path*` | | `/docs/ai-coder/ai-gateway/:path*` | `/docs/ai-governance/ai-gateway/:path*` | | `/docs/ai-coder/agent-relay/:path*` | `/docs/agent-relay/:path*` | None of the 3 existing rules in `docs/redirects.json` points into `ai-coder/`, so no destinations needed updating. **coder.com and router static redirects.** coder.com applies its own `redirects.json` and the rules it generates from this file before it hands `/docs` to the docs-engine router, which applies its own static `redirects.json` before the page. Three older static rules in both repos send `/docs/templates`, `/docs/templates/open-in-coder`, and `/docs/templates/troubleshooting` to `/docs/admin/templates/...`, and the `/docs/admin/templates/:path*` rule here sends them back, so each loops once a release with this layout is the docs mainline. A static `/docs/workspaces` rule would also hide the new `docs/workspaces/index.md` page from #31650. coder/coder.com#1201 and coder/docs-engine#304 (draft, DOCS-1479) remove those rules; they must merge when that release becomes the mainline, not before, because the old-layout mainline still needs them. A chain simulation of every page and static source on each branch of this stack finds no other loops or hidden pages. The `/docs/ai-coder/...` and other legacy rules there still work; some now take two redirects. ## Deviations from the proposal - **Glossary "IDE agent" entry.** The proposal says to remove this link and leave plain text. I pointed it at Access your workspace (`docs/user-guides/workspace-access/index.md`) instead, the same page the `ide-agents` redirect uses, because "Refer to IDE agents." with no link reads as a dead end. The "Coding agent" entry now links to Coder Agents, as the proposal says. - **Top-level icons.** The new sections need icons. I chose `wand.svg` (Coder Agents, the old ai-coder icon), `ai_intelligence.svg` (AI Governance), `link.svg` (Agent Relay), and `plug.svg` (MCP server). - **Coding agent module guidance.** Kept on the Reuse template code page (commit 6) instead of deleted with `docs/ai-coder/index.md`. The best-practices and IDE-agent pages are deleted as proposed. - **Order relative to Administration.** In this PR the four sections sit where `ai-coder` was, after Administration. PR C moves Administration after MCP server to reach the final order. - **`docs/mcp-server.md` repo link.** A relative link to `codersdk/toolsdk/toolsdk.go`, outside `docs/`, was re-based for the new depth. - **Left unchanged on purpose:** - Database migrations and the notification `.golden` files rendered from them still contain `coder.com/docs/ai-coder/...` URLs. Existing migrations can't be edited, so those links rely on the redirects. - `aibridge/client/client.go` links to a commit-pinned GitHub permalink, which still resolves. - Test fixtures in `scripts/docsredirectscheck` and `.github/workflows/test-docs-preview-mapper.sh` use `ai-coder` as sample data. - `site/src/pages/AgentsPage/components/ChatElements/tools/Tool.stories.tsx` uses `https://coder.com/docs/ai-coder/ai-gateway` as a sample web search result. Changing it would only change a visual snapshot. ## Open questions for Nick 1. Do you agree with the three redirect targets for the deleted pages above? 2. Should the "IDE agent" glossary entry link to Access your workspace (current) or be plain text (proposal)? 3. Are the icons for the new top-level sections OK? 4. Open PRs that touch the moved files, checked with `git merge-tree` against this branch. I didn't change them. - #31169 merges cleanly: Git's rename detection carries its edit to `docs/ai-governance/ai-gateway/clients/claude-code.md`, and its new relative link still resolves at the new path. - #30262 now targets `tk/ai-gateway-responses-ws-endpoint` and conflicts with `main` in 21 files. Against this branch it conflicts in the same 21 files, with `codex.md` at its new path, so this PR doesn't add new conflicts. Its new relative links still resolve after the move. - #30805 conflicts in `docs/redirects.json`. It already conflicts with `main` there, because `main` added the `/docs/about/screenshots` and `/docs/install/cli` rules. ## Release No backport to `release/2.39` for now; Nick may apply it by hand later. A cherry-pick of this branch onto `release/2.39` conflicts in 25 files, and #31647 and #31650 would need the same treatment to keep the stack together. coder/coder.com#1201 and coder/docs-engine#304 merge when the first release line that carries this layout becomes the docs mainline (2.38 today). ## Known limitations - **CLI newer than its server.** The `cli/cliui` troubleshooting links append `/templates/troubleshooting#...` to the server's versioned docs URL. A CLI from this release against an older server prints `/docs/@v2.38.x/templates/troubleshooting#...`. The router's static `/docs/templates/:page(open-in-coder|troubleshooting)` rule redirects that to the old page today, but coder/docs-engine#304 removes that rule to fix the loop, so after the cutover that case gets the version's not-found page. ## Post-release follow-up After a release that includes this stack becomes the default docs version on coder.com, point these hardcoded URLs at the new paths. They work today and redirect after the release, so nothing breaks in the meantime. Anchors are unchanged. Rerun `make gen` afterward to update `docs/admin/integrations/prometheus.md`, `scripts/metricsdocgen/generated_metrics`, the CLI golden files, and `docs/reference/cli/templates/{create,edit}.md`. | Current (old) URL | Post-release URL | Files | | --- | --- | --- | | `https://coder.com/docs/ai-coder/agents` | `https://coder.com/docs/coder-agents` | `.claude/skills/doc-check/output.md`, `README.md` | | `https://coder.com/docs/ai-coder/agents/architecture` | `https://coder.com/docs/coder-agents/architecture` | `coderd/x/chatd/chattool/execute_test.go`, `codersdk/toolsdk/workspacetools/execute.go` | | `https://coder.com/docs/ai-coder/ai-gateway` | `https://coder.com/docs/ai-governance/ai-gateway` | `README.md`, `coderd/templatebuilder/modules/claude-code/module.json`, `coderd/templatebuilder/modules/codex/module.json` | | `https://coder.com/docs/ai-coder/mcp-server` | `https://coder.com/docs/mcp-server` | `server.json` | | `https://coder.com/docs/admin/templates` | `https://coder.com/docs/templates` | `README.md` | | `https://coder.com/docs/admin/templates/extending-templates/docker-in-workspaces` | `https://coder.com/docs/templates/extending-templates/docker-in-workspaces` | `examples/templates/docker-devcontainer/main.tf` | | `https://coder.com/docs/admin/templates/extending-templates/parameters` | `https://coder.com/docs/templates/extending-templates/parameters` | `examples/parameters-dynamic-options/README.md`, `examples/parameters/README.md`, `examples/parameters/main.tf`, `examples/templates/kubernetes-envbox/README.md`, `examples/workspace-tags/README.md` | | `https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces` | `https://coder.com/docs/templates/extending-templates/prebuilt-workspaces` | `coderd/prebuilds/api.go`, `enterprise/coderd/prebuilds/metricscollector.go` (metric help text) | | `https://coder.com/docs/admin/templates/extending-templates/workspace-tags` | `https://coder.com/docs/templates/extending-templates/workspace-tags` | `examples/workspace-tags/README.md` | | `https://coder.com/docs/admin/templates/managing-templates` | `https://coder.com/docs/templates/managing-templates` | `cli/templatecreate.go`, `cli/templateedit.go` (CLI help) | | `https://coder.com/docs/admin/templates/managing-templates/image-management` | `https://coder.com/docs/templates/managing-templates/image-management` | `coderd/templatebuilder/bases/docker/README.md`, `coderd/templatebuilder/bases/kubernetes/README.md` | | `https://coder.com/docs/admin/templates/troubleshooting` | `https://coder.com/docs/templates/troubleshooting` | `agent/agentscripts/agentscripts.go`, `coderd/render/escape_internal_test.go`, `codersdk/deployment.go` (`agentFallbackTroubleshootingURL` default) | | `https://coder.com/docs/tutorials/template-from-scratch` | `https://coder.com/docs/templates/template-from-scratch` | `site/src/pages/TemplateBuilder/TemplateAlternatives.tsx` | ## Validation run - `make gen/docs-manifest`: clean diff afterward. - `make lint/docs-manifest`, `lint/docs-redirects` (`go run ./scripts/docsredirectscheck -base origin/main`: 15 rules OK, no removed-route warning), `lint/docs-html`, `lint/emdash`: pass. - `pnpm check-docs` (markdownlint + table formatter): pass. - Vale (`vale --no-exit docs/`): the same 12 warnings and 1 error as `main`, all pre-existing. Suggestions drop from 646 to 645; the one removed was in the deleted `ide-agents.md`. - Local relative-link check over `docs/**/*.md`: 0 unresolved links or images (also 0 on `main`). - Pre-commit hook: `make pre-commit-light` on the docs commit, and the full `make pre-commit` (gen, fmt, lint/go, lint/ts, build, and others) on the chore commit. Both passed. - Targeted tests: - Go: `go test ./coderd/x/chatd/chattool/... ./codersdk/toolsdk/... ./coderd/templatebuilder/...`. - Site: Vitest for the touched directories (107 files, 1879 tests), and the story tests for `CoderAgentsProductCard`, `GroupSettingsPageView`, `GatewayKeysPageView`, and `ModelForm` (4 files, 63 tests). - Every `docs()` path and anchor in the `site/` and Go diff resolves to a page and heading in this branch. - Frontend deep review (all 8 roles) on the `site/` diff of PRs A and B: no blocking or should-fix findings. Nits on existing code that this PR only touched, not changed here: a single-use `docsLink` constant in `ChatAccessDeniedAlert.tsx`, and assertion-only `play` functions in the `GatewayKeysPageView`, `ModelForm`, `CoderAgentsProductCard`, and `GroupSettingsPageView` stories. - Page counts: `docs/**/*.md` (excluding `.style`) 490 → 487; `manifest.json` routes 495 → 492. With #31646 squash-merged in, the counts don't change, because the Templates move only moves files. - **Link health (commit 4):** - linkspector 0.5.6 with `.github/.linkspector.yml` over all of `docs/`, like the weekly docs job (`umbrelladocs/action-linkspector`, `reporter: local`, `filter_mode: nofilter`). I ran it locally with Chrome in `--no-sandbox` mode. - `origin/main`: 0 errors. Before the fix (`17e54ad555`): 6 errors, all `https://coder.com/docs/<new path>` 404s (`shared-workspaces.md:19`, `esr-2.24-2.29-upgrade.md:80-82`, `tasks-to-chats-migration.md:73`, `prometheus.md:298`). After the fix (`def074caab`): 0 errors. A first run after the fix also flagged a Red Hat URL in `install/server/openshift.md`. That URL is unchanged from `main`, and it passed on a rerun, so the failure was transient. - After the fix: `make gen/docs-manifest` (clean), `lint/docs-manifest`, `lint/docs-redirects` (15 rules OK against `origin/main`), `lint/docs-html`, `lint/emdash`, `pnpm check-docs`, and the relative-link check (0 unresolved in 3416 links) pass. The full `make pre-commit`, including `make gen`, passed on the commit. - Tests after the fix: - Go: `go test ./cli -run 'TestCommandHelp|TestServerYAMLConfig'`, `./enterprise/cli -run TestEnterpriseCommandHelp`, `./coderd/render`, `./agent/agentscripts`, `./coderd/prebuilds`, `./enterprise/coderd/prebuilds`, `./coderd/x/chatd/chattool/...`, `./codersdk/toolsdk/...`, `./coderd/templatebuilder/...`. - Site: Vitest for `src/pages/TemplateBuilder` (7 files, 67 tests). - **After the rebase onto `ccf5ec74ae`** (commits 5 and 6 included): `make gen/docs-manifest` (clean), `lint/docs-manifest`, `lint/docs-redirects` (15 rules OK), `lint/docs-html`, `lint/emdash`, `pnpm check-docs`, and a relative-link and anchor check over the changed pages pass. The only unresolved anchor, `docs/ai-governance/ai-gateway/cost-controls.md` → `enterprise.md#list-organization-ai-spend-by-user`, is also broken on `main`. The pre-commit hook (`make pre-commit-light`, because both new commits touch only `docs/`) passed on commits 5 and 6. The rebased code commits rely on CI for Go and TypeScript checks. - **Redirect chains:** a Node simulation of coder.com's static rules, its generated rules from this branch's `docs/redirects.json`, the router's static rules, the page, then this branch's rules on a miss, over every page and exact static source, reports the 3 loops above and nothing else new; with coder/coder.com#1201 and coder/docs-engine#304 applied, 0. - **Skipped:** the docs-engine sync check, which was not available in this environment. <details> <summary>Implementation notes</summary> - Rebuilt on `main` at `ccf5ec74ae` (2026-11-03) to clear conflicts with `main`, after an earlier rebase the same day onto `1a963c628d`. The previous rebuild was on `9839406ff7` (2026-11-02), and the first version on `9b8d880d63` (2026-10-23). - Rebase conflicts with #31603, which added `target="_blank" rel="noreferrer"` to docs links: 4 `site/` files in the chore commit and 5 in the Templates commit. Each kept `main`'s version of the link with only the docs path changed. Vitest for the 7 affected page directories (233 tests) and the story tests for the 8 changed or affected stories (102 tests) pass, and every `docs()` path in `site/src` resolves except the same 13 that are unresolved on `main`. - Rebase conflict: `docs/manifest/coder-agents.yml`. `main` added `docs/ai-coder/agents/bring-your-own-mcp-servers.md`; it moves to `docs/coder-agents/` with its sidebar entry, and its `../../user-guides/` links become `../user-guides/`. - Folded into the Templates commit: a link that `main` added to `docs/user-guides/workspace-dotfiles.md` (#31606) now points at `../templates/extending-templates/environment-variables.md`. - `git range-diff` against `def074caab`, the head before both rebases, shows only those changes. - The move script reads every page from the clean `main` checkout and resolves each relative link (inline, reference-style, and HTML `src`/`href`) against the page's **old** directory. It maps the target through the move map and recomputes the link from the page's **new** directory. It runs once and refuses to run on a dirty `docs/` tree, so it can't apply the path math twice. It also rewrites absolute `coder.com/docs/...` and `github.com/coder/coder/(blob|edit|tree)/main/docs/...` URLs, and skips fenced code blocks and inline code. - Before reusing the script, I ran it on the old base and diffed the result against the old commit. The only differences were the two hand-edited glossary entries and table padding from the formatter, so the rebuild applies the same changes to the current `main`. - Afterward, `grep -r ai-coder docs/` finds matches only in `docs/redirects.json`. - Changes from the earlier version of this branch: 2 more pages move (`agents/projects.md`, `agents/acp-subagents.md`) and their sidebar entries move with them. The chore commit also updates `SessionSummaryTable.tsx` (new on `main`) and the doc-check skill's `output.md` (its examples moved there from `SKILL.md`). The `AICostControl.tsx` anchor question is gone, because `main` fixed it. </details> --------- Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com> Co-authored-by: Nick Vigilante <nick.vigilante@coder.com> |
||
|
|
c9ea1914a6 |
feat(cli): add phase 1 coder exp api command with httpie-style request items (#31427)
Adds a hidden `coder exp api` command that covers **Phase 1 only** of the "Simplified API Access via CLI" RFC, using httpie-style request items as RFC reviewers asked. It's a smaller alternative to #31406, which also ships Phase 3 (`--jq`, `--paginate`, `--verbose`). ``` coder exp api [METHOD] <path> [REQUEST_ITEM ...] ``` | Item | Meaning | |---|---| | `Name:value` | Request header | | `Name:` | Remove a request header, such as the default `Content-Type` | | `name==value` | Query parameter, appended to any query already in the path | | `name=value` | JSON string field | | `name:=json` | Raw JSON field (number, bool, null, array, object) | | `name=@file` / `name:=@file` | String or JSON field read from a file, `-` for stdin | - The path is relative to `/api/v2/`. A path that starts with `api/` or `/api/` is used as given, for example `/api/experimental/chats`. - METHOD is optional. The first argument counts as a method only when it matches a known HTTP method, so paths like `users` still work. The default is GET, or POST when there are data items or `--input`. - `--input <file|->` sends a raw body. It can't be combined with data items, the combination is rejected before any file or stdin is read, and stdin is never read implicitly. - There's no `-H` flag. Per-request headers are `Name:value` items, and the existing global `--header` / `--header-command` flags still apply because the command uses `r.InitClient`. Their values are sent in addition to header items. - Auth, TLS and the deployment URL all come from the existing CLI session (`CODER_URL`, `CODER_SESSION_TOKEN`, or `coder login` state). There's no new auth logic. - The command refuses absolute URLs and `.` or `..` path segments, including percent-encoded ones, so the token only goes to API routes on the configured deployment. It warns (but doesn't block) when that URL is plain HTTP to a host that isn't loopback. - httpie forms that would mean something different here are rejected rather than sent literally: `==@` and `:@` file separators, nested JSON field names such as `a[b]=c`, and a `Host` item. - It prints the raw response body. On 4xx/5xx it prints the body and exits non-zero with the Coder error, plus an API reference hint when the route doesn't exist. - No new dependencies. `go.mod` and `go.sum` are unchanged. **Left out on purpose:** `--jq`, `--paginate`, `-i/--include`, request/response logging, and gh-style `-X`/`-f`/`-F`/`-H` flags. **Decisions still open in the RFC:** - Whether httpie syntax is final. - Whether `--paginate`/`--jq` belong in Phase 1 at all. The RFC lists them under both the initial requirements and Phase 3. - An explicit `GET` with data items sends a JSON body, which is what httpie does. The new code is `cli/exp_api.go`, plus a one-line registration in `cli/root.go`. Tests are in `cli/exp_api_internal_test.go` (parsing) and `cli/exp_api_test.go` (integration). Tests run in the workspace: - `go test ./cli/ -run 'TestExpAPI|TestAPIURLIsInsecure|TestAPIRequestPath|TestSplitAPI|TestParseAPIRequestItems'`, also with `-race` plus `TestCommandHelp` - `go vet ./cli/` - `golangci-lint run ./cli/...` - `make lint/go/new-code`, and `make lint/go` through the pre-commit hook > [!NOTE] > This PR was generated by Coder Agents on behalf of @nickvigilante. --------- Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com> Co-authored-by: Nick Vigilante <nick.vigilante@coder.com> |
||
|
|
a9643ffcd3 |
feat: add rootless Podman starter template and EKS Auto Mode guidance (#30804)
## Summary
- EKS Auto Mode supports kernel sysctls via the NodeClass
`advancedCompute` field since 2026-10-01 ([AWS
announcement](https://aws.amazon.com/about-aws/whats-new/2026/10/eks-auto-mode-advanced-compute-config/)),
so rootless Podman no longer requires a separate managed node group;
document the custom NodeClass recipe and the `idsPerPod` requirement for
`hostUsers: false` pods
- Document native overlay storage (real-filesystem graph root + clearing
the image's `mount_program` pin), which removes the `/dev/fuse` device
plugin dependency on kernel 5.13+
- Add a "Nested container engines" section: one level of nesting is
supported; the dev container `docker-in-docker` feature is not, with
`docker-outside-of-docker` as the documented alternative
- Add the `kubernetes-podman-rootless` starter template (`coder
templates init --id kubernetes-podman-rootless`):
- persistent `/home/coder` volume (`fs_group_change_policy =
"OnRootMismatch"`), so repos, images and build cache survive restarts
- startup script fails with the Podman log when the API socket doesn't
start
- `kubernetes_pod_v1`, pinned to amd64 (the image is amd64-only)
Refs DOCS-1277. Related follow-up: DOG-74.
## Testing
- 2026-10-14, EKS Auto Mode v1.37 sandbox: rootless Podman on pure Auto
Mode nodes with native overlay, including builds with cache mounts,
Testcontainers-style Postgres, and the Docker-compatible API socket
- 2026-11-02, same cluster, starter template at
|
||
|
|
f0ddf43c42 |
feat: group Premium deployment options in their own section when unlicensed (#31460)
On deployments without a license, the Network settings page now moves options that need a license into their own "Premium settings" section. The section has a Premium badge in its title and the description "These settings require a Premium license to take effect. Learn more about Premium". The link goes to the in-product Premium page (`/deployment/premium`) and only shows when the user can view licenses, matching the paywall's `canViewPremium` check. With a license, every option stays in one table in its defined order, the same as before. Options annotated `enterprise` in `codersdk/deployment.go` count as needing a license. Proxy Health Check Interval is now annotated `enterprise` too, because only `enterprise/cli/server.go` reads it. As a side effect, `coder server --help` lists it under the Enterprise options group. The golden files are regenerated. `OptionsTable` gains an optional `aria-label`, so the two tables on the Network page have names. [Relates to DES-22148](https://linear.app/codercom/issue/DES-22148/add-premium-upsell-pills-to-deployment-level-settings). <img width="6400" height="3270" alt="PR 31460 Before After Network" src="https://github.com/user-attachments/assets/7ab2a2ec-a54a-42dc-9556-ae8f1964d4a3" /> <details> <summary>Decision log</summary> - **Block Direct Connections, the example in DES-22148, is not Premium.** Free code (`cli/server.go`, `coderd/workspaceagents.go`) reads it with no license check. The "Disabled" in the screenshot is just its default value (`false`). - **The existing `enterprise` annotation is the source of truth**, so the frontend doesn't keep its own list of Premium options. - **Group by license, with one label per section (designer's call).** This replaces earlier per-row badges and helper lines, which repeated the same message on every row and made the default `md` badge look oversized next to 14px titles. It follows Coder Kit's badge guidance (Premium is a category label) and the existing h2 `SettingsHeaderTitle` with a badge on the Security page's Browser-Only Connections section. The accepted tradeoff: unlicensed, DERP Server Relay URL and Cluster Host sit apart from the related networking options. - **With a license, the section disappears** and the options return to their defined order, so licensed admins see no change. - **"To take effect", not "to change".** This page is read-only, and the server accepts these values without a license. The features behind them are gated: Browser Only stays off and shows a license warning (`enterprise/coderd/license/license.go:900`), workspace proxies need `workspace_proxy` (`enterprise/coderd/coderd.go:413`), and multiple replicas need `high_availability` (`license.go:693`). The wording follows the docs' "requires a Premium license" pattern. - **"Learn more about Premium" is an internal link** to `PREMIUM_PAGE_PATH`, without the external-link icon (designer's call). It uses `Link asChild showExternalIcon={false}` around a router link, as elsewhere in the app, and is hidden without `permissions.viewAllLicenses`, like `PaywallSmall`. - **The check is any license, not per feature.** Only the Network page renders `enterprise`-annotated options: DERP Server Relay URL, Browser Only, Cluster Host and Proxy Health Check Interval. - **Not annotated in this PR**, because no deployment settings page shows them: Default Quiet Hours Schedule, Allow Custom Quiet Hours, Provisioner Daemon PSK and the AI Gateway Proxy options. AI Budget Policy/Period render only when the AI Governance page is already entitled. **Follow-ups** - Add per-feature checks by putting the feature name in the annotation and checking `entitlements.features[name].enabled`. - Give the other `OptionsTable` callers an `aria-label`. </details> --- Generated by Coder Agents on behalf of @designertyler. |
||
|
|
1acacc9c30 | feat: graduate MCP tool search from experiments (#31327) | ||
|
|
5b1eac6d1d |
feat(cli): narrow ResolveWorkspace related data in favorite, autoupdate, rename (#29914)
Stacked on #29913. Now that `ResolveWorkspace` forwards `WorkspaceOptions`, narrows the related data loaded by three CLI commands that only use the workspace's own `ID` and `Name`. Each passes an empty `wsrelated.Config{}` so the server skips loading the template and latest build. - `cli/favorite.go`: `favorite` and `unfavorite`. - `cli/autoupdate.go`: `autoupdate`. - `cli/rename.go`: `rename`. These were selected as the safest first candidates: they read only core workspace fields, so no output or behavior changes, only the amount of data fetched. _This PR was created by Coder Agents on behalf of @spikecurtis._ |
||
|
|
4fd3d7ef59 | fix: prompt instead of defaulting when a previous parameter option is removed (#30797) | ||
|
|
4b6f2c1a59 | feat: add start and message jitter to chat scaletest (#30264) | ||
|
|
bc65edc737 |
fix(cli): scope keyring credentials to the deployment origin (#29764)
Keyring entries were keyed by host alone, so http://host and https://host shared one entry: the https token was sent in plaintext to the http URL, and `coder logout` over http removed the https session. Credentials are now keyed by origin: - https: bare host, with :443 dropped. Older CLIs write the same key, so existing https sessions keep working. - http: http://host, with :80 dropped. - Any other scheme is rejected. coder_url stores the normalized origin. A token stored for the other scheme reads as os.ErrNotExist, so the CLI treats you as not logged in. Users who logged in to an http deployment with an older CLI, or with an explicit https://host:443, must log in again. Fixes #29290 Co-authored-by: Ehab Younes <ehab@alyounes.com> |
||
|
|
d469763bc0 |
feat: add JSON output to coder ping (#30148)
`coder ping` printed per-pong lines and a summary table with no structured output, so monitoring scripts had to parse text. It now accepts `-o table|json` (default `table`, today's output) through the shared CLI output formatter. JSON is a single document at the end with each attempt (sequence, time, latency, direct or DERP region, error) and the summary. **Behavior change:** Additive. Default output is unchanged. `-o json` requires `--num` and fails early without it, because pings otherwise continue until interrupted. In JSON mode, the per-pong and diagnostic lines that normally go to stdout go to stderr, so stdout contains only the JSON document. <details> <summary>Decisions</summary> - One document at the end rather than streaming, because it's simpler to parse. - Require `--num` with `-o json`. In the default continuous mode, a single document would leave stdout empty until Ctrl+C and hold every pong in memory. Newline-delimited JSON per pong is a possible follow-up if continuous machine-readable output is needed. - Durations are reported as `*_ms` floats because `time.Duration` doesn't marshal to a portable unit. - Output goes through the shared `cliui.NewOutputFormatter` (table and JSON), matching `coder speedtest`. This also adds the standard `-c, --column` flag for the summary table. </details> <details> <summary>CI note</summary> `Storybook` failed once on 61b39ef70b inside Pixel (`build finished with status failed`). This PR changes no frontend files; the job passed on rerun. `test-go-pg (ubuntu-latest)` failed on 8e6276921e in [run 38948569950](https://github.com/coder/coder/actions/runs/38948569950/job/117134059011) on `TestChatTurnStopsAtStepLimit/Default` in `coderd/x/chatd`. This PR doesn't touch `coderd/x/chatd`, so the failed job was re-run. </details> Closes [CLI-32](https://linear.app/codercom/issue/CLI-32) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
58d19d78c5 |
feat: enable Coder.Please Vale rule (#30789)
Depends on #30782. Adds `Coder.Please`, a Vale rule that enforces [Leave out "please"](https://github.com/coder/coder/blob/main/docs/.style/style-guide/voice-and-tone.md#leave-out-please). - Flags `\bplease\b`, ignoring case. - Severity: `warning`. Scope: `docs/**` except `docs/.style/style-guide/**`. - Baseline: 31 findings in 24 pages (23 hand-written plus the generated configuration reference), 0 after cleanup. - Code spans and fenced code blocks are skipped by Vale, so quoted product text such as `Please try again later` stays untouched, as the guide asks. ## Commits 1. `docs: leave "please" out of instructions`: rewrites each use as a direct imperative and keeps the meaning. It also fixes the one generated page that had a finding. `docs/admin/setup/configuration-reference.md` comes from the telemetry group description in `codersdk/deployment.go`, so the cleanup edits that source and the golden files (`cli/testdata/coder_server_--help.golden`, `cli/testdata/server-config.yaml.golden`, `enterprise/cli/testdata/coder_server_--help.golden`) regenerated with `go test -update`. 2. `feat(docs/.style): enable Coder.Please Vale rule`: adds the rule, flips the footer to enforced, adds the checks-table row, and updates the coverage counts. No `.vale.ini` change is needed, and no generated page is excluded. Linear: DOCS-1281 <details> <summary>Decision log</summary> - An `existence` rule with one `\bplease\b` token. Word boundaries keep `pleasant` and `displeasing` out. - `warning` rather than `error`, because a quoted product message can legitimately contain the word outside code font. - Generated pages: fixed in Go source instead of excluded, because only one string was affected and the text reads better without it. - URL query strings such as `body=please+enter+your+request+here` aren't flagged, because Vale skips link destinations. - The README sentence about rows, checks, and sections moves from 7, 10, and 9 to 8, 11, and 10 for the new row. Test cases (fixtures under `/tmp/please-test/`, not committed), run with LF and CRLF line endings, 6 findings each: - Flagged: sentence-initial `Please`, trailing `, please.`, `PLEASE`, a blockquote, a list item, a heading. - Not flagged: a code span containing `Please try again later`, a fenced code block containing `Please install curl`, `pleasant`, `displeasing`. Checks: - `vale --output=line docs/` reports 0 `Coder.Please` findings. - `go run ./scripts/styleclaims` passes. - The pre-commit hooks pass on both commits (gen, `lint/go`, `lint/ts`, markdown, emdash, style-claims, typos). - `go test ./cli -run 'Test(CommandHelp|ServerYAML)'` and `go test ./enterprise/cli -run TestEnterpriseCommandHelp` pass with the updated golden files. </details> *Generated by [Coder Agents](https://coder.com/docs/ai-coder/agents) on behalf of @nickvigilante.* |
||
|
|
281b838856 |
feat: retry failed MCP servers on context resync (#30489)
Stacked on #30484. The agent only reconnects workspace MCP servers when `.mcp.json` changes, so a server that is down when the agent first connects (for example, a dev server like Storybook started after the workspace is up) stays unavailable until the config file is touched. `agentcontext.Manager.Resync` now calls a new `agentmcp.Manager.Reconnect` before resolving. `Reconnect` re-runs the last MCP reload even when the config is unchanged, so servers that failed to connect are retried; connected servers keep their session because their config is unchanged. This makes `coder exp chat context refresh` (no argument) and the agent's `POST /api/v0/context/resync` retry failed servers. Resync is only called on explicit user request today, so no background traffic is added. Not covered here: a server that restarts after it connected keeps its stale session, since its config is unchanged. <details> <summary>Plan and decisions</summary> **Problem** 1. **Never connected.** A server that is down at the first reload is listed as `failed to connect` until the config file changes, because `startReloadIfNeeded` short-circuits when `SnapshotChanged` is false. 2. **Connected, then dead.** A server that restarts after connecting keeps its stale `ClientSession`; `classifyServers` keeps it because its config is unchanged. Out of scope for this PR. **Current wiring** - Reload triggers: once after startup scripts (`agent/agent.go`) and the `.mcp.json` fsnotify watcher. - After a reload changes the catalog, the agent pushes context and coderd live-syncs MCP rows into every bound chat, so new tools reach chats on their next turn without a chat refresh. - `coder exp chat context refresh` (no argument) calls the agent socket `ResyncContext`, which runs `agentcontext.Manager.Resync`. Before this PR, Resync re-read the MCP catalog but did not reconnect. - The UI "Refresh context" button calls `chatd.RefreshChatContext`, which is DB-only (re-pin) and never reaches the agent. **Options considered** | Trigger | Latency | Cost | Decision | | --- | --- | --- | --- | | A. Periodic agent ticker while a server is unhealthy | Up to one interval | Periodic dials to dead servers | Rejected | | B. On-demand via agent Resync (CLI, agent HTTP route) | Immediate | None unless invoked | This PR | | C. On-demand via UI "Refresh context", running the same agent resync as the CLI | Immediate | None unless clicked | Follow-up PR | | D. Per-turn nudge from chatd | Next turn | One agent request per turn, fleet-wide | Rejected | **Implementation choices** - `Reconnect` clears the stored config file snapshot and calls `Reload`, rather than adding a force flag to the reload path. `SnapshotChanged` then reports a change, the singleflight reload runs, and `installServers` writes a fresh snapshot. False-positive reloads were already documented as safe. - No backoff or retry state. **Follow-up (C)** Make the existing "Refresh context" button run the same agent resync as the CLI (coderd calls the agent's `/api/v0/context/resync`, then re-pins), and render it when MCP server issues exist. </details> --- Generated by Coder Agents on behalf of @jeremyruppel. |
||
|
|
1a65385a4b |
fix: log workspace shutdown reasons for SSH connections (#30515)
Workspace stops and deletes closed active SSH connections with generic shutdown or process-exit reasons. This obscured the workspace action that ended a connection and made related logs harder to correlate. The agent’s SSH tracking and logging now identify connections closed by the SSH server as server_shutdown, while preserving earlier client or network disconnects. The agent includes the client session ID when available for ordinary sessions and connections used only for port forwarding. Coderd now enriches shutdown reasons when it processes connection reports. It translates server_shutdown into workspace_stopped when the latest build is a running or successful stop or delete requested before the connection closed. Coderd persists the enriched reason and logs the build reason, transition, and build ID alongside the client session ID. Unavailable or unrelated build state retains the generic shutdown reason. The CLI now logs shutdown context once per stop or delete build through its existing workspace watcher. This includes the client session ID when available and preserves the existing graceful SSH shutdown behavior. Regarding the PTY connections, when the agent shut down, the reconnecting PTY server closed each PTY and its attached connections, and the connection handler then returned without an error. The server therefore logged and reported those connections as graceful closes. Its fallback for a forced shutdown reported a free-form reason that coderd did not recognize, so coderd never refined either case into a workspace shutdown. We change the reconnecting PTY server so that it reports any connection that ends after the agent begins shutting down as a server shutdown initiated by the agent, and its log keeps the client session ID. The forced shutdown fallback now reports the same standard reason, which lets coderd translate it into a workspace stop or delete in the connection log, as it already does for SSH. A client that closes its connection before the shutdown still keeps its graceful reason. Regression tests cover shutdown attribution, fallback behavior, CLI logging, and PostgreSQL persistence with and without a client session ID. The test logging helper also synchronizes with cleanup to prevent logging after a test completes - resolves https://linear.app/codercom/issue/CLIENT-665/close-workspace-tunnel-with-a-reason <!-- If you have used AI to produce some or all of this PR, please ensure you have read our [AI Contribution guidelines](https://github.com/coder/coder/blob/main/contributing/AI_CONTRIBUTING.md) before submitting. --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
03cba25a63 |
feat: list a workspace build's secrets in coder secret list (#30388)
`coder secret list` now shows the current workspace build's secrets next to your user secrets, and which user secrets they replace. Part of [RELAY-7](https://linear.app/codercom/issue/RELAY-7/agent-relay-deliver-provider-credentials-via-coder-secrets-instead-of). **Stack** (design decisions in #30248) 1. #30248 Database schema, queries, and RBAC 2. #30249 Encryption at rest 3. #30250 Set secrets on workspace builds 4. #30251 Deliver secrets to the agent 5. #30252 Docs 6. **#30388 List a build's secrets (this PR)** 7. #30459 Audit a build's secrets - New `GET /workspacebuilds/{workspacebuild}/secrets` lists a build's secrets (metadata only, never values) and which user secret each one replaces. - Inside a workspace, `coder secret list` includes the current build's secrets. Outside a workspace, use `--workspace` or `--build-id`. - The agent now exposes `CODER_WORKSPACE_BUILD_ID`, so the CLI knows which build it is running in. - The agent manifest and the new endpoint use one shared resolver, so they always agree on which secret wins. - The user secret API is unchanged. <details> <summary>Implementation details</summary> - The manifest carries `workspace_build_id`; the agent sets it as `CODER_WORKSPACE_BUILD_ID`. - `coderd/workspacesecrets.Resolve(user, build, policy)` decides which secret is delivered on each env var and file. The manifest no longer relies on entry order. - `codersdk.WorkspaceSecret` embeds `UserSecret` and adds `workspace_build_id`, `ephemeral`, `cleared_at`, `env_replaces`, and `file_replaces`. Secrets whose values a later build cleared are still listed, with `cleared_at` set. - CLI columns: `source` and `replaced by` are shown by default only when a build is included; `ephemeral` is opt-in. The CLI makes two requests: user secrets, then build secrets. - Agents that predate the build ID fall back to `CODER_WORKSPACE_ID` and its latest build. </details> <details> <summary>Decision log</summary> (existing decision log, unchanged) </details> --- *Created by Coder Agents on behalf of @Emyrk.* |
||
|
|
c6a47c4428 |
docs: replace references to the retired Enterprise license tier (#30853)
## Summary Coder has only Community and Premium license tiers, but several docs pages, CLI help strings, and SDK field comments still called features "Enterprise" or "enterprise-only". This PR changes them to say Premium and regenerates the reference docs built from those strings. Resolves [DOCS-1298](https://linear.app/codercom/issue/DOCS-1298/remove-references-to-the-retired-enterprise-license-tier). ## Changes - `docs/admin/users/quotas.md`: Replace "scoped to Groups in Enterprise and organizations in Premium" with a correct sentence. Quotas are Premium, allowances are set on groups, and each user's budget is calculated separately in each organization (per `GetQuotaAllowanceForUser`). - `docs/user-guides/workspace-lifecycle.md`: Replace "Enterprise" with Premium, and correct the quotas sentence to match the quotas page. - `docs/ai-coder/agents/platform-controls/mcp-servers.md`: Replace "enterprise entitlement" with Premium license. - `cli/templatecreate.go`, `cli/templateedit.go`: Update `--require-active-version`, `--allow-user-autostart`, and `--allow-user-autostop` help text. Point the `--require-active-version` help at the renamed `#template-update-policies` section, because the old `#require-automatic-updates-enterprise` anchor is broken. Make the errors for these flags tier-neutral. - `enterprise/cli/features.go`: `coder features` now says "List license features and entitlements", and its AGPL error no longer names a tier. - `codersdk/templates.go`, `codersdk/organizations.go`: Update field comments that feed the API reference and TypeScript types. - `docs/reference/glossary.md`: The Premium entry now says "paid license tier" instead of "paid enterprise tier". - `docs/.style/style-guide/voice-and-tone.md`: The example sentence now says "Premium licensing". - Regenerated: CLI golden files, `docs/reference/cli/`, `docs/manifest.json`, `docs/manifest/generated/cli.json`, `docs/reference/api/`, `coderd/apidoc/`, and `site/src/api/typesGenerated.ts`. ## Testing - `go test ./cli -run 'TestCommandHelp|TestCliTemplateCreate'` and `go test ./enterprise/cli -run 'TestEnterpriseCommandHelp|TestTemplateCreate|TestTemplateEdit|TestFeaturesList'` pass. - The pre-commit hook passed, including `make gen`, `fmt`, `lint/go`, `lint/ts`, `lint/markdown`, and a slim build. <details> <summary>Decisions and out-of-scope items</summary> ### Decisions - **Premium wording and legacy Enterprise licenses:** Coder still accepts existing Enterprise licenses, and `FeatureSetEnterprise` includes the features labeled Premium here. Docs and help text say "Premium" because that is the tier sold today, and about 25 other docs pages already use "Premium feature". Error strings are tier-neutral, so they're accurate for every license holder. - **Glossary and style guide:** The issue marked these as borderline. Both were one-word changes, so I made them. ### Not changed - `docs/reference/api/enterprise.md` keeps the "Enterprise" sidebar title. It comes from the swagger tag on the `enterprise/` Go package, so renaming it is a larger change. - Other "Enterprise" references the review flagged as out of scope: the `coder server --help` option group, quiet hours SDK comments, internal `coderd` comments, and the dashboard's "Enterprise" badge on the require-active-version option. - No docs page says that legacy Enterprise licenses are still valid. - Uses that don't refer to the license tier: GitHub Enterprise, Red Hat Enterprise Linux, "enterprise environments", and `enterprise/` package paths. </details> --- _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
11f1ee7d9f |
ci: fail the test process with a heap profile when memory passes a per-runner limit (#30487)
test: add memory guard and heap profiles for CI timeouts Add a memory guard to `cli`, `agent`, and `enterprise/cli` to diagnose recurring macOS `test-go-pg` timeouts. Recent logs show runaway memory usage and heavy swapping, but the allocation source remains unknown. - Check Go runtime memory once per second, with per-process CI limits of 5 GiB on macOS and 6 GiB on Linux and Windows. Disabled when `CODER_TEST_MEMORY_LIMIT_MIB` is unset. - On exceeding the limit, save a heap profile, attempt a second profile after forced GC with a five-second wait limit, then panic with memory usage, profile paths, and all goroutine stacks. - Upload heap profiles from unsuccessful CI jobs on every OS, retaining them for seven days. - Test guard lifecycle, environment parsing, panic diagnostics, profile validity, and post-GC allocation attribution. Validate with race tests, vet, lint, and a manual macOS test. Refs https://linear.app/codercom/issue/PLAT-251/flake-test-go-pg-macos-job-timeoutcancelled Refs https://github.com/coder/internal/issues/1365 |
||
|
|
c856d5fb22 |
feat: accept template version IDs in --template-version (#30563)
Follow-up to #30199. `--template-version` on `coder create`, `start`, `stop`, and `update` (plus `--stop-template-version` on `update`) now takes a template version ID as well as a name. Passing a version UUID used to 404 with a pretty unhelpful `get template version by name` error. `resolveTemplateVersionID` still looks up by name first, so a version that happens to be named like a UUID resolves the same way it did before. If that 404s and the input parses as a UUID, it falls back to fetching the version by ID. Either way the version has to belong to the selected template. That check matters most for `create`, which only sends the version ID and lets the server derive the template from it, so without it `coder create --template foo --template-version <id of a bar version>` would quietly create a `bar` workspace. The name is now path-escaped before the lookup. Previously something like `../../../templateversions/<id>` could reach other API routes through the name lookup and skip the template check entirely. Not-found errors now read `template version "x" not found for template "foo"` instead of the raw SDK error, so anything matching on the old text will need updating. Flag help and the generated CLI docs say "name or ID" now. |
||
|
|
2b9fad8bba |
feat: add chat project sharing database layer (#30479)
Database and authorization layer for chat project sharing (experiment `chat-projects`), part 1 of 2. #30439 adds the API on top of it. Nothing here changes behavior: projects start with empty ACLs, no endpoint writes them yet, and deleting a project still detaches its chats. Project deletion is in #30683. - **Schema:** migration `000621` adds `user_acl` and `group_acl` jsonb columns to `chat_projects`, typed as `ChatACL` like chats, with GIN indexes. It also adds the `chat_project:share` API key scope. - **Queries:** - `GetChatProjectsOwnedOrSharedWithUserID`: owned projects plus projects with an ACL entry for the user directly, through a group, or through the Everyone group (whose ID is the organization ID). Entries count only for members of the project's organization. Keys match regardless of actions, so dbauthz filters the rows. - `IsChatProjectAccessibleByUserID`: whether a user owns a project or holds a `read` or `*` grant on it, for code running under a system subject. With sharing disabled, dbauthz answers owner-only. - `GetChatProjectByIDForUpdate`: lets the ACL update read, modify, and write in one transaction. - `UpdateChatProjectACLByID`. - **RBAC:** - New `share` action on `chat_project`. dbauthz requires it to update the ACL. - `ChatProject.RBACObject` attaches the project ACL. Memory objects get a derived ACL: project `read` grants memory read, and `read` with `update` grants memory create and delete. Wildcard grants count. Read sharees change memories through their chats' agents, which #30439 gates. Project instructions authorize through the same object, so a `read` grant reads them and an `update` grant edits them. - `--disable-chat-sharing` also covers projects: ACLs are ignored, the ACL update is rejected, and roles deny `chat_project:share`. The help text and chat sharing docs say so. - **Audit:** `user_acl` and `group_acl` changes are tracked. - **Tests:** - Querier tests run the access queries both raw and through dbauthz (owner, direct user, group, Everyone, wildcard grants, a member of another org, grants without read). - RBAC object and memory ACL tests, with an authorizer check, in both sharing modes. - dbauthz cases including the disabled guards, and the `chat_project:share` negation in the roles test. The generated TypeScript changes only add the new scope value. > Generated by Coder Agents. |
||
|
|
69fab7de06 |
chore!: remove the coder_report_task MCP tool (#30742)
Coder Tasks have been removed from coder/coder, so the
`coder_report_task` MCP tool and the status reporting pipeline behind it
no longer do anything useful. This PR removes the tool and the code that
only existed to support it.
### Removed
- `codersdk/toolsdk`: `ToolNameReportTask`, `ReportTaskArgs`,
`ReportTask`, `Deps.report`, `WithTaskReporter`, and the `All` entry,
plus their tests.
- `coderd/mcp`: the remote MCP exclusion for `coder_report_task`.
- `coder exp mcp server`: the task reporter, the AgentAPI screen
watcher, the agent socket connection, and the `coder_report_task` skip
logic. The server now requires an authenticated user client, because
every remaining tool needs one.
- `coder exp mcp configure claude-code`: the
`mcp__coder__coder_report_task` allowed tool, the injected
`coder_report_task` CLAUDE.md prompt, the `report tasks properly`
history line, the default system prompt asking the agent to send task
status updates, and the `CODER_MCP_APP_STATUS_SLUG` /
`CODER_MCP_AI_AGENTAPI_URL` env written to the Claude MCP config.
- `cli/cliutil/queue.go`: only used by the reporter.
- `github.com/coder/agentapi-sdk-go` (and transitive `tmaxmax/go-sse`)
via `go mod tidy`.
- The "task reporting" mention in `docs/ai-coder/mcp-server.md`.
### Breaking: removed `coder exp` flags and env
`coder exp` is experimental. Any scripts that still pass these flags
will now fail with an unknown flag error. Env vars that are no longer
read are ignored.
| Command | Flag | Env |
|---|---|---|
| `coder exp mcp server` | `--app-status-slug` |
`CODER_MCP_APP_STATUS_SLUG` |
| `coder exp mcp server` | `--ai-agentapi-url` |
`CODER_MCP_AI_AGENTAPI_URL` |
| `coder exp mcp server` | `--socket-path` | `CODER_AGENT_SOCKET_PATH`
(still used by `coder agent` and `coder exp sync`) |
| `coder exp mcp configure claude-code` | `--claude-app-status-slug` |
`CODER_MCP_APP_STATUS_SLUG` |
| `coder exp mcp configure claude-code` | `--ai-agentapi-url` |
`CODER_MCP_AI_AGENTAPI_URL` |
`--claude-system-prompt` no longer has a default.
<details>
<summary>Intentionally kept</summary>
- **Workspace app status reporting** (`UpdateAppStatus` on the agent API
and agent socket, `agentsdk.PatchAppStatus` / `ProtoFromPatchAppStatus`,
the deprecated `PATCH /workspaceagents/me/app-status` endpoint): still
served by coderd and the agent and part of versioned protocols. With
this change, nothing in the CLI calls the agent socket `UpdateAppStatus`
client anymore. Removing it would need a separate protocol change.
- **`report_tasks` in
`coderd/templatebuilder/modules/{aider,amazon-q}`**: these catalog
entries mirror the input variables of pinned coder/registry module
versions, and the behavior lives in those modules. Dropping the variable
here would not disable it, because `amazon-q` defaults it to `true`. The
registry modules need a follow-up instead.
- **`UserClientOptional` on toolsdk tools**: other tools still set it,
and remote MCP still uses it.
- No CLI golden files or generated CLI docs changed, because `coder exp`
commands are hidden.
</details>
### Verification
- `go build ./...`
- `go test ./codersdk/toolsdk/... ./coderd/mcp/... ./cli/cliutil/...`
- `go test ./cli -run 'TestExpMcp|TestCommandHelp'`
- `golangci-lint run ./cli/... ./codersdk/toolsdk/... ./coderd/mcp/...`
(0 issues)
---
_Generated by Coder Agents._
Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com>
|
||
|
|
7517301ffa |
chore: add golangci new-code quality gates (#30622)
Stack context: second layer of the Go lint gate stack, built on the exclusion fix below. Why: adds commented-out code detection and a `log/slog` ban to the main config, plus a new-code-only pass requiring reasons on lint suppressions, flagging ignored errors (including `_, _ = w.Write(...)`), and banning `time.Sleep` in tests. Fixing the hits surfaced a real bug: GitLab warnings went to the wrong logger. The new-code pass resolves symlinked checkout paths so it does not silently report nothing. Validation: both configs report 0 issues; each seeded violation is caught; `make pre-commit` passed. > Xum acted for Mike to open this PR. |
||
|
|
5b060beeb1 |
feat: separate connection log methods from app names (#30466)
Connection logs now record how a connection was made (`connection_method`) separately from which app made it (`app_name`). Storage, the HTTP API, search filters, and the UI move to the new fields. Legacy agent reports and the deprecated `type` field keep working. - Add `connection_method` (`ssh`, `reconnecting_pty`, `workspace_app`, `port_forwarding`, `tunnel`) and optional `app_name` and `app_display_name` to `GET /api/v2/connectionlog`. Deprecate `type` and make it a plain string in the API and the Go SDK. - Add `method:` and repeatable `app:` search filters. `type:` keeps its old results but can't be combined with the new filters. - Replace the Type menu with a Method menu, show the app next to the method in each row, and warn when a filter uses `type:`. - Change the Active SSH connections preset to `method:ssh`, so it also includes SSH sessions from VS Code and JetBrains apps. - Generate `codersdk.ConnectionLogMethod` from the database enum with `typegen dbenums`. - Migration 000617 rewrites `connection_logs` under an ACCESS EXCLUSIVE lock, which takes about 50 seconds for 10 million rows. `vscode` and `jetbrains` rows become `ssh` rows with that app. Rolling back folds apps into the old types and loses per-app names. - Document the new filters and how to replace each `type:` value. Closes #27412 |
||
|
|
f923f4a525 |
chore!: remove the chat automations experiment (#30412)
Removes the experimental Chat Automations feature (`chat-automations` experiment) from main. This reverts the 16-PR stack that added it and adds two forward migrations that undo its schema and credential changes.
> [!WARNING]
> **Upgrade consequences**
>
> - **Automation data is deleted.** Migration 000615 drops the `chat_automations` table and deletes every queued message an automation delivered. Chats, their messages and ordinary queued messages stay. Messages lose their automation provenance (`automation_id`, `input_id`).
> - **Automation-only credentials are revoked.** Migration 000616 deletes API keys, OAuth2 codes and OAuth2 tokens whose only scopes (or allow-list entries) were `chat_automation:*`. Mixed credentials keep their other scopes. Custom roles lose their `chat_automation` permissions. OAuth2 apps that allowed only `chat_automation` scopes get the whitespace allowlist that grants nothing, as in 000595.
> - **A coordinated restart is required.** Stop all old replicas before the new version runs the migrations. Old replicas read the dropped table and columns, so a rolling deploy is not supported.
> - **Remove `--chat-max-automations-per-owner` before upgrading.** The flag, the YAML key `chat.maxAutomationsPerOwner` and the env var `CODER_CHAT_MAX_AUTOMATIONS_PER_OWNER` are removed. A deployment that still sets the flag or the YAML key will not start (`unknown flag` / `unknown option`). The env var is ignored. This includes dogfood. No release or tag contains the flag.
> - **Down migrations restore the schema only.** 000616 down and 000615 down recreate the 000611 schema with empty tables. They do not restore deleted automations, webhook secrets, provenance, queued deliveries, revoked credentials, stripped permissions or the deleted experiment rule.
## What is removed
- The `chat-automations` experiment and its stored runtime rule (`experiment_rule:chat-automations`).
- The `--chat-max-automations-per-owner` deployment option.
- The `chat_automation` RBAC resource, its member and chatd grants, and the `chat_automation:*` API key scopes.
- The automation sqlc queries, dbauthz wrappers and audit table entries.
- The management routes under `/api/experimental/organizations/{organization}/chat-automations`, and the webhook route `POST /api/experimental/chat-automations/{automation}/events` with its rate limiter.
- The chatd management service, webhook publish, schedule loop, the `manage_automations` tool, and the chatstate admission seam and queue promotion guard that only automations used.
- The Agents Automations page, editor, nav entry, chat labels, the Manage automations toggle and the API client.
- The `archived:any` chat search value that the automations "View chats" dialog added.
- `docs/ai-coder/agents/automations.md`, its manifest entry, the glossary entry and the related rows.
Reverted PRs: #30085, #30096, #30112, #30117, #30127, #30134, #30160, #30166, #30167, #30171, #30187, #30207, #30214, #30217, #30219, #30220.
## What stays, and why
- Migrations 000609, 000610 and 000611, their fixture, and the #30297 lock fix with `migration000609_test.go` stay unchanged. Deployments such as dogfood already ran them.
- New migration **000615** reverses the schema changes of 000609 and 000611 against the current schema. It uses the same short-wait lock-and-retry block as 000609, and it rebuilds `chats_expanded` from main's current definition minus the two automation columns. New migration **000616** follows the 000595 Tasks removal for credentials and recreates `api_key_scope` without the five `chat_automation:*` values. It keeps the `chat_project_memory:*` values from 000612.
- The `chat_automation` value stays in the `resource_type` enum, and `codersdk.ResourceTypeChatAutomation` stays. Old audit log rows stay readable, as with `task` after the Tasks removal.
- The 000615 delete fires the existing queue-version trigger, so `queue_version` moves to `snapshot_version` for each affected chat. `snapshot_version` is not bumped: the coordinated restart restarts every stream loop from an empty state, and the site does not read the version fields.
- `coderd/x/chatd/ARCHITECTURE.md` drops the sections the stack added and gets back its pre-stack wording, merged with the later main edits to the same file.
## Notes for reviewers
- #30379 (chat project page) merged while this PR was in progress. It passed `manageAutomationsEnabled` in `AgentCreatePage.test.tsx` and listed an `automations` route in `AgentsPageLayout.test.tsx`. Later main commits also added automation props in `ConversationTimeline.test.tsx` and `ConversationTimelineWorkingBlocks.stories.tsx`. This PR removes all of them.
- Remaining `automation` matches under `coderd`, `codersdk`, `enterprise`, `site/src` and `docs` are intended:
- migrations 000609 to 000611, their fixture and `migration000609_test.go`;
- the new 000615 and 000616 migrations and `migration000615_test.go`;
- the `chat_automation` resource type in `dump.sql`, `models.go`, `codersdk/audit.go`, the generated API docs, `swagger.json` and `typesGenerated.ts`;
- unrelated uses of the word "automation" (docs, `chatlabels_test.go`, `ratelimit.go`, `autostop.go`, `subagent_catalog.go`, `WorkspaceSharingSection.tsx`, `AgentChatPage.stories.tsx`).
Remote UAT on an isolated dev deployment passed. It upgraded a populated pre-removal database, then checked chats, queued messages, tokens, the 404 routes, the removed page and nav entry, and the experiments list.
---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_

|
||
|
|
0efb574355 |
feat(cli/cliui): add TextFormatFunc and OutputFormatter.WriteLine helpers (#30508)
Adds two small helpers to `cli/cliui/output.go` so commands that add `-o/--output` don't repeat the same boilerplate, as suggested in https://github.com/coder/coder/pull/30152#issuecomment-6043360441 by @jeremyruppel. - `TextFormatFunc[T]` wraps `ChangeFormatterData(TextFormat(), ...)` with the type assertion and "expected X, got Y" error, so a command only supplies its render function. - `(*OutputFormatter).WriteLine` formats data and writes it to an `io.Writer` with a trailing newline, replacing the `Format` + `Fprintln` block. No existing callers change in this PR. These PRs are stacked on it and use the helpers: - #30135 `coder tokens create` - #30139 `coder ai-gateway keys create` - #30145 `coder organizations members edit-roles` - #30152 `coder provisioner keys create` Migrating the existing callers on `main` (for example `cli/organization.go`, `enterprise/cli/workspaceproxy.go`) is left for a follow-up, since some of them print with `Fprint` rather than `Fprintln` and need care to keep output identical. Refs CLI-56 <details> <summary>Decision log</summary> - A global `-o` flag on the root command was ruled out because `coder config-ssh` already uses `-o` for `--ssh-option`. - The "one-time secret plus metadata" response structs in #30135 and #30152 stay local to each command, since they embed different SDK types and a shared helper would save little. - `WriteLine` uses `Fprintln` to match the four stacked PRs and most existing callers. It was renamed from `Write` during review so the trailing newline is visible at call sites and the method is not confused with `io.Writer`. </details> > [!NOTE] > This PR was generated by Coder Agents on behalf of @nickvigilante. |
||
|
|
a8303a8f2b |
feat!: add output formats to coder schedule start, stop, and extend (#30136)
`coder schedule start`, `stop`, and `extend` printed the updated schedule as a fixed table with no `-o` or `-c`, while `coder schedule show` has both. All four commands now share one formatter with the same row type, default columns, `-o table|json`, and `-c`, so the output of a change and of `show` is interchangeable. **Behavior change:** Adds `-o` and `-c` to the three commands. The default table output changes slightly: the WORKSPACE column no longer includes the favorite-star prefix, matching `schedule show`. Other columns are unchanged. <details> <summary>Decisions</summary> - Previously these commands rendered `WorkspaceListRow`, which prefixes the workspace name with a favorite icon. Using `scheduleListRow` for consistency with `schedule show` drops that prefix. </details> Closes [CLI-15](https://linear.app/codercom/issue/CLI-15) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
98bcc3afb7 |
fix!: remove the unused --yes flag from coder autoupdate (#30149)
`coder autoupdate` has registered `-y/--yes` since #10438 but never prompts, so the flag did nothing. This PR removes it. **Breaking change:** `coder autoupdate` no longer accepts `-y/--yes`. Scripts that pass it now fail with `unknown shorthand flag: 'y'`. To fix them, drop the flag; it never had an effect. <details> <summary>Decisions</summary> - The first version kept `-y` as a hidden no-op so existing scripts wouldn't break. - Reviewers preferred removing it outright as a breaking change, since a deprecation period would end in the same removal and the hidden flag is cruft. - The title uses `fix!:` and the PR carries `release/breaking`, so the release tooling lists it under breaking changes. - `cliui.HiddenSkipPromptOption()` landed on `main` through the organizations create PR and stays there for that command; this PR no longer touches it. - The test now pins the new behavior: passing `-y` returns an unknown flag error. </details> Closes [CLI-33](https://linear.app/codercom/issue/CLI-33) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
a115896a58 |
feat: add script resource address and dependencies to Script (#30451)
feat(provisionersdk): add script dependency proto fields Add optional `resource_address` and `dependencies` fields to `Script` for transporting resolved script ordering. Dependencies identify a prerequisite by Terraform address and require `SUCCESS` (successful exit) or `COMPLETION` (finish regardless of outcome). - Bump provisionerd API from v1.19 to v1.20, regenerate Go/TypeScript bindings, and update the CLI golden output. - Reuse the existing resource tree for workspace-agent and devcontainer scripts; no changes to `GraphComplete` or the provisionerd runner. - Add round-trip tests for both script types and verify unset fields preserve existing wire encoding. The fields remain unused in this PR. Follow-up provisioner changes populate them; PLAT-548 reads and persists them in coderd. **Release requirement:** Ship with the PLAT-545 integration stack, targeting 2.39, so no daemon advertises v1.20 without sending ordering. Hold or revert this PR before the release cut if that stack misses it. Refs PLAT-547. |
||
|
|
b4d51012da |
feat: allow template version selection for workspace builds (#30199)
Add named template version selection to `coder start` and `coder stop`, and independent stop/start selection to `coder update` with `--stop-template-version` and `--template-version`. Stop still defaults to the workspace's current version, and update starts with the active version by default. Explicit selections use the selected version for parameter preparation and builds, keep server permissions authoritative, and never silently fall back to the active version. Classic stop builds retain previous parameter values omitted by the selected stop version, so a later start can reuse them across separate commands or an interrupted update. Declared parameters still follow normal validation, and start builds still discard removed parameters. Update now returns an error and retry guidance when a start apply fails after stopping, including unflagged updates that previously returned success. Closes #29100 [PLAT-616](https://linear.app/codercom/issue/PLAT-616/cli-allow-specifying-a-template-version-for-stopstart-builds-and-both) --------- Co-authored-by: Nick Vigilante <nickvigilante@users.noreply.github.com> |
||
|
|
b4fb7901e6 |
docs: clarify that disable-password-auth also applies to owners (#30362)
The `--disable-password-auth` help text says owners can still sign in with a password "to avoid potential lock out", and a comment in `coderd/userauth.go` says the same. Neither is true. #6193 removed the owner bypass on purpose, so the flag blocks password login for everyone. The recovery advice was also wrong. It named a command that doesn't exist (`create-admin`), and any admin that `create-admin-user` creates while the flag is on still can't sign in. This PR changes docs and comments only: - Rewrites the flag description to say it applies to owners too and how to recover access. Regenerated the CLI and config reference docs and the golden files. - Fixes the misleading comment in `coderd/userauth.go`. - Adds the same warning and recovery steps to `docs/admin/users/password-auth.md`. > [!NOTE] > Generated by Coder Agents on behalf of @jdomeracki-coder. |
||
|
|
7c39819665 |
fix(cli): close coderd on server startup errors (#30280)
`coder server` closes the coderd API only in its graceful shutdown sequence. Every startup error returned after `newAPI` (creating aibridged, registering Prometheus metrics, writing the config URL, creating provisioner daemons, notifying systemd) skipped that close and leaked the whole coderd instance: tailnet and wireguard-go, gvisor, metricscache, dbrollup, cryptokeys, chatd, and pubsub queues. `TestServer/Logging` hits this when test cleanup cancels startup while aibridged is being created. The test helper ignores the resulting `context canceled` error, so only the package-level goleak check in `cli` fails. The fix closes the API in a deferred `sync.OnceValue` registered right after `newAPI`, and the shutdown sequence calls the same function. The guard is needed because the closer is not safe to call twice: the AGPL API returns "API already closed", and the enterprise closer closes each component again. The normal shutdown path is unchanged. ## Testing The new `TestServer/StartupErrorNoLeak` fails startup after coderd is created by putting a directory at the config URL path. - Red (test only): `go test ./cli -run '^TestServer$/^StartupErrorNoLeak$' -count=1` exited 1 in 3 of 3 runs with `goleak: Errors on successful test run: found unexpected goroutines` (coderd frames) while the subtest passed. - Green (with the fix): the same command passed in 3 of 3 runs. - `TestServer/Logging` alone, 20 runs from one test binary: 20 of 20 passed with no goleak failure, including 3 runs that hit the `create aibridged` startup error. - `go test ./cli -count=1` passed in 4 of 4 runs, and `go vet ./cli` is clean. Found in the CI of #30272 (`test-go-pg (ubuntu-latest)`). > Xum, an AI coding agent, implemented, tested, and opened this PR on behalf of @ibetitsmike. |
||
|
|
dad9f733f4 |
chore: improve code vpn-daemon run help text (#30331)
|
||
|
|
237616a87d |
fix!: make --yes skip the rename confirmation prompt (#30151)
`coder rename` registers `-y/--yes`, but its confirmation asks you to type the workspace name, and `cliui.Prompt` only honors `-y` for yes/no prompts. So `coder rename ws new -y` still blocked on input. With `-y`, the type-the-name prompt is now skipped. The data-loss warning is still printed. **Behavior change:** With `-y`, the rename happens without reading stdin. Without `-y`, the prompt is unchanged. Closes [CLI-35](https://linear.app/codercom/issue/CLI-35) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
15616728d5 | refactor: move coderd/x/nats to coderd/nats | ||
|
|
ffc7dadfe2 |
refactor: use typed AI Gateway actor identity (#30258)
Adds typed AI Gateway actor identity, including the API key ID used by recording. Recorders now read the authenticated API key ID from each call context instead of capturing request identity at construction time. This allows one recorder to be reused safely across sequential and concurrent requests. Includes context helper coverage and recorder regression tests. Generated by Coder Agents on behalf of @pawbana. |
||
|
|
cc0c868c55 |
feat: add client_session_id to ssh connections (#29701)
Add a new /tcp endpoint on the agent that is used to pass along the client session ID (with the existing baggage mechanisms). The agent then can upgrade that into the desired connection type, based on the port. For now that is only the standard SSH port and reconnecting pty. The `ssh`, `ssh --stdio`, `ssh --stdio` over Coder Connect, `exp rpty`, and web terminal paths are all updated to use this new endpoint, and fall back to the old method when the endpoint is not available. That ID is added to the log context, and is also used to populate the session ID column in the connection logs table. There are some logs related to a connection that will not be tagged with the ID (like the "accepted connection" line) because they happen before the http handler gets to run. |