Commit Graph
16592 Commits
Author SHA1 Message Date
Danielle Maywood 06d421fbcf chore: vendor the @shadcn/react message-scroller source (#29473)
The agent chat transcript scrolls through `@shadcn/react`'s
MessageScroller, and its scroll defects have to be fixed in the package.
The package ships only minified dist, so the fix would be an
unreviewable patch against minified code, and 0.3.1 still has the
identical defect, so an upgrade buys nothing.

This vendors the readable upstream source (`@shadcn/react@0.3.0`, commit
`b1c580c63`, MIT) under `site/src/vendor/` and drops the npm dependency.
It is a pure move with no behavior change; the fix itself follows in
#29354. Each file header pins the upstream tree, and any deviation from
upstream must be marked `LOCAL CHANGE`.
2026-09-22 10:20:24 +01:00
Thomas Kosiewski 60cc826f2b feat: sign forwarded MCP identity headers (#29669) 2026-09-22 11:11:08 +02:00
Jake Howell 47d3e1c52b feat(site/src/components): animate overlays from their trigger (#29620)
> 🤖 This PR was written by Coder Agents on behalf of Jake Howell.

Extremely subtle... overlays previously zoomed from their own centre, so
a menu opened from a corner appeared to grow out of nowhere instead of
out of its trigger.

Radix already publishes the trigger-relative origin as
`--radix-popper-transform-origin` on the popper wrapper, so the fix is
to read it:

| Component | Change |
|---|---|
| `Popover`, `Select`, `Tooltip` |
`origin-(--radix-popper-transform-origin)` |
| `DropdownMenu`, `ContextMenu` | same, via the shared
`menuContentClass` |
| `MultiSelectCombobox` | `origin-top` (not popper-based; anchored
directly below its input) |

| Old | New |
| --- | --- |
| <img width="300" alt="preview--old"
src="https://github.com/user-attachments/assets/84410733-5de0-452e-bdb1-af4ca44a066e"
/> | <img width="300" alt="preview--new"
src="https://github.com/user-attachments/assets/d36bd3df-37e9-4eed-b477-870135e9ef6f"
/>
2026-09-22 09:10:55 +10:00
Rowan Smith 31842bdbc5 chore: (helm) expose deployment strategy parameter (#29652)
closes #28797

adds support for specifying a custom value for `coder.strategy` which
gets applied to the `Deployment` object.

tests included.

pre:
```
➜  helm-deployment-pzxt git:(helm-deployment-pzxt) helm template coder coder-v2/coder --set coder.image.tag=v2.37.2 | grep -A5 strategy
➜  helm-deployment-pzxt git:(helm-deployment-pzxt) 
➜  helm-deployment-pzxt git:(helm-deployment-pzxt) helm template coder helm/coder --set coder.image.tag=v2.37.2 | grep -A5 strategy
➜  helm-deployment-pzxt git:(helm-deployment-pzxt) 
```
post:
```
➜  helm-deployment-pzxt git:(helm-deployment-pzxt) helm template coder helm/coder --set coder.image.tag=v2.37.2 --set coder.strategy.type=RollingUpdate,coder.strategy.rollingUpdate.maxSurge=50%,coder.strategy.rollingUpdate.maxUnavailable=3 | grep -A5 strategy
  strategy:
    rollingUpdate:
      maxSurge: 50%
      maxUnavailable: 3
    type: RollingUpdate
  template:
```
2026-09-22 08:12:51 +10:00
Michael Suchacz efd8e8ca12 fix(coderd): require read and update chat permissions for delegated chat owners (#29684)
`POST /api/v2/chats` with `owner_id` (#29581) checks that the delegated
owner holds `chat:create` before creating the chat under the owner's
context. Creation also inserts the first message (`chat:update`) and
reads the chat back (`chat:read`) inside the same transaction, so an
owner whose custom organization role grants only `chat:create` passed
the preflight and then failed inside the transaction with a generic 403
instead of the intended 400 `Chat owner does not have permission to use
chats.` The transaction rolls back, so no chat is left behind; only the
status code and message were wrong.

The preflight now requires create, read, and update for the owner.
Regular organization members hold all three through the member role, so
this only changes the response for service accounts and custom roles
with partial chat grants.

Found by Codex on the 2.37 backport (#29683), which carries this same
commit. The code is identical on main.

## Validation

- `TestPostChats_OwnerID/OwnerWithCreateOnlyChatPermission`: red on the
unfixed head (403 instead of 400), green with the fix.
- `go test ./coderd/ -run 'TestPostChats|TestPatchChat' -count=1`: pass.
- Pre-commit hook (gen, fmt, lint, slim build) passed on this commit.

> Xum opened this PR on behalf of @ibetitsmike.
2026-09-21 20:05:43 +00:00
Michael Suchacz e35cbe2a7f fix(coderd/x/chatd): stream compaction summaries (#28886)
Chats could get permanently stuck once their context crossed the
compaction threshold on adaptive-thinking Claude models: every
compaction attempt failed with `compaction produced an empty summary`,
and both automatic and manual compaction take the same path, so the chat
could never recover.

## Problem

`compactionSummaryCall` deliberately set `MaxOutputTokens = nil` because
the summary request was non-streaming and the Anthropic SDK rejects
non-streaming requests whose `max_tokens` implies a completion longer
than ten minutes. But a nil cap makes fantasy's Anthropic provider
silently default to 4096 output tokens, and adaptive-thinking Claude
models can spend that entire budget on a thinking block, leaving zero
summary text.

## Fix

- Stream the compaction summary request. Streaming lifts the Anthropic
SDK's non-streaming duration restriction, which was the only reason the
cap was nil'd.
- Keep the resolved output cap (32k default) on the summary call instead
of nil'ing it.
- When the summary comes back empty with truncation evidence (length
finish reason, or reasoning with no text), fail with `compaction summary
was truncated at the output token cap` instead of the generic
empty-summary error, so the next occurrence is attributable at a glance.

Unit tests cover text-block joining and the truncation classification;
the compaction e2e fixtures now serve streamed summaries and assert the
summary request streams with `max_tokens: 32000`. Dogfood UAT on a
deployment built from this branch verified manual compaction with Claude
Opus 5 (adaptive thinking, twice, with reload persistence) and an OpenAI
regression chat.

> 🤖 Opened by [Xum](https://mux.coder.com) on behalf of @ibetitsmike.
2026-09-21 21:28:45 +02:00
Spike Curtis 8475a1defb refactor(coderd): enforce workspace template authz in singleWorkspaceData (#29665)
Part of the lite `codersdk.Workspace` work
([GRU-82](https://linear.app/codercom/issue/GRU-82),
[RFC](https://app.notion.com/p/coderhq/Lite-Workspace-API-Requests-3aad579be5928060b5e7cc65c539717f)).

`api.workspaceData` omits templates the actor cannot read and leaves
each caller to check `len(data.templates) == 0` and fail the request
itself. Now that `workspaceData` receives the `wsrelated.Config`, it
knows whether the template was requested, so the authorization check can
live closer to the data.

This adds `singleWorkspaceData`, a thin wrapper for single-workspace
fetches that returns `errWorkspaceTemplateUnauthorized` when the
template was requested but is absent (i.e. unreadable). The five
single-workspace callers route through it and map that error to the
response their endpoint requires:

- get workspace by ID → `403`
- get workspace by owner/name → `404` (preserves existence concealment)
- create/put workspace → `403`
- watch workspace (SSE) → forbidden error event

The batch `workspaceData` keeps its RBAC-filtering behavior so the
**list** endpoint can still skip workspaces whose template the actor
cannot read, rather than failing the whole request. Field selection
(`Config`) and authorization policy are kept separate: the strict check
is a property of the single-workspace wrapper, not of `All()`.

<details>
<summary>Design note</summary>

The check tests membership by the workspace's `TemplateID` rather than
only `len(templates) == 0`, and only real query failures (not RBAC
omissions) propagate as generic errors, so a genuine DB error is never
mistaken for an authorization denial.
</details>

### Testing

- New `TestSingleWorkspaceData` (mocked `database.Store`): template
readable, template requested-but-unauthorized (sentinel), template not
requested (no error), and a real query error (not the sentinel).
- Existing `TestWorkspace`, `TestWorkspaceByOwnerAndName`,
`TestWorkspaceWatcher`, and `TestWorkspaceIncludeRelated` pass
unchanged.

---

*Generated by Coder Agents on behalf of @spikecurtis.*
2026-09-21 21:06:06 +02:00
Michael Suchacz af0ef00f91 feat: add owner_id to CreateChatRequest to create chats for another user (#29581)
Owners and owner-level service accounts can now start a Coder Agents
chat on behalf of another user by setting `owner_id` on `POST
/api/v2/chats`. The field is optional and defaults to the caller, so
existing clients are unaffected. A delegated owner must be an active,
non-system member of the requested organization; anything else returns
400 `Chat owner must be an active member of the organization.` once the
caller has passed the authorization gates below.

A chat runs entirely with its owner's credentials (synthetic API key,
workspace access, OIDC and provider tokens), so creating one for someone
else is acting as that user. On top of org-scoped `chat:create` for the
owner, the caller must hold the authority to create API keys for that
user, which is what the token endpoint demands to mint their session.
Org admins therefore cannot use it; site owners and owner-role service
accounts can. For the same reason the workspace binding, model config,
and MCP server IDs are validated as the owner rather than the caller,
and the owner must themselves hold `chat:create` (organization service
accounts do not). The initial user message is attributed to the caller
through `chatd.CreateOptions.CreatedBy`.

An earlier revision of this PR exposed the same behavior as `POST
/api/v2/users/{user}/chats`; that route and
`codersdk.Client.CreateUserChat` were removed in `62a8be3dd32` in favor
of the request field. An explicit zero `owner_id` is rejected with 400
rather than silently defaulting to the caller. Coverage lives in
`TestPostChats_OwnerID`.

<details>
<summary>Review record (path-based revision, gates unchanged)</summary>

- Two-axis code review (Standards, Spec) plus a simplicity audit ran as
Xum sub-agents on `1f3189898f0`. The Spec axis found the workspace
binding was authorized as the caller, fixed in `363d45281d8` with
red-green coverage in `WorkspaceNotAccessibleToOwner`. The additional
API-key gate and the `CreatedBy` attribution go beyond the workspaces
pattern and were kept deliberately for the reasons above.
- Codex review on `363d45281d8`: one P2, suspended, dormant, or system
users could be targeted and would get a chat that can never run because
AI Bridge refuses to authorize them. Fixed in `c065437e359` with
`OwnerSuspended` (red on the old head); thread replied to and resolved.
- Codex review on `c065437e359`: one P2, an explicit or
personal-override model config the caller can read but the owner cannot
was accepted and chatd would silently fall back to the default model at
run time. Fixed in `aa88b608182` by resolving the model config and MCP
server IDs under the owner's context, with
`ModelConfigNotAccessibleToOwner` (red on the old head); thread replied
to and resolved.
- Codex review on `aa88b608182`: one P2, an organization service account
(which deliberately holds no chat permissions) could be targeted because
the chat permission check ran as the caller. Fixed in `a6fe8075c30` by
also requiring the owner subject to hold `chat:create`, with
`OwnerWithoutChatPermission` (red on the old head); thread replied to
and resolved.
- Codex review on `a6fe8075c30`: one P2, the active/non-system check was
skipped when the caller could not read the owner's user object. Fixed in
`0dd8bb4dd44` by moving the check behind the authorization gates with a
system-restricted lookup; thread replied to and resolved. In
`62a8be3dd32` that lookup became a single `OrganizationMembers` query,
which also covers membership and excludes system and deleted users.
- Codex review on `62a8be3dd32` (the `owner_id` revision): two P2s. An
explicit zero `owner_id` was treated as omitted and created the chat for
the caller; fixed in `f54b4f33d36` with a 400 and `OwnerIDNil` (red on
the old head). Creation and the read-back still ran as the caller while
the preflight ran as the owner; fixed in the same commit by passing
`ownerCtx` to `CreateChat`, `GetChatByID`, title generation, and the
file-metadata fetch. That second scenario is unreachable today (only the
built-in `owner` role holds `api_key:create` for others, and site-wide
custom roles are refused by both the API and dbauthz), so it has no
dedicated red test. Both threads replied to and resolved.
</details>

<details>
<summary>Remote UAT record (path-based revision)</summary>

Remote UAT on dogfood (chat `d7442df3-693f-4403-805f-2de52f7bdbed`, Xum
sub-agent as critical runner) tested head `21ed6b389cc`, the last
path-based revision. Licensed dev server, real Haiku 4.5 model, 77
logged API requests, 23 inspected screenshots. Endorsed verdict:
**PASS**. Site owner creates a chat for member X: X sees it, gets real
answers to the admin prompt and to follow-ups, and state survives reload
and mid-response refresh. The creating admin gets `403 Only the chat
owner may send messages.` and a read-only view; an unrelated member gets
404. Org admin, member, user-admin, and template-admin callers get 403;
owner-role service account 201. Suspended, dormant, and service-account
targets 400; owner-inaccessible workspace, model config, or MCP server
400; 300 KiB body 413. The `owner_id` revision changes only how the
owner is supplied and the non-member response (400 instead of 404); the
authorization and eligibility gates it exercised are unchanged and
covered by `TestPostChats_OwnerID`.

Non-blocking findings for the author's judgment, none of them
regressions of this PR:
1. X's UI shows no author on the admin-written first message and offers
X "Edit" on it; `created_by` carries the admin but the frontend does not
surface it.
2. A site owner who is not a member of the organization can still create
a chat for its members (201), while a self-owned `POST /chats` returns
403 for the same organization; same asymmetry as `postUserWorkspaces`.
3. The creating admin can archive, rename, and interrupt X's chat
although it cannot message it (pre-existing chat authz).
4. Owner-inaccessible model config or MCP server is reported as "not
found or disabled" with no hint that the owner, not the caller, lacks
access.
5. Dormant (never logged in) targets are refused because AI Bridge
rejects non-active users; a new hire cannot be given a chat until first
login.
6. The endpoint docs list only 201 and 413.
</details>

> Xum (an AI agent) acted on behalf of @ibetitsmike for this PR.
2026-09-21 20:49:10 +02:00
Mathias Fredriksson cd2481615d fix(coderd/x/chatd): clarify chat delegation ownership (#29041)
The delegation guidance encouraged parallel activity without defining
ownership between the parent and child, and corrections default to
queued delivery, so a parent could keep working against an assignment
the child had not received.

Give each delegated task one owner. The parent continues independent
work, waits with wait_agent when its next step depends on the child's
result, and treats the report's findings as read context. Corrections
and handoffs interrupt; a handoff is acknowledged only by the child's
response through wait_agent. Agent selection stays in the spawn
description instead of a second copy in planning guidance. Wording only;
tool arguments and execution behavior are unchanged.

Refs CODAGT-1079
2026-09-21 18:20:22 +00:00
Mathias Fredriksson 297a55051b fix: make Terraform fixture generation predictable (#29481)
`make gen` could regenerate every Terraform fixture during unrelated
work because the installed CLI differed from `version.txt`, or because
the provider-version check failed.

`make gen` now compares the generator, fixture sources, provider lock,
and mise’s Terraform pin against a committed record. Changed inputs
trigger regeneration; a different installed executable or checkout
timestamps do not. Terraform runs in a temporary directory, and outputs
are copied back only after generation succeeds. Shared CI checks the
record and conversion behavior without regenerating Terraform fixtures.

Fixes CODAGT-1082
2026-09-21 19:49:33 +03:00
Michael Suchacz a970c6c92e fix: list one Unknown AI Gateway client for missing and literal values (#29635)
`ListAIBridgeClients` grouped by the raw `client` column while selecting
`COALESCE(client, 'Unknown')`, so interceptions with no client and
interceptions whose client is literally `Unknown` produced two identical
`Unknown` entries in the client filter. Group by the coalesced value
instead.

## Validation

`go test ./enterprise/coderd -run '^TestAIBridgeListClients$'` (adds an
interception with a literal `Unknown` client and expects a single
entry), `make gen` with no drift (regenerates `queries.sql.go` and
`querier.go`).

Split out of #28964, where the spend page's client filter surfaced it.

> Xum prepared this PR on behalf of @ibetitsmike.
2026-09-21 18:03:22 +02:00
Michael Suchacz 988520477e feat!: remove the experimental chat API mounts after the transition window (#29548)
Remove the `/api/experimental` duplicates of the promoted chat API.
#28496 double-mounted the chat, organization chat and MCP server, member
model-override, AI provider key, and MCP OAuth2 disconnect routes under
both prefixes for the one-release compatibility window decided in
CODAGT-921; that window closed with v2.37.0, so these routes now answer
only on `/api/v2`. The change also deletes what existed only for the
dual mount: the `chatAPIPrefix` plumbing, the shared cross-prefix files
rate limiter (`RateLimitByAPICompatibilityEndpoint`), the 410 tombstones
for the legacy `chats/providers` and `chats/user-provider-configs`
collections with their `ExperimentalClient` SDK methods, and the
`/providers` and `/user-provider-configs` 404 reservations on `/api/v2`.
Signed chat file download URLs now point at `/api/v2`.

Routes that were never promoted stay on `/api/experimental`: the
experiment-gated `chats/config/advisor` and
`chats/config/computer-use-provider`, `chats/{chat}/stream/desktop`,
`chats/{chat}/debug/runs`, and the MCP OAuth2 callback, whose path is
pinned as a registered redirect URI with external providers. The
frontend already calls `/api/v2` for every promoted route, so only
`typesGenerated.ts` changes. Because the experimental mount no longer
reserves the removed collection segments, requests such as `GET
/api/experimental/chats/models` now fall into the `{chat}` wildcard and
return 400 instead of 404; the experimental prefix carries no stability
guarantee and the compatibility window is over, so no new reservations
were added.

`coderd/x/chatd/ARCHITECTURE.md` now describes the single `/api/v2`
mount and the remaining experimental routes, and its endpoint headings
use the `/api/v2` paths.

Closes CODAGT-922
(https://linear.app/codercom/issue/CODAGT-922/remove-experimental-chats-api-paths-after-transition-window).
Refs #28496.

## Delivery record

- Remote dogfood UAT (Coder Agents chat
https://dogfood.cdr.dev/agents/c016b549-201a-4eca-a50f-3c0b7c339db6):
verdict PASS on b008976a4dfba3524b220ca846ea3c3492e9cc9c. The branch was
since rebased onto main (which had a duplicate migration 000596 until
#29568) and gained one docs-only commit
(`coderd/x/chatd/ARCHITECTURE.md` only); the current head 666332f579
carries the same code diff, so the tested branch code is unchanged.
Covered the Agents UI end to end on `/api/v2` (chat, streaming reply,
reload mid-stream, file upload and download, debug runs panel), the
admin AI settings pages with persisted saves, 45 curl route checks
across both prefixes, websocket handshakes, the frozen MCP callback
redirect URI, and the files rate limiter. One low-severity note: the
400-versus-404 behavior for removed experimental collection paths
described above.
- Codex review on b008976a4d (draft marked ready): no findings. Codex
review on the current head 666332f579 (requested via `@codex review`):
one P1 thread asking for TODO markers instead of the direct
`ARCHITECTURE.md` edit; replied and resolved because the PR author
reviewed the earlier TODO markers and directed this replacement text. No
unresolved threads. CI is green on 666332f579 (run 35376339802;
`test-go-pg-17` passed on rerun after a Docker Hub timeout in
`TestSSH_Container/OK`).

> [!NOTE]
> Xum acted on @ibetitsmike's behalf in this pull request.
2026-09-21 17:42:31 +02:00
Jeremy Ruppel 30bf9027d2 fix(site): keep template build error visible (#29670) 2026-09-21 11:38:30 -04:00
Andrew Aquino 5a13b22cc1 chore: bump cdr.dev/slog/v3 to v3.2.0 (#29600)
## What

Bumps `cdr.dev/slog/v3` from `v3.1.0` to `v3.2.0`.

## Why

`v3.2.0` adds the flight recorder (`Logger.FlightRecorder(size)` /
`Logger.Flush(ctx)`), the shared primitive behind the connection-log RFC
requirement that clients and agents buffer sub-threshold logs in memory
and emit them on connection failure. Landing the version bump on its own
unblocks the two independent consumers:

- CLIENT-672: agent log buffering
- CLI-4: CLI log buffering

Keeping the bump as its own small PR lets those two consumers proceed
and merge in any order.

## Changes

- `go.mod` / `go.sum`: `cdr.dev/slog/v3 v3.1.0 -> v3.2.0`. No code
changes; the new API is additive.

slog release: https://github.com/coder/slog/releases/tag/v3.2.0

---
<sub>Opened by Coder Agents on behalf of @aqandrew.</sub>
2026-09-21 08:22:09 -07:00
Jake Howell 9a65e8f0e5 chore(docs): update ws-proxy-picker.png (#29651)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Replaces `ws-proxy-picker.png` with a 896px preview of the current
Workspace Proxies settings page
(`UserSettingsPage/WorkspaceProxyPage/WorkspaceProxyView`), using the
same `MockWorkspaceProxies` fixture data as its Storybook story. The old
image showed the previous admin Deployment layout with a separate URL
column, badge-style statuses, and full sidebar chrome.

Image-only change; no docs text or paths were modified. Referenced once,
from `docs/admin/networking/workspace-proxies.md` under "Selecting a
proxy".

| Old | New |
|---|---|
| <img width="448" alt="ws-proxy-picker (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/admin/networking/workspace-proxies/ws-proxy-picker.png"
/> | <img width="448" alt="ws-proxy-picker (new)"
src="https://raw.githubusercontent.com/coder/coder/refs/heads/jakehwll/docs-ws-proxy-picker/docs/images/admin/networking/workspace-proxies/ws-proxy-picker.png"
/> |

<details>
<summary>Verification</summary>

- Header text, "View docs" link, and the Proxy / Status / Latency
columns match `WorkspaceProxyView.tsx`; URL-as-subtitle, dot-style
status indicators, `N ms` / "Not available" latency, and the Errors /
Warnings blocks match `WorkspaceProxyRow.tsx`.
- Fixture data only (`dev.coder.com`, `*.fly.dev.coder.com`,
`127.0.0.1:3001`), identical to the old image. No real deployment URLs
or users.

</details>
2026-09-22 01:19:09 +10:00
Jake Howell 113667470d chore(docs): update autostart.png and autostop.png (#29650)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Replaces the autostart and autostop screenshots under
`docs/images/workspaces/` with previews of the current workspace
schedule form. The old images showed the previous MUI-based form
(different toggle and input styling, Sunday-first day order).

Image-only change; no docs text or paths were modified. Both are
referenced from `docs/user-guides/workspace-scheduling.md`.

| Old | New |
|---|---|
| <img width="448" alt="autostart (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/workspaces/autostart.png"
/> | <img width="448" alt="autostart (new)"
src="https://raw.githubusercontent.com/coder/coder/refs/heads/jakehwll/docs-workspaces-autostartstop/docs/images/workspaces/autostart.png"
/> |
| <img width="448" alt="autostop (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/workspaces/autostop.png"
/> | <img width="448" alt="autostop (new)"
src="https://raw.githubusercontent.com/coder/coder/refs/heads/jakehwll/docs-workspaces-autostartstop/docs/images/workspaces/autostop.png"
/> |

<details>
<summary>Verification</summary>

- Labels match
`site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceScheduleForm.tsx`:
"Enable Autostart", "Start time", "Timezone", "Days of Week" with Mon
through Sun ordering, "Enable Autostop", "Time until shutdown (hours)",
and the `ttlShutdownAt` helper text.
- No user names, emails, or deployment URLs visible.

</details>
2026-09-21 14:50:10 +00:00
Michael Suchacz c1b3ee7895 fix: select an AI Gateway client only on an exact match (#29636)
`useClientFilterMenu` resolved the selected option by searching clients
with `q: value` and taking the first result, so with no value selected
(or a prefix that matches another client) the filter displayed a client
that was never chosen. Require the first result to equal the value.

Split out of #28964, where the spend page rendered the filter with no
selection and showed the first client as selected.

> Xum prepared this PR on behalf of @ibetitsmike.
2026-09-21 16:44:16 +02:00
Paweł Banaszewski f69f545429 chore: clean up ChatProviderAPIKeysFromDeploymentValues (#29666)
Removes not needed `ChatProviderAPIKeysFromDeploymentValues` function.
2026-09-21 16:40:35 +02:00
Jake Howell f3cfd8bddc chore(docs): remove unused images (#29647)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Removes 73 files (72 PNGs and 1 MP4, about 12 MiB) under `docs/images/`
that nothing references anymore. Most are older screenshots superseded
when docs were reorganized and new images were added at new paths (for
example `guides/using-organizations/` vs the current
`admin/users/organizations/`), leaving the originals orphaned.

Pure deletion, no markdown or manifest changes. This covers every
unreferenced raster asset under `docs/images/`. 22 unreferenced SVGs
remain (`icons/*.svg`, `google-cloud.svg`, `oidc-sequence-diagram.svg`)
and are out of scope here; `icons/` is consumed via `manifest.json`
`icon_path` entries rather than markdown, so those warrant a separate
look.

<details>
<summary>Verification</summary>

- Searched the whole repo (not just `docs/`) for every deleted file by
full path, docs-relative path, and basename (case-insensitive): zero
references. All basename hits resolve to different, still-present files
that share a name at another path.
- `docs/manifest.json`, root `README.md`, `site/`, and `offlinedocs/`
were included in the search.
- GitHub code search across the `coder` org for links to the deleted
directories (this repo uses
`raw.githubusercontent.com/coder/coder/.../docs/images/...` URLs for
media, so external consumers are possible): no live consumers. The only
hits are a vendored docs snapshot in `coder/coder-k8s` under
`.mux/skills/coder-docs/references/`, which is stale by design.
- CI: `check-docs` (linkspector), `lint-docs`, and `offlinedocs` pass.

</details>
2026-09-22 00:40:06 +10:00
Jake Howell 84f790bd32 chore(docs): new notifications images (#29649)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Replaces the two notification preference screenshots under
`docs/images/admin/monitoring/notifications/` with Figma-exported
previews in the same 896px style as #29455 and #29648, reflecting the
current UI. The old shots predated the Events / Settings /
Troubleshooting tabs on the admin page and the AI Cost Control and Chat
event groups, and the old user-preferences shot included a real user's
name and email in the sidebar.

Image-only change; no docs text or paths were modified. Both are
referenced from `docs/admin/monitoring/notifications/index.md`. Files
are 25-60% smaller.

| Old | New |
|---|---|
| <img width="448" alt="notification-admin-prefs (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/admin/monitoring/notifications/notification-admin-prefs.png"
/> | <img width="448" alt="notification-admin-prefs (new)"
src="https://raw.githubusercontent.com/coder/coder/12b31d278358d2f0a6af1028792b72b366e8e1d4/docs/images/admin/monitoring/notifications/notification-admin-prefs.png"
/> |
| <img width="448" alt="user-notification-preferences (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/admin/monitoring/notifications/user-notification-preferences.png"
/> | <img width="448" alt="user-notification-preferences (new)"
src="https://raw.githubusercontent.com/coder/coder/12b31d278358d2f0a6af1028792b72b366e8e1d4/docs/images/admin/monitoring/notifications/user-notification-preferences.png"
/> |

<details>
<summary>Verification</summary>

- Page copy and tabs match
`site/src/pages/DeploymentSettingsPage/NotificationsPage/NotificationsPage.tsx`
and
`site/src/pages/UserSettingsPage/NotificationsPage/NotificationsPage.tsx`.
- Event groups and template names (AI Cost Control Admin Events, AI Cost
Control Events, Chat Events, Missing AI Model Prices, User
Approaching/Reached AI Budget Limit, AI Budget Limit Reached, AI Budget
Warning) match the notification template migrations.
- The user-preferences image still shows a per-template delivery method
icon on the right, which the docs text above it refers to.
- No user names, emails, or deployment URLs visible.

</details>
2026-09-22 00:22:47 +10:00
Jake Howell 57e8fd14b2 chore(docs): new licensing images (#29648)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Replaces the three screenshots under `docs/images/admin/licenses/` with
Figma-exported previews in the same 896px style as #29455, reflecting
the current Licenses UI. The old `licenses-screen.png` predated the
Products / Add-ons license card (Coder Workspaces, Coder Agents, AI
Governance).

Image-only change; no docs text or paths were modified. Referenced from
`docs/admin/licensing/index.md` and `docs/tutorials/faqs.md`. Files are
40-60% smaller and no longer carry EXIF metadata.

| Old | New |
|---|---|
| <img width="448" alt="licenses-screen (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/admin/licenses/licenses-screen.png"
/> | <img width="448" alt="licenses-screen (new)"
src="https://raw.githubusercontent.com/coder/coder/1a18a0ee925d12cecfb1e2cee5e37b22602a3629/docs/images/admin/licenses/licenses-screen.png"
/> |
| <img width="448" alt="licenses-nolicense (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/admin/licenses/licenses-nolicense.png"
/> | <img width="448" alt="licenses-nolicense (new)"
src="https://raw.githubusercontent.com/coder/coder/1a18a0ee925d12cecfb1e2cee5e37b22602a3629/docs/images/admin/licenses/licenses-nolicense.png"
/> |
| <img width="448" alt="add-license-ui (old)"
src="https://raw.githubusercontent.com/coder/coder/53ad29512def2e562f41fc17509508896980605e/docs/images/admin/licenses/add-license-ui.png"
/> | <img width="448" alt="add-license-ui (new)"
src="https://raw.githubusercontent.com/coder/coder/1a18a0ee925d12cecfb1e2cee5e37b22602a3629/docs/images/admin/licenses/add-license-ui.png"
/> |

<details>
<summary>Verification</summary>

- Every visible label in the new images maps to a current string in
`site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/`
(`LicenseCard.tsx`, `LicensesSettingsPageView.tsx`,
`AddNewLicensePageView.tsx`, `CoderWorkspacesProductCard.tsx`,
`CoderAgentsProductCard.tsx`).
- Mock license data only: license #26, 64/100 seats, valid August 27,
2024 to August 27, 2027. No license key, deployment ID, or email
visible.
- Dimensions 896x512 / 896x352 / 896x512, matching the
`docs/images/screenshots/` convention from #29455.

</details>
2026-09-22 00:21:59 +10:00
Nick Vigilante 6a060b22a0 ci: map changed docs images to pages in docs-preview (#28415)
## Problem

The `docs-preview` workflow only inspected changed **Markdown** files. A
PR that changes only images under `docs/images/` (for example a
screenshot refresh with no `.md` edits) produced **no preview comment at
all**: the changed-files list was filtered to `^docs/.*\.md$`, so an
image-only PR fell through to `cleanup_stale_and_exit` and posted
nothing.

Motivating example: #28356 changed 6 screenshots under `docs/images/`
with zero Markdown changes, so reviewers got no preview link to see the
new images in context.

## Change

- Map each changed image to the docs pages that embed it, and render a
nested list in the comment: every changed image, then each page that
references it, each with its own preview link.
- An image that no navigable page embeds (an icon wired only into
`docs/manifest.json`'s `icon_path`, or an image referenced only from a
non-navigable page) is still listed on its own line with no sub-links,
so a screenshot- or icon-only PR always posts a comment.
- Image references in docs are **relative** Markdown
(`![](../images/…)`) and HTML (`<img src="…">`) at varying `../` depths.
Resolving them needs each page's directory, so the job now checks out
the PR head (`actions/checkout`, commit-pinned, `persist-credentials:
false`, `sparse-checkout: docs` since `docs/` is the only tree it reads)
and resolves refs against the working tree. External `<img>` URLs are
ignored.
- The manifest read moves from the contents API to reading
`docs/manifest.json` from the checkout (the now-unused `HEAD_SHA` env is
dropped). A page is still only linked if it has a `docs/manifest.json`
route, so image sub-links never point at un-navigable pages.
- The image section is **informational (no checkboxes)**. The pages
themselves did not change, so the checklist's reset-on-change contract
does not apply. Sub-links deliberately use ` - [` + a code span (no `[
]` glyph) so the existing checkbox-state parser cannot pick them up, and
the hidden state marker is unchanged.
- Bounded by `IMAGE_SECTION_BUDGET` (20000) and `IMAGE_PAGES_MAX` (25)
so the always-rendered section stays under GitHub's comment size limit.
Image extensions matched: `png|jpe?g|gif|svg|webp|avif|bmp|ico`
(case-insensitive); `mp4` is excluded (video, not image).
- The PR's changed-file list is fetched once and filtered into the
Markdown and image sets from the same payload, rather than paginating
the same endpoint twice.

## Example rendered section (paths illustrative)

The comment gains a section that renders like this:

```
#### Changed images

These images changed. Each is listed with the navigable page(s) that embed it, so you can open the preview and see the new image in context. An image with no page listed isn't embedded by any navigable docs page. These links are informational and have no review checkboxes.

- `docs/images/user-guides/desktop/coder-desktop-mac.png`
  - [`docs/user-guides/desktop/index.md`](https://coder.com/docs/@my-branch/user-guides/desktop)
- `docs/images/templates/icons.png`
  - [`docs/admin/templates/managing-templates/index.md`](https://coder.com/docs/@my-branch/admin/templates/managing-templates)
  - [`docs/tutorials/best-practices/index.md`](https://coder.com/docs/@my-branch/tutorials/best-practices)
- `docs/images/icons/cloud.svg`
```

A shared image lists every page that embeds it; a page with no manifest
route is dropped, and an image that no navigable page embeds (like the
icon above) is listed on its own with no sub-links.

## Testing

- `.github/workflows/test-docs-preview-mapper.sh` passes (50 cases),
covering image extraction (every matched extension, plus
`extract_ref_tokens` and `resolve_ref` branch cases), relative-ref
resolution, page grouping (including an image with no embedding page),
section rendering with exact overflow counts, an icon-only comment, and
a guard that image sub-links do not pollute checkbox-state recovery.
- `actionlint` (with embedded shellcheck) on the workflow; `shellcheck`
and `shfmt -d` on the test script; `typos`; `scripts/check_emdash.sh`.
All clean.
- End-to-end sanity check against the current repo for #28356's images:
the nested links resolve to the embedding, manifest-routed pages.

## Follow-up

`test-docs-preview-mapper.sh` is not yet invoked by any CI job. The
script exists but nothing runs it, so a regression in this logic would
not be caught automatically. That is a pre-existing gap (it predates
this PR) and is tracked separately in DOCS-689; it is intentionally left
out here to keep this diff focused.

## CI notes

<details>
<summary>Initial CI red was a transient Go module-proxy flake (green
after re-run)</summary>

The first run of this commit had `gen`, `test-go-pg (ubuntu-latest)`,
and `test-go-race-pg` fail with `stream error: ... INTERNAL_ERROR;
received from peer` while fetching modules from `proxy.golang.org` (e.g.
`go-openapi/swag`, `coder/serpent`, `unrolled/secure`), so the Go builds
hit `[setup failed]` before any test ran. `test-go-pg` on macOS and
Windows passed in the same run. This PR only touches
`.github/workflows/` (no Go, `go.mod`, or `go.sum`), so it cannot cause
module-download failures. Re-running the failed jobs cleared it; all
checks are now green.
</details>

Linear: DOCS-687

> This PR was created with AI assistance (Coder Agents).
2026-09-21 10:12:08 -04:00
Michael Suchacz 2bf0f567d8 feat: add OpenAI Pro reasoning mode to chat model configs (#29584)
Adds `provider_options.openai.reasoning_mode` (`pro`) to chat model
configs so admins can turn on OpenAI's Pro reasoning mode for a model,
alongside the other OpenAI request options on the model form such as
`service_tier`. The field is offered for any model on an OpenAI
provider; the field description says Pro is supported from the GPT-5.6
Sol generation and that requests fail when Pro is set on a model that
does not support it. There is deliberately no supported-model list
anywhere: a newly released model that supports Pro works with no code
change, and OpenAI rejects the request when the model does not.
Validation rejects only values other than `pro`, non-OpenAI providers,
and configs that explicitly force plain sampling
(`reasoning_model=false`) or Chat Completions
(`use_responses_api=false`), including partial updates that move a
configured model onto such a provider or transport.

A configured mode implies the Responses API and reasoning-model
treatment when `openai_config` leaves those unset
(`chatprovider.effectiveOpenAIConfig`), so an alias the pinned SDK has
never seen, such as `gpt-daybreak-blue-latest`, still gets `effort` and
`summary` and drops `temperature`. The same effective config feeds the
client options and the recorded transport, so the two cannot disagree.

The pinned fantasy OpenAI provider options do not carry
`reasoning.mode`, so the mode is applied as a client-scoped `openai-go`
request option when the model client is built rather than per call. The
SDK merges pre-serialization `WithJSONSet` overlays by top-level key, so
the key is escaped (`reasoning\.mode`) to add `mode` to the existing
`reasoning` object instead of replacing `effort` and `summary`.
`TestResolveModelCallReasoningModeWire` pins the resulting request body
for streaming and non-streaming calls and checks that the fixed
computer-use model does not inherit the mode; AI Gateway forwarding of
the `reasoning` object is covered in `aibridge`. Because the option is
bound to the model client, every call made through a Pro model config
carries it, including title generation and quick generation when those
fall back to the chat's model; deployments that want cheaper auxiliary
calls should point the title generation override at another model.

Frontend: the field renders through the existing schema-driven provider
options with no hand-written field logic. Two generic changes:
`visible_for_providers` is now honored for provider fields the way it
already was for general fields (render and payload), so the
OpenAI-scoped select does not appear or serialize for Azure, which
shares the OpenAI field group; and the add/update model save toasts now
carry the server's error detail, so a rejected combination such as Pro
with Use Responses API at Off tells the admin which field to change.

Docs: `docs/ai-coder/agents/models.md` gains a Reasoning Mode row in the
OpenAI provider-specific options table (from the documentation check
comment
https://github.com/coder/coder/pull/29584#issuecomment-5752457808), and
its Azure note now says Azure OpenAI lacks that one option.

Not changed: `coderd/x/chatd/ARCHITECTURE.md`. Its OpenAI transport
selection table needs a `reasoning_mode` row (client-applied, neither
transport) to match `TestProviderOptionsTransportParity`; left for the
human author.

<details>
<summary>Delivery record</summary>

- Local validation on every pushed head: targeted Go tests (chatopenai,
chatprovider, chatd wire test, aibridge integration test, coderd DB
tests for persistence, invalid input, and partial updates), red/green on
the wire test (injection removed, and unescaped key), Vitest
(`modelConfigFormLogic`, `ModelForm`), Storybook tests for
`ModelFormProviderConfig`, biome, tsc, oxlint, golangci-lint on touched
packages, pre-commit hook.
- Codex round 1 on `e7dbaefeafc`: 3 findings (Storybook assertions,
ARCHITECTURE.md TODO, `gpt-daybreak-blue-latest` alias). Disposition:
assertions moved to Vitest and alias accepted in `8fccf111111`;
ARCHITECTURE.md left untouched by author instruction. Threads replied to
and resolved.
- Codex round 2 on `8fccf111111`: 1 finding (fixture naming, FE9),
renamed in `23449e92317`. Round 3 on `23449e92317`: 1 finding (fixture
location, FE9), moved to `testHelpers/chatModels.ts` in `c3bd5aa370f`.
Round 4 on `c3bd5aa370f`: "Didn't find any major issues"
(https://github.com/coder/coder/pull/29584#issuecomment-5735119236). All
threads resolved.
- Remote UAT round 1 (chat
https://dogfood.cdr.dev/agents/f5ed1d16-be1d-4d39-952b-126a6a829ef1)
exercised `e7dbaefeafc`: endorsed PASS. Real `gpt-5.6-sol` turns showed
`"mode": "pro"` / `"standard"` / no key in the Debug tab with effort and
summary intact; 14 POST and 6 PATCH rejections captured; UI select
visibility, persistence, reload, and clearing verified. Low,
non-blocking notes: the `gpt-5.6` alias revert in the model identifier
field is pre-existing; Pro is dropped silently when a model or transport
change makes it unsupported; Pro applies to auxiliary calls (see above).
- Remote UAT round 2 on `c3bd5aa370f` (same chat, alias and core
re-verify): core PASS, alias FAIL. With `gpt-daybreak-blue-latest` the
request carried `{"mode": "pro"}` without the configured effort and
summary and kept sending `temperature` (provider 400 then retry on quick
generation and title calls), because the SDK does not classify the alias
as a reasoning model. Fixed in `d4c338de767`: a configured mode now
implies a reasoning model unless `openai_config.reasoning_model` is set,
and a mode on a config that forces plain sampling is rejected. Alias
UI/API behavior, rejections, and known-model Pro/Default turns all
passed on `c3bd5aa370f`.
- Codex round 5 on `d4c338de767`: "Didn't find any major issues"
(https://github.com/coder/coder/pull/29584#issuecomment-5736190356).
Zero unresolved threads. CI green on `d4c338de767`.
- Remote UAT round 3 on `d4c338de767` (same chat): endorsed PASS. Alias
runs are single-attempt 200s with `{"effort", "summary", "mode": "pro"}`
and no `temperature` (quick generation and title calls no longer retry);
`reasoning_model=false` plus a mode is rejected by POST and PATCH with
the stored config unchanged; the Reasoning Model override at Off hides
the select and drops the mode on save; `gpt-5.6-sol` Pro turn unchanged.
Remaining low notes, none introduced here: rejection detail for a
non-OpenAI provider names the model rather than the provider; Pro is
dropped silently when an override makes it unsupported; `PATCH
model_config` replaces the whole object (pre-existing on main).

- coder-frontend-review on `d4c338de767` (8 role reviewers, 3 passes):
13 failing checkpoints, chiefly a TS mirror of the Go model regex, the
`json_name === "reasoning_mode"` gate duplicated in the render filter
and payload builder, a defaulted `model` parameter, and comment and type
nits. Fixed in `554c90d5fd9`: the pattern and provider scope are
generated onto the field schema, one predicate is shared by both call
sites, `buildModelConfigFromForm(provider, model, form)` requires the
model, and the ModelForm test also asserts the select disappears for an
unsupported model. Red/green: stripping `supported_models` or
`visible_for_providers` from the generated schema fails 21 and 1 Vitest
cases respectively. Declined with rationale: RO4 (move the fixture to
`ModelsPage/testFixtures.ts`; FE9 in `FRONTEND_PATTERNS.md` names
`testHelpers/chatModels.ts`, and Codex round 3 required it) and a DF5
nit to gate on the committed identifier and warn when a saved mode is
dropped (behavior change, separate follow-up). Final pass: all
checkpoints PASS or N/A.
- Remote UAT round 4 on `554c90d5fd9` (same chat, focused regression
after the frontend-review refactor): endorsed PASS. All six claims held
(Pro round trip with effort and tier intact; unsupported identifiers
hide the select and a save drops the stale mode while keeping the other
options; Azure never shows or saves it; the alias shows it only with the
Responses override On; Reasoning Model Off hides it and drops it; three
real `gpt-5.6-sol` Pro turns were single-attempt 200s with
`{"effort","summary","mode":"pro"}` and no `temperature`). Probes aimed
at the refactor also passed: `gpt-5X6-sol` is rejected (dot escaping
survived the JSON round trip), whitespace-padded identifiers still
match, the other 11 OpenAI fields and the Anthropic section still
render. Remaining low notes are carried over from round 3 plus one
naming note ("Reasoning Mode" versus "Reasoning Model"). The final head
`abb58df77d8` differs from `554c90d5fd9` only in `ModelForm.test.tsx`,
so it ships the same production code.
- Codex round 6 on `554c90d5fd9`: 1 finding
(https://github.com/coder/coder/pull/29584#pullrequestreview-5260492465):
the two `toBeInTheDocument` assertions added in the frontend-review
round violate FE1. Confirmed against `site/AGENTS.md`; removed in
`abb58df77d8` (test-only, 7 deletions; the payload assertion keeps the
behavior coverage and the `ProviderConfigOpenAI` story captures the
hidden state). Thread replied to and resolved.
- Codex round 7 on `abb58df77d8`: "Didn't find any major issues"
(https://github.com/coder/coder/pull/29584#issuecomment-5749626071).
Zero unresolved threads. CI green on `abb58df77d8` (23 success, 8
skipped, `required` pass).

- Design change on `e99152e5c57` (owner direction: no model gating;
"none or pro" for any model; tooltip states the GPT-5.6 Sol constraint
and that requests fail on unsupported models). Removed
`codersdk.ChatModelReasoningModeModels`, the generated
`supported_models`, `isFieldApplicableToModel`, the
`gpt-daybreak-blue-latest` special case, and the `standard` enum value;
`ValidateReasoningMode(provider, config)` no longer takes the model;
`effectiveOpenAIConfig` makes a mode imply Responses and reasoning-model
treatment. PR footprint went from +1130/-22 to +769/-18. Local
validation: `go test` for chatopenai, chatprovider, chatd wire test, and
the coderd API tests (persistence now covers `gpt-5.6-sol`, `gpt-4o`,
`gpt-daybreak-blue-latest`, `gpt-7-nova`; invalid input now rejects
`standard`), golangci-lint on touched packages, Vitest (187 tests across
`modules/aiModels` and `ModelsPage`), biome, tsc, pre-commit hook.
- coder-frontend-review on `e99152e5c57` (8 roles, 1 pass plus a TS and
CD confirmation pass): 9 failing checkpoints (SD4, CD1, CD3, CD4, TS3,
TS7 x2, RO3, RO5, TN4, DF5). Fixed in `e06bfbe4299`: the ModelForm test
edits `mockGPT5` so its provider matches the selected provider state,
types the update mock like the sibling story, and drops an unused route;
the story spreads `mockGPT5` with a saved mode instead of a dedicated
shared fixture (`MockGPT56Pro` removed, `testHelpers/chatModels.ts` back
to base); a `ProviderConfigAzure` story captures the panel without
`reasoning_mode`; comment nits. Left as a nit with justification: RO3
(the one-line `!hidden && isFieldVisibleForProvider` predicate now
appears in both `getVisibleProviderFields` and
`getVisibleGeneralFields`; hoisting a helper for two call sites is not
worth it). Confirmation pass: TS all PASS; CD flagged one wording nit,
fixed before commit.
- CI green on `e06bfbe4299` (23 success, 8 skipped, `required` pass).
- Codex round 8 on `e06bfbe4299`: 1 P2 finding
(https://github.com/coder/coder/pull/29584#discussion_r4057659673): the
form still offers Pro with Use Responses API or Reasoning Model at Off,
a combination the server rejects, and the failure was not actionable.
Disposition: the select stays visible by owner direction (no client-side
gating of this field beyond the provider scope; an explicit rejection is
preferred over the earlier silent drop), and `e2b43c3aee7` makes the
add/update save toasts show the server detail so the admin sees which
field to change. Thread replied to and resolved; zero unresolved
threads.
- Remote UAT round 5 on `e06bfbe4299` (same chat): endorsed PASS with
two UI issues to land before release. All seven probes passed: the
select offers only Default and Pro for `gpt-5.6-sol` and `gpt-4o` with
the tooltip text verbatim; Pro saves on `gpt-4o` and the real turn fails
visibly with the provider's "reasoning.mode is not supported with this
model" after a single 400 attempt, and works again once Pro is cleared;
`gpt-daybreak-blue-latest` with Pro and no overrides is a single 200 to
`/v1/responses` with `{effort, summary, mode: "pro"}` and no
`temperature`; the `gpt-5.6-sol` Pro turn is unchanged; POST and PATCH
reject `standard`, `PRO`, empty, Responses Off, Reasoning Model Off, and
Azure, openai-compat, and Anthropic providers with the stored config
unchanged, while a model-only PATCH to `gpt-4o` now succeeds; the Azure
form shows no Reasoning Mode; the alias with an explicit Responses
override still works. Reservations: (1) medium, the UI conflict path
only showed "Invalid model config." without the detail (fixed in
`e2b43c3aee7`, not yet UAT-exercised); (2) low-medium, a dev-DB row
still holding `standard` from round 2 renders an empty red select whose
message is the whole field description plus "has an invalid value." and
blocks saving unrelated fields (pre-existing generic behavior of
`yupTestForField` using the description as the label; no released data
can hold `standard`, so no migration); (3) low, no hint next to older
identifiers (documented design); (4) low, a chat on such a stored row
fails with a generic headline (pre-existing).
- Final head `e2b43c3aee7` differs from `e06bfbe4299` only in the two
save-toast handlers (`AddModelPage.tsx`, `UpdateModelPage.tsx`, 8
insertions). CI is green on `e2b43c3aee7` (skipped=8, success=23,
`required` success). Codex has not run on `e2b43c3aee7`.
- Remote UAT round 6 on `e2b43c3aee7` (same chat,
https://dogfood.cdr.dev/agents/f5ed1d16-be1d-4d39-952b-126a6a829ef1,
settled 2026-09-20T19:02Z): endorsed PASS on the exact final head. Build
proven by `/api/v2/buildinfo` (`v2.37.2-devel+e2b43c3aee`,
`external_url` at the full SHA) and the UI badge. The round 5 toast
issue is resolved: Add and Update saves with Pro plus Use Responses API
Off or Reasoning Model Off show "Invalid model config." with the server
detail as the description, one 400 each, nothing stored. Compact
regression of every round 5 probe held (dropdown and tooltip; Pro on
`gpt-4o` fails visibly with the provider's `reasoning.mode is not
supported with this model` and works after clearing; alias with and
without the Responses override and `gpt-5.6-sol` all send `{effort,
summary, mode: "pro"}` with no `temperature` in a single 200; POST and
PATCH rejection matrices with stored config unchanged; Azure form
without the field). Legacy `standard` row: fails closed on chat, and
re-picking Pro or Default saves. Remaining notes, none blocking: the
malformed validation copy for an invalid stored enum (pre-existing
`yupTestForField` label choice, dev-DB rows only), Pro offered for
models that cannot accept it (documented design), and a pre-existing
`quickgen` status quirk on `gpt-4o` unrelated to this field. Secret scan
clean.
- Final head `4f3c6106dfe` adds one docs-only commit on top of
`e2b43c3aee7` (`docs/ai-coder/agents/models.md`, 9 insertions, 8
deletions, no code). Remote UAT round 6 exercised `e2b43c3aee7`; the
docs commit is not UAT-relevant. Validated with
`markdown-table-formatter`, `markdownlint-cli2`, and the pre-commit hook
(`fmt/markdown`, `lint/markdown`, `lint/emdash`, `lint/typos`). CI is
green on `4f3c6106dfe` (success=24, skipped=7, `required` success) and
the documentation check re-run marked its item addressed
(https://github.com/coder/coder/pull/29584#issuecomment-5752457808).
- Review tally for this PR: Codex 8 completed rounds;
coder-frontend-review 34 role passes (24 on `d4c338de767`, 10 on
`e99152e5c57`); remote UAT 5 rounds; no human review yet. This is far
past the six-review guardrail, so no further Codex or agent review has
been requested. Whether to spend another Codex pass on `e2b43c3aee7` is
an owner decision; human review is still required before merge.

</details>

> Xum acted on behalf of @ibetitsmike.
2026-09-21 15:58:18 +02:00
Danielle Maywood 97ba9c0fbb chore: enable consistent-type-definitions oxlint rule (#29566) 2026-09-21 14:56:32 +01:00
Michael Suchacz 157477e3c5 fix!: remove obsolete managed agent limit license warning (#29657)
## Summary

Deployments that used the legacy Tasks (managed agents) feature in the
past keep seeing the license banner "You have built more workspaces with
managed agents than your license allows." even after installing a
freshly generated license. This removes that warning at its source,
along with its dashboard-only link mapping and stories.

## Why the banner is obsolete

- The warning was appended in `enterprise/coderd/license/license.go`
whenever `managedAgentCount >= limit` for the `managed_agent_limit`
feature.
- The count comes from `GetTotalUsageDCManagedAgentsV1`, which sums
historical `dc_managed_agents_v1` usage events. The only emitter of
those events (the `has_ai_task` start-build path) was removed in #29085,
so nothing produces them anymore and the count can never decrease.
- Premium licenses without an explicit claim get a grandfathered
`managed_agent_limit` default with a usage period spanning decades, so a
deployment that ever exceeded that count keeps the warning forever,
regardless of license renewal.

## What changed

- `enterprise/coderd/license/license.go`: stop appending the warning.
The feature still measures and reports `Actual` for the licenses page.
- `codersdk/licenses.go` and `site/src/api/typesGenerated.ts`: delete
the `LicenseManagedAgentLimitExceededWarningText` constant. This is the
breaking part of the change for external `codersdk` consumers, hence the
`!` in the title.
- `site/src/modules/dashboard/LicenseBanner/`: remove the "View AI
Governance" link mapping and the two stories that rendered the obsolete
message.
- Tests: the two cases that asserted the warning now assert no warning
while `Actual` is still reported. The existing `AgentRuntimeHours/*`
cases keep covering the Coder Agent runtime hours warnings unchanged.

The Coder Agents `agent_runtime_hours` warnings (`hb_agent_runtime_v1`
usage) are unchanged. The `managed_agent_limit` feature, its usage
query, and the `dc_managed_agents_v1` event type are intentionally kept
so that existing licenses and historical reporting keep working.

## Validation

- `go test ./enterprise/coderd/license/`
- `pnpm exec tsc --noEmit` and `biome check` on the touched frontend
files
- Repository pre-commit hook

> Xum acted on behalf of Mike (@ibetitsmike) to prepare this pull
request.
2026-09-21 15:09:25 +02:00
Spike Curtis c5c7f9d8b2 fix(coderd): remove stale coderd/wsrelated import in test (#29655)
Fixes a broken `main`: `coderd/workspacebuilds_internal_test.go` had two
`wsrelated` imports after the stacked include_related PRs squash-merged.
The stale `github.com/coder/coder/v2/coderd/wsrelated` path no longer
exists (the package moved to `codersdk/wsrelated` in #29540), so the
`coderd` test package failed to compile.

Removes the dangling import; the file already imports the correct
`codersdk/wsrelated`.

### Verification

- `go build ./coderd/` and `go test ./coderd/ -run '^$'` (compile the
test package) both succeed.

---

*Generated by Coder Agents on behalf of @spikecurtis.*
2026-09-21 11:04:12 +00:00
Paweł Banaszewski 44eb71f922 chore: move aibridge proxy code and helpers to separate packages (#29573)
Move the stateless AI Gateway router into `aibridge/x/proxy`.
Extract shared routing helpers into `aibridge/routing` and move provider
and recorder helpers to their owning packages. Update callers and tests
without changing behavior.

Generated by Coder Agents.
2026-09-21 12:26:09 +02:00
Spike Curtis 9cea3d94a1 chore: narrow createworkspaces workspace fetch to agents (#29541)
Part of the lite `codersdk.Workspace` work
([GRU-82](https://linear.app/codercom/issue/GRU-82),
[RFC](https://app.notion.com/p/coderhq/Lite-Workspace-API-Requests-3aad579be5928060b5e7cc65c539717f)).
Stacked on #29540, which added `include_related` to
`codersdk.Client.Workspace`.

Narrows the first `client.Workspace` call site to exercise
`include_related` end to end.

In `scaletest/createworkspaces`, the fetched workspace is used only to
find the first agent (`workspace.LatestBuild.Resources` -> `Agents`,
reading `agent.ID`); no template, job, template version, apps, scripts,
log sources, or metadata are read. The call now requests exactly
`latest_build.resources.agents` via `wsrelated.Config`, so the load test
stops fetching data it discards.

### Testing

`Test_Runner` provisions workspaces with agents and drives agent
connections, so it covers the agent-finding path with the narrowed
selection.

---

*Generated by Coder Agents on behalf of @spikecurtis.*
2026-09-21 11:54:10 +02:00
Spike Curtis 9a29aab2ee feat: add include_related option to client.Workspace in codersdk (#29540)
Part of the lite `codersdk.Workspace` work
([GRU-82](https://linear.app/codercom/issue/GRU-82),
[RFC](https://app.notion.com/p/coderhq/Lite-Workspace-API-Requests-3aad579be5928060b5e7cc65c539717f)).
Stacked on #29539, which wired `include_related` into `GET
/api/v2/workspaces/{workspace}`.

Adds `include_related` support to the `codersdk` client, expressed with
the typed selection tree so only supported selections are representable:

- Moves the `wsrelated` package from `coderd/` to `codersdk/` so both
the server and the client can share `wsrelated.Config`. `coderd` already
depends on `codersdk`, so this only changes import paths on the server
side.
- Adds `Config.QueryParam`, which encodes a selection into the
`include_related` value: the dotted path of each selected node that has
no selected descendants. Selecting a node implies its ancestors, so
`Parse` round-trips the result back into an equal `Config` (covered by a
round-trip test).
- `WorkspaceOptions` gains `IncludeRelated *wsrelated.Config`. A nil
value omits the parameter (server returns everything, unchanged); a
non-nil value is encoded via `QueryParam`, and a zero `Config` loads
only the workspace.
- `Client.Workspace` now accepts optional `WorkspaceOptions`, backward
compatible with existing `client.Workspace(ctx, id)` calls.

### Testing

- `codersdk` internal test asserts `WorkspaceOptions.asRequestOption`
sets `include_related` from the selection, following the existing
`WorkspaceFilter` test pattern rather than spinning up a server.
- `wsrelated` tests cover `QueryParam` output and a `Parse`/`QueryParam`
round trip.

`make gen` regenerated the `WorkspaceOptions` TypeScript type. Because
the wire representation of `include_related` is a comma-separated
string, `scripts/apitypings` maps `wsrelated.Config` to `string` in
TypeScript, so `include_related?: string` rather than a nested object
the frontend cannot serialize. `api.getWorkspace` already forwards
`WorkspaceOptions` as query params, and a frontend test in `api.test.ts`
confirms `include_related` is sent through.

---

*Generated by Coder Agents on behalf of @spikecurtis.*
2026-09-21 11:53:11 +02:00
Spike Curtis 29ae50d9c9 feat: accept include_related query param on get workspace by ID (#29539)
Part of the lite `codersdk.Workspace` work
([GRU-82](https://linear.app/codercom/issue/GRU-82),
[RFC](https://app.notion.com/p/coderhq/Lite-Workspace-API-Requests-3aad579be5928060b5e7cc65c539717f)).
Follows #28639, which added the `wsrelated` package and parser.

Wires the `include_related` query parameter into `GET
/api/v2/workspaces/{workspace}`, the first endpoint to accept it. When
present, the value is parsed with `wsrelated.Parse` and the resulting
selection is threaded into `workspaceData`, so only the requested
related data is queried. Omitting the parameter is backward compatible
and returns everything (`wsrelated.All`). An invalid value returns
`400`.

Because related data can now be omitted, the handler no longer assumes
the build and template are present: it uses zero values when they are
absent, and only enforces the template read-authorization check (`403`)
when the template was actually requested.

### Partial-build conversion

`convertWorkspaceBuilds` now tolerates a build whose provisioner job or
template version was deliberately omitted from the selection, so
selections such as `latest_build` (build only) or
`latest_build.resources.*` (resources without the job) convert correctly
instead of erroring. The omitted fields are left zero (empty `Job`,
empty `TemplateVersionName`). Resources are keyed by the build's `JobID`
rather than the fetched job row, so they load independently of whether
the job is selected. The integrity error is preserved for full-data
callers: when a job or template version is requested but missing,
conversion still fails. The selection config (`wsrelated.LatestBuild`)
is threaded into `convertWorkspaceBuilds` to distinguish "not requested"
from "missing".

Only this endpoint is wired; the other endpoints that produce
`codersdk.Workspace` objects, and the codersdk client functions, come in
later PRs.

---

*Generated by Coder Agents on behalf of @spikecurtis.*
2026-09-21 10:50:01 +02:00
Susana Ferreira 839be9dc7b feat: generate AI Gateway metrics (#29184)
## Description

Generate AI Gateway metrics from source instead of maintaining their
definitions manually in the static metrics file.

Existing metrics are preserved and 29 AI Gateway metrics are now
generated automatically.

Timing comparison against #29183, using medians of five runs:

- Scanner: **0.276s before → 0.279s after**.
- `make scripts/metricsdocgen/generated_metrics`: **1.171s before →
1.187s after**.
- Full stack compared with main: scanner **0.270s → 0.279s** and forced
`make` **1.203s → 1.187s**.

## Changes

- Scan `aibridge/` and the previously excluded AI Gateway metric files
using the directory-prefix mappings.
- Extract labels built with `append(baseLabels, ...)`.
- Remove the 29 verified AI Gateway definitions from the static file and
retain other static metrics and override behavior.
- Document the manual prefix mapping maintenance requirements.

Closes https://linear.app/codercom/issue/AIGOV-561

> [!NOTE]
> Generated by Coder Agents on behalf of @ssncferreira.
2026-09-21 09:33:33 +01:00
Susana Ferreira 1590f6ccad feat: map metric prefixes by directory (#29183)
## Description

Apply registration prefixes using four explicit directory mappings
instead of tracing registerers across function calls. Metric definitions
remain automatically extracted, while prefixes are maintained manually.

Generated metrics and the final documentation are unchanged.

Timing comparison against main, using medians of five runs:

- Scanner: **0.270s before → 0.276s after**.
- `make scripts/metricsdocgen/generated_metrics`: **1.203s before →
1.171s after**.

## Changes

- Keep four directory mappings and their lookup alongside the scanner
configuration.
- Apply the longest matching directory rule, including subdirectories.
- Explain when mappings need updating and add a TODO for automatic
prefix discovery.

Refs https://linear.app/codercom/issue/AIGOV-561

> [!NOTE]
> Generated by Coder Agents on behalf of @ssncferreira.
2026-09-21 09:33:32 +01:00
Michael Suchacz 53ad29512d fix: route chat quickgen side calls through the title generation model (#29622)
Chat sublabels were falling back to "Finished latest turn" for most
turns on some models. On dogfood, 95% of Claude Fable 5.1 chats over the
last 7 days showed the fallback (341/357) while Opus 4.8 sat at 3%. The
end-of-turn status label and the whole-chat summary were generated on
the chat's own model, and Anthropic rejects the forced tool call that
Fantasy's object generation relies on with `400 tool_choice: type "tool"
and "any" are not supported for this model.` on every `claude-fable-5-1`
request (about 3k such 400s in 7 days). OpenAI-compatible reasoning
models such as solstice-1 fail the same call differently, answering with
text at the 64-token cap. Title generation kept working because it
already resolves a dedicated model: the organization `title_generation`
override (Haiku 4.5 on dogfood), then a preferred small model, then the
chat model. The failures were only visible at Debug level.

Route every quickgen side call (turn status label, chat summary,
automatic and manual title) through one shared resolver,
`resolveQuickgenModel`, with that same order: `title_generation`
override, then an enabled preferred small model, then the chat's model
as a last resort. The preferred-model match now also accepts dated
snapshot IDs such as `claude-haiku-4-5-20251001`, which is how admins
commonly configure Haiku. Candidate failures for labels, summaries, and
titles are logged at Warn with provider and model. The admin settings
copy and the models doc now say that the title generation override also
governs status labels and summaries.

Known tradeoff: when the resolved quickgen model itself is unusable at
call time (for example an invalid provider key on the small model), the
side calls fail and the generic label is shown; there is deliberately no
second call on the chat's model.

Refs
https://linear.app/codercom/issue/CODAGT-1077/fix-agent-turn-status-label-generation-failures

## Delivery record

- Remote dogfood UAT, Coder Agents chat
https://dogfood.cdr.dev/agents/87bab92b-bd54-4d5c-aba2-8147eaedfa49
(real Anthropic and OpenAI models through the dev AI gateway, UI driven
through Playwright). Round 1 on b4cc6fc336: FAIL, a dated Haiku config
(`claude-haiku-4-5-20251001`) did not match the preferred-model list, so
labels still fell back to Fable; fixed in cb5f0e0eaf. Round 2 on
cb5f0e0eaf: PASS (override set, override cleared with the dated Haiku
config, single-model fallback, auto and manual titles, summary
regeneration, Warn logging, plus edge cases). Later heads add only UI
copy, docs, and a Storybook play-function cleanup on top of the
UAT-tested SHA and were not re-exercised remotely.
- Codex review: pass 1 on 0ec37f6492 raised one P1 (assertions inside a
Storybook play function), fixed in 409eac5211 and the thread resolved;
pass 2 on 409eac5211: "Didn't find any major issues", zero unresolved
threads. CI green on 409eac5211.

> Xum (an AI coding agent) authored this PR on behalf of @ibetitsmike.
2026-09-20 23:18:12 +02:00
Ben Potter 854bd610f0 fix(site): preserve agent send shortcuts in narrow viewports (#29613)
Enter and Cmd/Ctrl+Enter inserted newlines instead of sending when the
Coder Agents window was narrower than 640px. This broke desktop split
views even with the Cmd/Ctrl+Enter preference enabled.

Use pointer capability instead of window width for touch keyboard
behavior. Narrow desktop windows respect the send preference,
Cmd/Ctrl+Enter works at every width, and Shift+Enter still inserts a
newline.

Fixes #28438. Refs
[CODAGT-1006](https://linear.app/codercom/issue/CODAGT-1006).

Tested on web (macOS/Chrome):


https://github.com/user-attachments/assets/10e3fc49-d5b5-4438-96b8-5fe740b6acbb

Tested on iOS:



https://github.com/user-attachments/assets/0a3844f8-721a-469e-a822-7e8ea89586d9



<details>
<summary>Implementation and verification notes</summary>

The change is limited to the shared composer Enter handler, its existing
tests, and the mobile composer story. Plain Enter inserts a newline when
the primary pointer is coarse, including on larger touch devices.
Cmd/Ctrl+Enter bypasses that check. Pointer capability is a proxy for
touch input, not a physical-keyboard detector.

Regression tests reproduced the bug before the fix. All 87 targeted unit
tests and 99 composer stories pass, along with frontend formatting,
lint, typechecking, and the full make pre-commit checks. Browser checks
confirmed submit callbacks at 390px and 1280px with both send
preferences and touch emulation. A dev-instance chat also completed
through dogfood AI Gateway.

The related queue-button work in #29507 is not a dependency.

</details>

Generated by Coder Agents on behalf of @bpmct.
2026-09-20 10:13:32 -05:00
Jake Howell 9661661ba6 chore(site): prune dead animations and name the spinner leaf animation (#29619)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Two commits.

**1. Prune dead animations.** `@keyframes caret-scan` /
`--animate-caret-scan` and `@keyframes zip-right` /
`--animate-zip-right` had no consumers, so Tailwind was already dropping
them. Both animated `left`/`width`, so they were layout-thrashing
templates waiting to be copied.

**2. Name the spinner leaf animation.** The surviving keyframes were
called `loading` and were driven by an arbitrary
`animate-[loading_0.8s_ease-in-out_infinite]` utility plus a `// 0.8 =
leaves * 0.1` comment, while the `--animate-loading` theme token sat
unused with stale `2s … alternate` timing. Now:

- `@keyframes loading` → `@keyframes spinner-leaf-fade`, named for what
it does.
- `--animate-spinner-leaf` derives both the cycle and the per-leaf delay
from the leaf count, so the wave stays seamless if the count changes.
- `Spinner` applies `animate-spinner-leaf` and passes only
`--spinner-leaf-index` and `--spinner-leaf-count`; no arbitrary value,
no hand-computed delay, no magic `0.8`.
2026-09-20 21:35:31 +10:00
Atif Ali ac40e59907 chore(site): add OpenRouter provider icon (#29558)
## Problem

OpenRouter is a supported provider type (AI Bridge, AI settings, model
selectors), but it had no icon. Everywhere else shows a provider logo,
OpenRouter fell back to the generic `Building2` glyph (or a question
mark in AI Bridge), which looks like a broken or unknown provider.

## Fix

Added the OpenRouter logo from [Simple
Icons](https://github.com/simple-icons/simple-icons/blob/develop/icons/openrouter.svg)
and wired it into both provider icon maps.

| File | Change |
|---|---|
| `site/static/icon/openrouter.svg` | New asset, path coordinates baked
into the repo's 256x256 viewBox with a white fill, matching
`anthropic.svg` |
| `site/src/modules/aiModels/ProviderIcon.tsx` | Map `openrouter` to the
new icon |
| `site/src/pages/AIBridgePage/icons/AIBridgeProviderIcon.tsx` | Same
mapping for the AI Bridge provider icon |
| `site/src/theme/externalImages.ts` | Register as `monochrome` so it
adapts to light and dark themes |
| `site/src/theme/icons.json` | Regenerated with `make
site/src/theme/icons.json` |
| `site/src/modules/aiModels/ProviderIcon.stories.tsx` | Add an
`OpenRouter` story, drop OpenRouter from the fallback comment |

Provider labels already existed in `formatProviderLabel` and
`addableProviderTypes`, so only the icon was missing.

## Validation

- Rendered the icon in headless Chromium on dark and light backgrounds
with the light-theme monochrome filter applied, to confirm geometry and
contrast.
- Audited all 148 icons in `site/static/icon`: every one uses a `0 0 256
256` viewBox, and 145 now carry baked coordinates with no geometry
transform. The upstream 24x24 path was scaled into 256 space so this
icon follows that convention rather than relying on a wrapper `scale()`.
The baked version renders byte-identical to the transform-based version.
- `pnpm exec tsc --noEmit`: clean
- `pnpm exec biome check` on the touched directories: clean
- `pnpm exec vitest run --project unit src/modules/aiModels
src/pages/AIBridgePage/utils.test.ts`: 185 passed

> 🤖 This PR was created with the help of Coder Agents, and needs a human
review. 🧑‍💻
2026-09-20 12:55:52 +05:00
Ben Potter 38a17ec002 fix(site/src/pages/AgentsPage): size embedded agent chat to viewport (#29602)
Embedded agent chats in fixed-height iframes, including the chat panel
on `prototypes.cdr.dev`, grew to the transcript height and left the
composer clipped below the viewport.

The embed route rendered directly under block-level `#root`, so the chat
view's `flex-1` and `min-h-0` did not constrain it. Add the missing
full-height flex column around the route outlet, size the chat view to
its parent, and add a 412px-tall Storybook state for visual regression
coverage. The embed also waits for permissions before mounting
`DashboardProvider`, preventing dev-proxy loads from crashing while the
permissions query is still pending.

## Screenshots

Live dogfood transcript content is redacted.

![Before and after embedded agent
chat](https://raw.githubusercontent.com/coder/coder/recordings/recordings/agent-embed-chat-height/comparison.png)

<details>
<summary>Individual screenshots</summary>

### Before

![Embedded agent chat before the
fix](https://raw.githubusercontent.com/coder/coder/recordings/recordings/agent-embed-chat-height/before.png)

### After

![Embedded agent chat after the
fix](https://raw.githubusercontent.com/coder/coder/recordings/recordings/agent-embed-chat-height/after.png)

</details>

## Compiled bundle measurements

| Context | Bundle | Document height | Document scroll | Outer view |
Message scroller | Composer bottom |
|---|---:|---:|---:|---:|---:|---:|
| Direct, 900x740 | Before | 1686px | 806px | 1686px | None | 864px,
124px clipped |
| Direct, 900x740 | After | 740px | 0px | 740px | 534px / 1417px |
724px, 16px clear |
| Iframe, 900x412 | Before | 1686px | 1134px | 1686px | None | 536px,
124px clipped |
| Iframe, 900x412 | After | 412px | 0px | 412px | 206px / 1417px |
396px, 16px clear |

<details>
<summary>Verification</summary>

- Ran the real Vite frontend from `origin/main` and this branch against
an authenticated dogfood session on separate ports.
- Loaded the embed route directly at 900x740 and through a fixed-height
iframe harness served from a different port.
- Sampled document scrolling, outer view height, transcript scrolling,
and composer position at 0.2s, 1s, 3s, and 8s.
- Confirmed the standalone block-parent reproduction scrolls the
document in the broken state and moves overflow into the transcript
after adding a full-height child.
- Added and visually inspected the `EmbeddedViewport` Storybook state.
- `pnpm test:storybook
src/pages/AgentsPage/AgentChatPageView.stories.tsx`: 66 passed.
- `pnpm check`, `pnpm lint`, and `pnpm lint:types` passed. Biome reports
one existing informational finding in `OAuth2AppForm.test.tsx`.
- Repository pre-commit hook passed.
- Repository pre-push hook passed with `VITEST_MAX_WORKERS=1`: 3656
passed, 2 skipped, and the production site build passed.

</details>

🤖 Generated with Coder Agents.
2026-09-19 18:18:29 -05:00
Michael Suchacz a698b026fe fix(aibridge): relay Responses SSE events unless tools are injected (#29580) 2026-09-19 09:02:55 +02:00
Jake Howell 403ba01161 refactor(site/src/pages/AgentsPage): extract chat send pipeline from AgentChatPage (#29160)
Move composer content building, slash-command intercept, edit-model
override, and send/queue upsert out of AgentChatPage into function
modules so the page is easier to navigate.
2026-09-19 06:30:27 +00:00
Ehab Younes 9974294ca9 feat: report arbitrary workspace agent session types (#28338)
Report session counts as a dynamic app-name map from the agent, the SSH CLI, and the workspace usage API, so a new IDE flows end to end without a schema, proto, or server change.

- Report through `Stats.session_counts` on Agent API v2.11. Older agents keep reporting through the deprecated count fields.
- Accept arbitrary names from `coder ssh --usage-app` and the workspace usage API. A name the registry does not recognize keeps its identity and is attributed to the `unknown` family.
- Add reconnecting PTY counts to the map without overwriting the counts SSH reported.
- Normalize and merge names before applying the deterministic 64-name cap, ordered by known apps, then count, then name. Overflow sums into `unknown`, and non-positive counts cannot cancel valid activity.
- Strip control characters, treat whitespace-only HTTP app names as absent, and require the exact environment variable prefix when you extract an SSH session type.
- Count overflow entries in `coderd_agentstats_session_counts_overflow_total` and keep raw payloads out of logs.
- Change the usage API's `app_name` to a string, and update the SDK types and API reference.

closes #27410
2026-09-19 00:32:51 +02:00
Michael Suchacz cc8c76651e fix: use workspaces when chat capabilities are insufficient (#29579)
Chatd's guidance discouraged workspace creation even when the chat
lacked the tools or context needed to finish a request. Make a suitable
workspace the fallback when missing tools, skills, MCPs, or context
block progress, while preferring existing capabilities when sufficient.

Align the system prompt, workspace awareness, planning guidance, tool
description, regression tests, and user documentation. Preserve
template-selection guardrails and delegated-agent restrictions.

**Open review finding:** workspace readiness can precede initial
MCP/context discovery. The wording now acknowledges this limitation; a
runtime synchronization fix is pending a scope decision.

<details>
<summary>Implementation and verification context</summary>

- Coding requests authorize necessary workspace setup without a separate
workspace request; self-contained examples remain workspace-free when
existing capabilities suffice.
- Detached root chats create a workspace; attached stopped workspaces
use start_workspace. Persisted awareness describes the initial state
rather than claiming the chat remains detached.
- Delegated chats report workspace needs to their parent. Provisioning
does not unlock workspace MCP tools in Plan Mode.
- Use actually exposed capabilities; do not assume readiness means all
skills, MCP tools, and context have loaded, or recreate workspaces to
retry discovery.
- Prompt, workspace-creation, template-selection, setup-failure, Plan
Mode MCP boundary, and API prompt-composition tests pass. The creation
E2E now verifies published instructions, skills, and MCP tools appear in
request two with no extra user turn; repeated and race runs pass. This
does not establish live-model compliance or discovery readiness.
- Full make pre-commit passes, including generation, formatting, lint,
and the slim build. All CI checks pass on f4f61333ce (23 passed, 8
skipped), and Codex reports no major issues on that commit.
- Codex review iterations corrected prompt/tool conflicts. The alleged
immutable-per-turn tool catalog was disproved by the per-task generation
lifecycle. The narrower initial-discovery race remains open: no existing
chatd-visible signal distinguishes pending discovery from completed
empty or failed discovery.

</details>

Generated by Coder Agents on behalf of @ibetitsmike.
2026-09-18 17:47:53 -04:00
Michael SuchaczandPaul Frybarger 19e2b0415a fix(coderd/x/chatd): preserve tool definitions during compaction (#29436)
Supersedes #28883 by @pfrybar. His commit is carried with authorship
intact (rebased onto main as 32d261f94f); the second commit adds the
overflow fallback found while testing it.

## Problem

Compaction rebuilt the summary request without the conversation's tool
definitions, so the summary prompt no longer shared the turn's prefix
and providers could not reuse the cached context (measurements in
#28883).

Sending the tools with the summary makes that request at least as large
as the generation it summarizes. At a model's real context window
(gpt-3.5-turbo-0125, 16385 tokens) the summary request was rejected with
`Your input exceeds the context window of this model.` on the same
overflow compaction exists to recover from. The chat stayed in `error`,
and both manual `/compact` and the automatic retrigger failed the same
way, so the chat was stuck.

## Fix

`generateCompactionSummary` sends the prepared tool definitions with the
summary request. When the provider rejects that request for size, it
regenerates the summary once without tools, which is the request shape
compaction used before and still fits whenever the history alone does.
The context-window check reuses fantasy's classification and also
matches bad-request wordings fantasy does not parse (OpenAI Responses
API, Anthropic, `context_length_exceeded`).

`BuildToolDefinitions` moves into its own file in `chatloop` so the turn
and the summary share one construction path.

On Anthropic the summary prompt now carries the same `cache_control`
breakpoints as the turn; without them Anthropic never reads the cache,
so the shared tool and history prefix would have been pure cost there. A
compaction override that resolves to a different model shares no prompt
cache and may not support the chat model's provider-native tools, so its
summary request carries no tool definitions; an override resolving to
the chat model itself keeps them. HTTP 413 counts as a size rejection
for the tool-less retry.

## Testing

- Unit:
`TestGenerateCompactionSummaryRetriesWithoutToolsWhenContextTooLarge`,
`TestGenerateCompactionSummaryDoesNotRetryOtherFailures`,
`TestGenerateCompactionSummaryAppliesAnthropicPromptCaching`,
`TestIsContextTooLargeError`, `TestBuildToolDefinitions*`.
- End to end: `TestActiveServer_ManualCompaction/retries the summary
without tools when the prompt exceeds the context window` asserts two
summary requests (with tools, then none), the chat returns to `waiting`
with `last_error` cleared, and the summary is persisted.
- Red-green: with the retry disabled the unit test fails on the returned
provider error and the e2e chat never leaves `error`; with the phrase
matching disabled the Responses, Anthropic, and error-code classifier
cases fail.

## Review record

- Local standards and spec review at 99f7e80a0a9 (pre-rebase content of
8799db2f0e): switched `errors.As` to `errors.AsType`, removed two
comments restating test names, trimmed the phrase list to
provider-attested wordings. Rebase onto main resolved one test-file
conflict (both sides deleted different tests) and inlined the
`chattest.AnthropicErrorResponse` helper that main removed in #29008.
- Codex round 1 on 8799db2f0e: one P1, parent tool definitions sent to
a compaction override on a different provider. Mechanism verified
partially (fantasy skips foreign provider-defined tools with a warning;
`web_search` translates across providers and schemas can be rejected).
Fixed in a7fa7a61e4 by dropping tool definitions when the override is a
separate provider instance, with a red-green case in
`TestActiveServer_CompactionModelOverride`. Thread resolved.
- Codex round 2 on a7fa7a61e4: P1 override tools should drop for any
different model (agreed, guard replaced by an unconditional drop); P2
HTTP 413 should take the tool-less retry (agreed); P2 Anthropic summary
request had no cache breakpoints so the tools bought no cache hit
(confirmed in code, matches earlier dogfood `cache_read=0`). All three
fixed in e7bd72390c with red-green unit and e2e assertions. Threads
resolved.
- Codex round 3 on e7bd72390c: P2 keep tools when the override resolves
to the chat model (agreed, fixed in 6d8d8d6f71 with a red-green e2e
case); P1 missing ARCHITECTURE.md TODO items for the changed compaction
flow (agreed, added in 6d8d8d6f71 per the chatd rule); P2 summary tool
set may differ from the triggering request after a `find_tools`
activation (mechanism confirmed, declined as a cache-efficiency edge
case with the overflow path covered by the retry). Threads resolved.
- Codex round 4 on 6d8d8d6f71: "Didn't find any major issues", reviewed
commit `6d8d8d6f71`, zero unresolved threads. CI green on the same head
(Storybook rerun once after Pixel returned HTTP 500 while uploading
snapshots; this branch has no `site/` changes).

> Xum, an AI coding agent, prepared this PR on behalf of @ibetitsmike.

---------

Co-authored-by: Paul Frybarger <pfrybar@frymail.net>
2026-09-18 23:19:00 +02:00
Bobby Ho 0a45c6214e feat(site): add a scope allowlist field to the OAuth2 app form (#29360)
Add an "Allowed scopes" picker to the OAuth2 app form.

- Populate a searchable multi-select from `/api/v2/auth/scopes` and submit selections as a space-separated `scope`.
- Preserve stored scopes, including those missing from the catalog. While loading or on failure, disable only the picker and keep existing scopes unchanged on save; allow retry after failures.
- Empty selections mean unrestricted access; existing unrestricted apps remain unchanged on save.
- Verified 32 manual scenarios across UI behavior, API scope handling, authorization enforcement, and DCR.

Part of [PLAT-475](https://linear.app/codercom/issue/PLAT-475). Depends on #29313 for API support.
2026-09-18 21:02:43 +00:00
McKayla はな f7c5df26ef refactor: use React.ComponentProps for element props (#29587) 2026-09-18 14:06:33 -06:00
Michael Suchacz ceed0df682 chore: add DeepSeek V4.1 Flash and other missed models to the known models catalog (#29585)
Add the models that landed on models.dev since the September 4 curation
pass (#28955), plus cross-provider gaps where a model was curated on one
provider but not on the others that serve it, so they appear as
suggestions when an admin adds a chat model in `/agents` settings.

| Model | Added to |
|---|---|
| GPT-6 Astra | azure, openrouter, vercel (already curated on openai) |
| Claude Mythos 5.1 | anthropic. Not on models.dev, so injected in
`overrides.jq` as a copy of `claude-fable-5-1`, mirroring the existing
`claude-mythos-5` injection. Anthropic's pricing page lists Mythos 5.1
at the same rates as Fable 5.1, including the reduced cache-read rate. |
| DeepSeek V4.1 Flash | openrouter, vercel |
| Gemini 3.8 / 3.7 / 3.6 Flash | openrouter, vercel (no Google models
were curated on either gateway) |
| Gemini 3.1 Pro Preview, Gemini Flash-Lite Latest, Gemini 3.5 Flash
Lite | google (the catalog had no Pro or Lite tier) |
| Claude Mythos 5 | azure (left pending in #28887) |
| Claude Opus 4.7 | azure, bedrock (plus `global.` alias), openrouter,
vercel |
| GPT-5.5, GPT-5.4 mini | openrouter, vercel |
| GPT-5.4, GPT-5.4 mini, GPT-5.3 Codex | azure |
| Grok 4.6, Qwen3.8 Flash, GLM 5.3 Flash, MiniMax M3, Kimi K2.7 Code |
openrouter, vercel |

Mythos 5.1 uses `reasoningEffort: high` like Fable 5.1 and is added to
the Anthropic thinking-mode pin in `knownModelsGenerated.test.ts`.
Gateway entries follow the existing convention: no reasoning default and
upstream display names. New entries sort ahead of the models they
supersede.

Deliberately not added: `openai.*` models on Bedrock (chatd's Bedrock
provider wraps the Anthropic client, so they cannot be used from Coder
Agents), models.dev's `~`-prefixed rolling aliases on OpenRouter, and
`copilot` (unsupported in chatd).

`knownModelsGenerated.json` and
`coderd/aibridge/prices/data/prices.json` are regenerated with `make
gen/aibridge-prices` from the same models.dev snapshot. Apart from the
`claude-mythos-5-1` row, the `prices.json` changes are upstream drift
since the last weekly refresh, the same content the scheduled refresh PR
would produce.

Validation: `go test ./scripts/aibridgepricesgen/...
./coderd/aibridge/prices/...` and `pnpm test src/modules/aiModels/` (174
tests) pass.

> Xum opened this PR on behalf of @ibetitsmike.
2026-09-18 21:04:59 +02:00
McKayla はな 98e1ec11bc refactor: use React.ComponentProps instead of ref-variant helpers (#29577) 2026-09-18 13:01:48 -06:00
Bobby Ho 55da502938 feat: allow admins to configure an OAuth2 app's scope allowlist (#29313)
Add backend support for scope allowlists on admin-created OAuth2 apps, previously available only through DCR.

- Add optional, space-separated `scope` to create/update requests and return canonicalized, deduplicated scopes in app responses.
- On create, omitted or empty `scope` means unrestricted. On update, `scope` replaces the allowlist; omission preserves it, and an empty string clears it to unrestricted.
- Keep scope enforcement unchanged. Add tests for scope round-trips, DCR canonicalization parity, and authorization narrowing.
- Include generated SDK and docs updates. The UI scope picker follows in a separate PR.

Part of [PLAT-475](https://linear.app/codercom/issue/PLAT-475).
2026-09-18 11:58:49 -07:00
McKayla はな 66a433985e feat: add user workspace search filter (#29442) 2026-09-18 12:57:21 -06:00
Callum Styan 057475c4e8 feat: control notification scaletest load via template deletion count (#29151) 2026-09-18 11:57:06 -07:00
Garrett Delfosse 8339cea84b fix(scripts/migrate-test): correct direction in migration mismatch hint (#29572)
`make test-migrations` migrates from the current ref (the release
branch) to `origin/main`. When it fails, the hint told you every
migration in `main` must exist in the release branch, which is
backwards. The check actually requires that every migration in the
release branch also exists in `main` with the same number.

Swaps the version arguments so the hint describes the real requirement.

---
Generated by Coder Agents on behalf of @f0ssel.
2026-09-18 14:28:38 -04:00