mirror of
https://github.com/coder/coder.git
synced 2026-11-28 00:39:06 +08:00
34ef30ee90271258f18a080b008cc368f736ab80
17408
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
34ef30ee90 | fix: harden chat workspace file upload input validation (#30184) | ||
|
|
81c40579dc |
feat: enable Coder.StepLength Vale rule (#30791)
Adds `Coder.StepLength`, a Vale `script` rule for [Keep steps short](https://github.com/coder/coder/blob/main/docs/.style/style-guide/procedural-writing.md#keep-steps-short). It flags an ordered-list step whose instruction, the step's first paragraph, has more than 20 words, counted as [How to count words](https://github.com/coder/coder/blob/main/docs/.style/style-guide/voice-and-tone.md#how-to-count-words) describes. Paragraphs below the instruction explain the step and aren't counted. - Severity: `warning`. - Scope: `docs/**` except `docs/.style/style-guide/**`. - Baseline: 124 findings in 60 hand-written files. The cleanup shortens each long instruction, moves its explanation into one paragraph below it, or splits a step that holds several actions. After cleanup `vale docs/` reports 0 `Coder.StepLength` findings, and the other rules report no new findings on the changed files. - The guide section now says the limit covers the instruction, and that one action or one explanation must not be broken across paragraphs to meet it. - Generated pages (`docs/reference/{api,cli,agent-api}`, `configuration-reference.md`, `prometheus.md`): no findings, so no `.vale.ini` exclusion is needed. Linear: DOCS-1272 <details><summary>Decision log</summary> **Review change (Ian's review)** - The first version limited every paragraph of a step to 20 words. The cleanup for it chopped explanations into several short paragraphs, which made steps harder to read and sometimes changed their meaning. - The rule now counts only the first paragraph segment of each step. The content files were reset to `main` and the cleanup was redone against the narrower rule. - Cleanup preferences, in order: shorten the instruction; keep a short instruction and put the explanation, with its original wording, in one paragraph below it; split a step into one step for each action; for descriptive lists (such as "How it works"), keep each item one statement. - `docs/admin/users/oidc-auth/microsoft.md` keeps the split into separate steps, with Ian's wording suggestions applied. "click" became "select" in step 16 because `Coder.SelectClick` flags it. **Rule shape** - A `script` rule (Tengo) with `scope: raw`, because the count depends on Markdown structure that per-paragraph scopes hide. - A step is an ordered-list item with a `1.` or `1)` marker. A nested ordered item is its own step. Bullets, even under a step, are not steps. - The instruction ends at a blank line, a fence, a nested list, a table row, a blockquote, block-level HTML, or an explicit hard break (`<br>`, a trailing backslash, or two trailing spaces). - Fenced code blocks, HTML comments, tables, images, and nested bullets add no words. - CRLF: `\r` counts as whitespace, and offsets come from the raw text. **Counting approximations (also in the rule header)** - A code span and a `**bold**` or `__bold__` span are one word each. - Words split on whitespace, so a hyphenated compound and `30 seconds` are one word. - Link text counts word by word, destinations are skipped, images add no words, and `<https://...>` autolinks are one word. - A token with no letter or digit, such as the `>` in `**A** > **B**`, is not a word. - Tengo indexes strings by rune but measures them in bytes, so the script rewrites each non-ASCII rune to ASCII of the same byte length first. **Tests** (fixtures under `/tmp/sltest/`, not committed; run with the repo `.vale.ini`, LF and CRLF) - Flagged: a long instruction, a short action and a long result in one paragraph, a long nested ordered step. - Not flagged: a long paragraph below a short instruction, text after a `<br>` hard break, a long paragraph after a code block, a long nested bullet. - LF and CRLF output is identical. - Pre-commit hooks (`fmt/markdown`, `lint/markdown`, `lint/emdash`, `lint/style-claims`, `lint/typos`) pass. - Not run on Windows or macOS. The rule is plain text processing, and the CRLF cases simulate Windows line endings on Linux. </details> *Generated by [Coder Agents](https://coder.com/docs/ai-coder/agents) on behalf of @nickvigilante.* |
||
|
|
1aff810443 |
chore: sync fantasy with upstream v0.45.5 (#31288)
Moves the fantasy pin to the tip of `coder_2_33` (`85ffbbe`). That commit is coder/fantasy#72, which merges 87 upstream charmbracelet/fantasy commits, v0.40.0 to v0.45.5. Between the two pins 117 files change. Upstream's own v0.40.0 to v0.45.5 change, without tests, testdata, examples, `go.sum` and the kronk provider, is 43 files, +2271/−928. ## What reaches chatd chatd builds only the `anthropic`, `openai` and `openaicompat` fantasy clients (`chatprovider.ModelFromConfig`); other vendors reach it through the AI Gateway on one of those. So the upstream changes to the Google, Vercel, OpenRouter, Bedrock, Azure and kronk providers, and to the `fantasy.Agent` loop and its retries, do not run in chatd. These do: - **Chat Completions and openaicompat streams** keep reasoning on batched and DeepSeek-shaped chunks, keep `finish_reason: length` when tool calls are truncated, and stop sending empty reasoning fields. openaicompat drops assistant turns that hold only reasoning. - **Token usage.** When an OpenAI-shaped backend reports reasoning tokens apart from completion tokens (reasoning larger than output), output tokens now include them, so that backend's reported output tokens and cost rise. OpenAI's own shape, where reasoning is a subset, is unchanged. - **Responses.** A content-filtered turn no longer reads as a tool-call turn. - **Context overflow.** Baseten, Fireworks and Parasail prompt-length errors set `ContextTooLargeErr`, which compaction acts on. - **Anthropic.** Tool calls whose content block never closes are reported. For Claude 5 models, thinking defaults to `display: "summarized"` when the chat config sets none; a configured display still wins. `TestThinkingDropBlockModel_RetriesWithEffort` now expects the field in the retry body. - **Anthropic keepalives.** Fantasy forwards `message_start`, `message_delta` and unknown events as content-free `keepalive` parts. The first one arrives before any model output, so this PR makes `ttft_seconds` and the `time_to_first_token` stage skip them, as they skip warnings. They still reset the stream silence guard. `processStepStream` ignores them, and the debug recorder counts them in its part count but records no content. - **Tool-result media** now goes through upstream's shared `ToolRunBuffer`, which replaces coder/fantasy#64 and does the same thing. #72 keeps coder's anthropic-sdk-go and openai-go forks, Go 1.26 and kronk v1.31.5, so upstream's SDK and Go moves do not come along. `go mod tidy` raises the modules fantasy v0.45.5 requires, among them otel exporters v1.47, the AWS SDK, `google.golang.org/api` v0.307 and go-openapi v1. All are upgrades. The `go.mod` comment now names #72 as the upstream sync. coder/coder#29861 stacks on this PR to pin coder/fantasy#62. <details> <summary>Verification</summary> - `go build ./...`. - `go test` passes on every package that imports fantasy (`coderd/x/chatd/...`), and `go test ./coderd -run 'TestChat|TestExpChat|TestMCP|TestAIBridge'` passes. - `TestGuardedStreamTTFTStage/WarningsAndKeepalivesThenContentObservesOnce` fails without the TTFT change (TTFT observed 0s instead of 1s) and passes with it. - `make pre-commit` passes. The generated Prometheus docs pick up the metric help change. Not verified against live backends in this PR: the stream fixes, the token usage change and the context-overflow patterns have no coder test against a real provider. coder/fantasy#72 reports a local chatd run against the AI Gateway on Anthropic, Responses, OpenAI Chat and openaicompat. </details> > 🤖 This PR was created with the help of Coder Agents, and _will be_ reviewed by a human. 🏂🏻 |
||
|
|
a33af01605 |
refactor(coderd/x/chatd/chatloop): create the compaction debug run through StartRun (#31087)
Compaction was the last debug-run caller that did by hand what `chatdebug.Service.StartRun` does: insert the run on a detached context with a 5 second limit, rebuild the run context, and finalize it with `ClassifyError`. This PR moves `startCompactionDebugRun` onto `StartRun` and deletes `compactionDebugCreateRunTimeout`. #30934 moved the other callers; compaction waited for #30766, which has merged. **Why it is safe:** - The first commit changes only the test, renamed from `TestStartCompactionDebugRun_DoesNotReportDebugErrors` to `TestStartCompactionDebugRun`. It now asserts the whole inserted row: kind `compaction`, status `in_progress`, the parent run's root chat, parent chat and trigger message, the summary model's provider, model, model config and history tip when the caller sets them and the parent run's otherwise, and no summary. It also asserts the returned run context and the `completed` and `interrupted` finalize statuses. It passes on the old code and on the new code. - On the old code, 16 mutants (wrong kind or status, a dropped parent field, an ignored override or fallback, a seeded summary, a wrong run context field, a wrong finalize status) all fail the new test. Before this PR, the chatloop tests caught 1 of them and `TestActiveServer_CompactionModelOverride` 3 more (kind, model and model config); the other 12 passed both. On the new code, all 13 mutants of the `StartRun` call fail the test. - `StartRun` keeps the rest: a failed insert returns the caller's context and a no-op finalizer, the insert ignores the caller's cancellation, and the run still finalizes through `FinalizeRun` with its default 5 second limit. `TestService_StartRun` pins the first two. A nil seed summary still stores no summary, because `nullJSON` maps a nil map to SQL NULL. **Review focus:** log output. The old code discarded create and finalize errors. `StartRun` logs them at Warn as `failed to create debug run` and `failed to finalize debug run`, like the other callers. A debug failure still never fails compaction. Validation: - `go test -count=1 ./coderd/x/chatd/chatloop/...` passes, and so does `go test -race` on the compaction debug tests. - `go test -count=1 -p 2 -parallel 4 ./coderd/x/chatd/chatdebug/...` passes. - `go test -count=1 -parallel 4 -run 'Debug|Compact' ./coderd/x/chatd/`: the same 53 tests pass before and after. - `go vet` is clean on both packages, and the pre-commit hook, which runs `paralleltestctx`, passed on both commits. > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
514f23979a |
feat: honor disable-model-invocation in skill frontmatter (#31147)
Extends #30882's `model_invocable` semantics to workspace skills and to stored skills created through the API. Claude Code and Xum let skill authors set `disable-model-invocation: true` in SKILL.md frontmatter, so agents never pick the skill on their own and it runs only when a person invokes it. Coder Agents honored the key only when someone imported a SKILL.md file while adding a project skill (#30884). ## What changes - **Workspace skills:** when the pinned SKILL.md sets the key to the YAML boolean `true`, chatd leaves the skill out of `<available-skills>` before merging sources, so a listed skill with the same name keeps its bare name, and `read_skill` reports it as not found. The skill stays in the `/` menu, and invoking it still loads its body. `read_skill_file` serves its supporting files under the bare name or `workspace/<name>` and refuses its `SKILL.md` (case-insensitive, after `path.Clean`). Skills without the key behave as on the base. - **Invoked workspace skills:** invoking a workspace skill now stores the pinned skill directory on the invocation part, and the prompt renders it as `dir` on `<invoked-skill>`, escaped as an attribute value. Before, only `read_skill` gave the model a skill's directory, and it refuses a hidden skill, so a hidden skill could not run the scripts it bundles. The part also stores the chat's workspace, and the prompt shows `dir` only while the chat stays bound to it, as it does for workspace file references. This changes #30861's invocation code. Hook payloads drop the directory and its workspace like the body, and API responses strip both. - **Stored skills:** a create request whose content sets the key and that omits `model_invocable` stores `model_invocable = false`. An explicit value wins, and PATCH is unchanged. This covers personal, organization, and project skills, which share `createSkill`. - `workspacesdk.SkillDisablesModelInvocation` reads the key. The `CreateSkillRequest.ModelInvocable` doc comment, the generated API docs, and `extending-agents.md` (the SKILL.md format, a new "Turn off automatic use" section, and the notes on the skill index, the skill tools, and aliases) describe the new behavior. ## Follow-ups - The personal and organization skill editors have no "Agents can use it automatically" switch yet. Only the project editor from #30884 has one. ## Testing - Go tests cover the parser, the turn's skill index and aliases, `read_skill`, `read_skill_file`, invocation of a hidden skill and the directory it carries (attribute escaping, no directory after the chat changes workspace, no directory in hook payloads), and the create default for personal and organization skills. Each new test fails when its code path is removed. - Remote dogfood UAT with a real model failed rounds 1 to 3. Rounds 1 and 2 found the hidden SKILL.md still readable through `read_skill_file` by symlinks and stale pins, plus a bare-name lookup bug and a docs gap that round 2 fixed. Round 3 found that the content check added against those bypasses refused a listed skill's file whose own frontmatter sets the key. After round 3 we narrowed the rule to the hidden skill's `SKILL.md` path. The key decides what agents are offered (the index and `read_skill`), not which files they can read: `read_file` and `execute` already open any workspace file, so a content check in `read_skill_file` protected nothing and kept producing edge cases. - Round 4 passed on `c9ff25dc29f`. Later commits added a behavior-neutral cleanup (`cd617533c2e`), one test case from the test audit (`044c1e6e23a`), and a comment fix (`9ec3768b18b`), which passed validation without another UAT round. Round 5 passed on `2b518c6c2b1`, which adds the skill directory. A real model ran hidden skills' scripts from the `dir` on `<invoked-skill>`, including directories whose paths contain `&`, `'`, `"`, `<` and `>`, and API responses carried no directory. Merging main after #30884 landed (`2d7d3cb9674`) did not change this PR's diff, so UAT was not rerun. `8f043b2a342`, which shows the directory only while the chat stays bound to the skill's workspace, has Go tests but no UAT round. - The doc-check skill ran in author self-check mode on `2d7d3cb9674`, and `27de7f5c6d7` fixes its findings: the skill index sentence said every skill is listed, the stored-skill sentence claimed any project editor import honors the key and presented the API default as fixed, the API path came before the UI path, and some wording broke the docs style rules. The fix is docs-only, so UAT was not rerun. - Polish and the test audit stayed inside the implementation diff. No new dependencies. - Codex review found no major issues on `9ec3768b18b`, then raised one P2 on the same head when the PR was marked ready: an invoked hidden skill gets no skill directory. A probe confirmed it, and `2b518c6c2b1` fixes it. Its earlier finding on that head (honor `CODER_AGENT_EXP_SKILL_META_FILE`) was refuted, because the pinned skill snapshot always reads `SKILL.md`. Both threads are resolved, and Codex found no major issues on `2b518c6c2b1` or on the merge `2d7d3cb9674`. - On `27de7f5c6d7`, Codex raised two P2s. One was confirmed: an invoked skill's directory stayed in the prompt after the chat moved to another workspace, which a prompt test showed on that head, and `8f043b2a342` fixes it. The other was declined: on Windows, `scripts\..\SKILL.md` gets past the `SKILL.md` check in `read_skill_file`, but that check is not an access boundary (`read_file` opens any path), and Windows has more aliases (`SKILL.md.`, `SKILL.md::$DATA`, `SKILL~1.MD`) that normalizing backslashes would not stop. On `8f043b2a342`, Codex asked to bind the directory to the workspace build instead. That was declined: every workspace start is a new build with new agent IDs, so the directory would drop after each stop and start, and the pinned body and the live files can diverge without a rebuild anyway, as they do for `read_skill`. A later request on that head asked to limit a hidden skill's `read_skill_file` access to invocations in the current workspace. That was declined too: `read_skill_file` resolves names against the current pin for listed skills on main as well, and the key decides which skills agents are offered, not which files they can read. All four threads are resolved. `a697dcd927f` adds the `format:"uuid"` tag that `TestSDKFieldsFormatted` requires on the new field, and Codex found no major issues on `a697dcd927f`. `ae70b2c533f` is docs-only: it applies the doc-check suggestion to say that an invoked skill's directory is included only while the chat stays in that workspace. The author doc-check self-check found no blocking findings on it, and Codex found no major issues on `ae70b2c533f`. > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. --------- Co-authored-by: Jaayden Halko <jaayden.halko@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> |
||
|
|
688c4a390c |
fix: bump Go to 1.26.10, terraform to 1.16.7, alpine to 3.24.3 (CVE-2026-111943) (#31301)
Mitigates CVE-2026-111943 (compromised eMudhra intermediate CAs). - **Go 1.26.9 to 1.26.10** (`go.mod`, `mise.toml`, `mise.lock`). Go 1.26.10 no longer trusts certificates issued through the compromised intermediates. - **Bundled Terraform 1.16.6 to 1.16.7** (`install.go`, `install.sh`, `scripts/Dockerfile.base`, `mise.toml`, `mise.lock`, `flake.nix`, airgap docs, `testdata/generation.sha1`). [1.16.7](https://github.com/hashicorp/terraform/releases/tag/v1.16.7) is built with Go 1.26.10. Checksums come from the GPG-verified `terraform_1.16.7_SHA256SUMS`. `maxTerraformVersion` stays at 1.16.9. - **Base image `alpine:3.24.2` to `alpine:3.24.3`**. 3.24.2 ships `ca-certificates-bundle-20260909-r0`; 3.24.3 ships `20261020-r0`. Verification: - Rebuilt `scripts/Dockerfile.base` for linux/amd64 and linux/arm64. Both contain `ca-certificates-bundle-20261020-r0` and `Terraform v1.16.7`. - `go test ./provisioner/terraform/...` passes with Terraform 1.16.7. - `scripts/check_go_versions.sh` passes. - Local git hooks were skipped at the author's request because the dogfood host was overloaded. CI is the gate. Backports to `release/2.34` through `release/2.38` follow as separate PRs. Older Terraform minor lines did not get the Go 1.26.10 rebuild (1.15.9 is built with Go 1.25.10, 1.14.9 with Go 1.25.8), so release/2.35 also moves to 1.16.7. <details> <summary>Decision log</summary> - The request named Go 1.26.1. Main and every release branch were already on 1.26.9, so @sreya confirmed the target is 1.26.10. - release/2.34 stays on the Alpine 3.23 line (`alpine:3.23.7`, which also ships `ca-certificates-bundle-20261020-r0`) instead of jumping to 3.24. - release/2.35 had drifted: `install.go` pinned 1.14.5 (max 1.14.9) while the image and `mise.toml` used 1.15.5. Its backport sets both to 1.16.7 and raises max to 1.16.9. </details> > Generated by Coder Agents on behalf of @sreya. |
||
|
|
aa9b0a950a |
docs: document declarative script ordering (#31227)
Add a Beta guide for `coder_script_order` with startup and shutdown examples, module and dev container ordering, failure handling, and migration from `coder exp sync`. Add navigation and glossary entries. Recommend declarative ordering for whole scripts and clarify when to use `coder exp sync` for coordination within script bodies. Fix fragment links and heading anchors in the offline docs renderer so section links stay on the current page and repeated headings get unique IDs. Refs: https://linear.app/codercom/issue/CORE-555 --------- Co-authored-by: Atif Ali <atif@coder.com> |
||
|
|
cdfdaed267 |
fix(site/src/pages/AISettingsPage/ProvidersPage): stop browsers refilling provider credentials (#30391)
Fixes DES-22153. Provider credential inputs (API key, Bedrock access key and secret, Claude Platform workspace key) are plain text fields with `autocomplete="new-password"`, which browsers and password managers don't treat as a reason to skip filling. As a result, a key entered earlier could show up again on the next Add provider form, such as Azure. `CredentialField` now spreads the shared `passwordManagerIgnoreProps` from `#/utils/formUtils` (added in #28998): `autocomplete="off"` plus the 1Password, LastPass, Bitwarden, and Dashlane ignore attributes. Every credential input picks this up, and the now-unused `autoComplete` prop is removed. A regression test covers the Azure and Bedrock fields. <details> <summary>Decision log</summary> - The Linear issue has no repro steps. Of the possible causes, browser or password-manager refill is the only one that matches "retains a previously entered value" on a fresh form: the add page unmounts the form when you go back to the provider list, and Formik starts with an empty `apiKey`. - The input stays `type="text"` rather than becoming `type="password"`, so the saved-key mask (for example `sk-***...ABCD`) stays readable, as #25848 intended. - The fix reuses the existing shared constant instead of adding new attributes. - Relation to CODAGT-525 (#25848): `autoComplete="new-password"` was added while that PR briefly made these inputs `type="password"` (review finding CRF-2). Review finding CRF-3 moved them back to `type="text"` so the saved-key mask stays readable, but `new-password` stayed and only has an effect on password inputs. This PR swaps it for the attributes that work on text inputs. The CODAGT-525 re-mask-after-save and focus/blur logic is unchanged, and its `ProviderForm` stories still pass. </details> > Generated by Coder Agents on behalf of @tracyjohnsonux. |
||
|
|
9b34c5a12a |
chore(site): enable no-useless-spread oxlint rule (#31241)
Depends on #31240 Enables oxlint's `unicorn(no-useless-spread)` rule in `site/.oxlintrc.jsonc`, moving it from the correctness backlog to `"error"`. Each of the three violations spread an expression that already produced a new object: - `vite.config.mts`: `resolve.alias` is now the profiling ternary itself. - `testHelpers/entities.ts`: `MockProxyLatencies` is the `reduce` result directly; its accumulator is already a fresh object. - `schedule.test.ts`: a nested `...{ ...emptySchedule, ... }` is flattened, keeping key order. > Generated by Coder Agents on behalf of @jeremyruppel. |
||
|
|
fc13808e97 |
chore(site): enable preserve-manual-memoization oxlint rule (#31240)
Depends on #31239 Enables oxlint's `react(preserve-manual-memoization)` rule in `site/.oxlintrc.jsonc`, moving it from the correctness backlog to `"error"`. The rule flagged the same `sortedParams` `useMemo` in `CreateWorkspacePage`, `TemplateEmbedPage`, and `WorkspaceParametersPage`: the callback reads `latestResponse.parameters` after a guard, but the dependency list was `[latestResponse?.parameters]`, so the compiler could not preserve the memoization. Each now destructures `parameters` from `latestResponse ?? {}` and depends on `[parameters]`. The `useMemo`s stay because these pages are outside the React Compiler `include` list in `vite.config.mts`. > Generated by Coder Agents on behalf of @jeremyruppel. |
||
|
|
898776816a |
chore(site): enable control-has-associated-label oxlint rule (#31239)
Depends on #31238 Enables oxlint's `jsx-a11y(control-has-associated-label)` rule in `site/.oxlintrc.jsonc`, moving it from the correctness backlog to `"error"`. Both violations were empty `<button>`s in the `ProxyContext.test.tsx` harness. They now have text content ("Clear proxy", "Select proxy"), and the tests query them with `getByRole("button", { name })` instead of test IDs. > Generated by Coder Agents on behalf of @jeremyruppel. |
||
|
|
711f64bc40 |
chore(site): enable no-noninteractive-element-interactions oxlint rule (#31238)
Depends on #31229 Enables oxlint's `jsx-a11y(no-noninteractive-element-interactions)` rule in `site/.oxlintrc.jsonc`, moving it from the correctness backlog to `"error"`. The rule's one violation was the `<label>` in `ThemeSwatch`, which carried hover and focus handlers for the theme preview. `onFocus`/`onBlur` now live on the radio input, where focus actually happens (they previously bubbled to the label). The hover handlers stay on the label with a suppression, since the `sr-only` input cannot receive pointer hover. Narrowing the rule with its `handlers` option would also have cleared this without a code change, but Biome's equivalent rule flags the same code, so the default handler set is kept. > Generated by Coder Agents on behalf of @jeremyruppel. |
||
|
|
46c0cfdb35 |
chore(site): enable no-useless-fallback-in-spread oxlint rule (#31229)
Depends on #31228 Enables oxlint's `unicorn(no-useless-fallback-in-spread)` rule in `site/.oxlintrc.jsonc`, moving it from the correctness backlog to `"error"`. The rule's one violation was `...(typeDefaults ?? {})` in `ProviderForm`'s initial values. Spreading `undefined` into an object literal adds no properties, so it is now `...typeDefaults` with no behavior change. > Generated by Coder Agents on behalf of @jeremyruppel. |
||
|
|
19ad8f346f |
chore(site): enable no-conditional-tests oxlint rule (#31228)
Depends on #31224 Enables oxlint's `vitest(no-conditional-tests)` rule in `site/.oxlintrc.jsonc`, moving it from the correctness backlog to `"error"`. The rule's one violation was in `site/src/theme/cssVariables.test.ts`, where an `if (effectiveBlock !== null)` guard silently skipped every `resolves --<variable>` test when a theme's effective block could not be built (for example, a missing base-mode block). The tests now always register and fail in that case, using the same `?? ""` pattern as the rest of the file. The loop that registered them is now `it.each`. > Generated by Coder Agents on behalf of @jeremyruppel. |
||
|
|
bcafbe2aae |
chore(site): enable static-components oxlint rule (#31224)
Enables oxlint's `react(static-components)` rule in
`site/.oxlintrc.jsonc`, moving it from the correctness backlog to
`"error"`.
The rule's one violation was `Shimmer`, which resolved its element with
`motion.create()` during render. A module-level cache kept the component
stable at runtime, but the rule cannot see that, and React Compiler
skipped optimizing the component. `Shimmer` now picks from a static `{
p: motion.p, span: motion.span }` map, and `as` is narrowed to `"p" |
"span"`. All existing callers pass `as="span"`.
> Generated by Coder Agents on behalf of @jeremyruppel.
|
||
|
|
1e0a481a60 |
fix: retry workspace quota commits with jittered backoff (#31207)
Bursts of builds for the same user and org (usually autostarts) can hit serialization failures in `CommitQuota`. `InTx` only retried those 3 times back-to-back, so once retries ran out the build failed outright. `CommitQuota` stays `SERIALIZABLE` and now gets up to 10 retries with full-jitter exponential backoff (50ms base, 2s cap, about 11s of backoff at most). These builds aren't interactive, so a longer wait is a better trade than a failed build. The wait respects the request context and happens between transactions, so nothing holds a connection while it sleeps. Each attempt also resets its results now, so a rolled-back attempt can't leak `Ok: true` into the response. The retry settings are opt-in fields on `database.TxOptions` (`SerialMaxAttempts` and `BeforeSerialRetry`). Every other `InTx` caller keeps the default 3 attempts with no delay. Since this touches `coderd/database/db.go`, it'll need a look from a `coderd/database` owner. This replaces #30126 with the simpler approach Spike and I landed on. If we still see failures after this ships, the next step is making autostart replica-aware so a single replica handles each user, rather than adding locking here. Fixes [CORE-198](https://linear.app/codercom/issue/CORE-198) |
||
|
|
7e9735c4ec |
refactor: share the session app fold rule and method derivation (#31028)
Ingest, the template insights API, and the Prometheus metric now use one rule to fold apps and one rule to derive each app's connection method. The method is derived from the app name, not stored. Every current reporter's app name implies its method. - Add codersdk.SessionAppMethod: reconnecting_pty and port_forwarding keep their own method, and every other app name is ssh. It replaces the private helper in coderd/insights.go. - Add codersdk.FoldUnregisteredSessionApps, the fold rule that GetTemplateInsights already applies in SQL. Registered apps, unknown, and overflow keep their entries, and so do the 64 busiest other apps. Ties break by app name in byte order, and the rest add up under overflow. - Ingest uses the shared rule instead of capSessionCounts. Registered apps and unknown no longer fold, and at most 64 unregistered app names keep their entries. Refs #31012, CLIENT-1062 |
||
|
|
e17851d968 |
feat(codersdk): accept options on ResolveWorkspace (#29913)
Stacked on #29908. `ResolveWorkspace` dispatches to either `Client.Workspace` or `Client.WorkspaceByOwnerAndName`. Now that both accept `WorkspaceOptions`, `ResolveWorkspace` takes an optional `WorkspaceOptions` and forwards it to whichever lookup runs, so callers can request deleted workspaces or narrow the related data loaded. - Signature is variadic (`opts ...WorkspaceOptions`) so existing call sites are unaffected; only the first option is used, and it is applied on both the UUID and owner/name paths. - Added a `ForwardsOptions` subtest to `TestResolveWorkspace` that asserts `include_related` is sent on both resolution paths using a mock HTTP server. _This PR was created by Coder Agents on behalf of @spikecurtis._ |
||
|
|
578b5270a6 | chore: skip Storybook on PRs without site changes (#31298) | ||
|
|
b2e6f89766 |
chore: use go test cache for test-go-pg-17 and test-go-race-pg (#31295)
These jobs skipped the mtimehash step that test-go-pg uses, so packages that open files (cli, enterprise/coderd, enterprise/cli, ...) missed the Go test cache on every PR run. |
||
|
|
e4e62d99da |
docs(docs): document Toolbox support bundle requirements (#31289)
The support bundle guide covers CLI and VS Code collection but does not explain the requirements or collection flow for JetBrains Toolbox. The Toolbox installation guide also lists an outdated minimum version. This commit updates both guides with the minimum Coder plugin, Toolbox, and CLI versions. The support bundle guide now explains how the Toolbox plugin collects Coder diagnostics and local SSH logs, what the archive contains, and what remains available when bundle generation fails. The collection steps now start from the environment list shown after sign-in and use the environment's action menu, so users can follow the Toolbox interface directly. Each environment represents a workspace and agent pair. -resolves https://linear.app/codercom/issue/JET-11/document-toolbox-support-bundle-version-requirements-in-coder-docs <!-- 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. --> |
||
|
|
9bf68b8e6b |
chore(docs): update release docs for v2.38.2 (#31218)
Automated docs update for v2.38.2 release. Created by `releasetui`. --------- Co-authored-by: Nick Vigilante <nick.vigilante@coder.com> |
||
|
|
1893b80805 |
fix(docs/reference/cli): regenerate ping docs with table headers (#31292)
## Summary Regenerate `docs/reference/cli/ping.md` so `main` passes `lint/docs-html` and the `offlinedocs` unstaged-files check again. #30148 committed the page from a branch that predated #30879, which gave CLI option tables a `Property | Value` header. ## Changes - Regenerate `docs/reference/cli/ping.md` with `make -B docs/reference/cli/index.md`. No hand edits. Linear: DOCS-1424 ## Testing - `make -B docs/reference/cli/index.md` reports that only `ping.md` changed, and the diff matches what CI reported. - `go run ./scripts/docshtmlcheck` passes. --- > [!NOTE] > Generated by Coder Agents on behalf of @nickvigilante. |
||
|
|
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._ |
||
|
|
b644b19f02 |
feat(site): support ACP subagents on the frontend (#30561)
Render dedicated ACP tool cards with live transcripts, reasoning, nested tool activity, and session labels shared across follow-up messages. List discovered harnesses and their configuration directories in the context indicator. https://github.com/user-attachments/assets/827cb8f4-0ed2-4c3c-a115-b04fc26afde9 Depends on #30560. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
e75885a37e |
feat: add ACP subagent waiting and transcript streaming (#30560)
Add `acp_wait_agent` to stream ACP transcripts, including reasoning and nested tool activity, to users while returning the subagent's text response to the parent model. Reconnect dropped streams from their transcript cursor, preserve running sessions on wait timeout or cancellation, and persist separate user-visible and model-visible results. Depends on #31022. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
8fd94eba27 |
feat: add tools to start, message, and interrupt ACP agents (#31022)
Add tools to spawn, message, and interrupt workspace-local ACP agents when the `chat-acp-subagents` experiment is enabled. Derive harness choices and configuration validation from the chat's pinned context, and deduplicate session creation and prompt submission across retries. Depends on #30831. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
4b9b98794a |
feat: add agent-local ACP session interaction (#30831)
Expose agent-local ACP session creation, messaging, interruption, transcript reads, and event streams through the agent HTTP and WebSocket API and workspace SDK. Support cursor-based reconnection and extend response write deadlines to allow harness initialization and session recovery to finish. Depends on #30857. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
e3068bb4c4 |
feat: restore and recover agent-local ACP sessions (#30857)
Restore missing or failed agent-local ACP sessions using load or resume, preferring load to replay the latest turn's history. Share concurrent recovery attempts and preserve failed transcripts without automatically retrying messages. Depends on #30903. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
d2c32e666d |
feat: watch and subscribe to ACP session updates (#30903)
Add atomic transcript snapshots and live event subscriptions for agent-local ACP sessions, with cursor-based replay across turns. Close subscriptions on cancellation, shutdown, or buffer overflow so slow consumers do not block session updates. Depends on #30841. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
9add27f852 |
test(agent/x/agentacp): cover session runtime and transcripts (#30841)
Cover agent-local ACP session initialization, configuration, environment propagation, permission callbacks, and transcript ordering with a fake harness. Verify busy-session rejection, interruption, write deadlines, and preservation of partial output after failures. Depends on #30835. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
43ec0ba8d5 |
feat: add ACP session runtime and transcripts (#30835)
Create and run agent-local ACP sessions with configurable harnesses, prompt submission, interruption, and ordered transcripts. Track session status and failures, scope permission grants to running turns, and stop session processes when the manager shuts down. Tests are in the next PR in the stack. Depends on #31128. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
457d777af1 |
fix(coderd/x/chatd/toolschema): traverse schema branches (#31128)
Tool input validation skipped properties declared inside composed schemas, allowing case-variant keys to bypass ambiguity checks. Traverse `anyOf`, `oneOf`, and `allOf` branches when checking nested objects, arrays, and free-form map values, while preserving exact property matches. Generated with Codex, carefully reviewed by Hugo. |
||
|
|
9cda919eb1 |
test(coderd/x/chatd): fold the duplicate advisor scenarios (#30993)
Two end-to-end advisor scenarios repeated other tests. This PR moves their unique checks into tests that stay and deletes them. - `TestAdvisorGating_RootChat` replayed the advisor and `read_file` batch of the `mixed exclusive and local tools commit policy errors` subtest. Its exact two-call count moves into that subtest, which already checks that `read_file` never runs and both stored errors. Its check that the first request carries the advisor guidance moves into `TestAdvisorHappyPath_RootChat`; the `Root` row (#30990) checks the advisor tool and the guidance in the turn environment. - The `solo exclusive tool executes` subtest is a subset of `TestAdvisorHappyPath_RootChat`, which now also checks the stored advisor result. ### Why it is safe | Deleted assertion | Remaining check | | --- | --- | | Exactly two streamed calls | the mixed local subtest: `>= 2` became `== 2` | | Advisor offered | `Root` row (turn environment), and `TestAdvisorHappyPath_RootChat` now checks that the first request lists `advisor` | | Guidance in the first request | happy path test, new check | | Advisor and skipped tool errors sent back | the mixed local subtest (stored errors), `TestExclusiveToolPolicy_MixedBatchErrors` (text) | | Solo: stored result is not an error and holds the reply | happy path test, new checks | | Solo: three streamed calls | happy path test waits for the same three | | Mutant | Fails before | Fails after | | --- | --- | --- | | Exclusive batch check off | both mixed subtests, `RootChat` | both mixed subtests | | No exclusive tool set | both mixed subtests, `RootChat`, `Root` row | both mixed subtests, `Root` row | | Advisor runs, then the batch is rejected | `RootChat` only | the mixed local subtest | | Advisor result marked as an error | provider executed subtest, solo | provider executed subtest, happy path | | Advisor result replaced with `{}` | solo, happy path | happy path | | Guidance dropped from the request (`generation.go:898`) | `RootChat` only | happy path | Only an exact count sees the nested advisor call of the third mutant, so the count moves instead of going away. Coverage: in 6 runs per head of `go test ./coderd/x/chatd/... -count=1 -p 4 -covermode=set -coverpkg=./coderd/x/chatd/...`, every block that all runs at #30990 reach is also reached at #30993. The other differences are blocks that some runs of the same head reach and others miss, mostly error paths that depend on timing, so one run per head can show them as lost or gained. ### Review focus The subtest reads the count after the chat reaches `waiting`, and its fake model server counts only streamed requests, so title requests do not change it. ### Timing From 10 runs, the two deleted scenarios took 0.83 s summed (median per test). ### Validation - `go test ./coderd/x/chatd/ -run '^(TestActiveServer_ExclusiveToolPolicy|TestAdvisorHappyPath_RootChat)$' -count=10`, and with `-race -count=3`: pass - `go test ./coderd/x/chatd/...`: pass - `go test -overlay` mutant runs of the whole `./coderd/x/chatd/` package before and after this PR: results above - the pre-commit hook (gen, fmt, lint, slim build) passed ### Stack The stack moves advisor eligibility and the root versus child tool split into `TestBuildTurnEnvironmentToolPolicy` and deletes the end-to-end tests that only checked them, finishing #30868. #30911 has merged, so the stack now starts at `main`. 1. #30990 Advisor and general child rows in the tool policy table 2. #30991 Remove the end-to-end advisor gating tests 3. #30992 Remove the end-to-end root and child tool list tests 4. #30993 Fold the duplicate advisor scenarios (this PR) > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
c78ceccfaa |
test(coderd/x/chatd): remove end-to-end root and child tool list tests (#30992)
This PR deletes three end-to-end checks of model request tool lists (309 lines); the rows from #30990 check the same lists on the turn environment. The plan child tail also proved that a follow-up message without `PlanMode` keeps the stored plan mode. The plan rows of `TestBuildTurnEnvironmentToolPolicy` now send that follow-up and check the stored plan mode, so clearing it in `SendMessage` fails the table. - `TestSubagentChatExcludesWorkspaceProvisioningTools` booted coderd with a provisioner and AI Bridge to compare root and child tool names. - The plan child tail of `TestActiveServer_BasicAssistantGenerationAndPromptPreparation` checked `read_file` and `write_file`. Its only helper, `createPlanSubagentChatWithHistory`, goes too. - `TestPlanModeRootChatApprovedExternalMCPToolInvocation` is the first half of `TestPlanModeRootChatApprovedExternalMCPWorkflowCanReachProposePlan`, with the same three checks. ### Why it is safe Each mutant of `turn_environment.go` below failed the deleted check and fails the remaining one: | Deleted assertion | Remaining check | Mutant | | --- | --- | --- | | Root has the five workspace and five sub-agent tools | `Root` | root-only tools in no chat | | Standard root has no `ask_user_question` or `propose_plan` | `Root` | either tool added there | | Child has no workspace, sub-agent, or `ask_user_question` tools | `GeneralChild` | root-only tools or `ask_user_question` in children | | Plan child has `read_file` and no `write_file` | `PlanChild` | each flipped | | Plan root offers the approved MCP tool, ends `waiting`, and sends the result to the next call | the workflow test, and `PlanRoot` | approved MCP tools dropped | The split reads only `ParentChatID`, `Mode`, and `PlanMode` from the chat row (`turn_environment.go:258-261`), so a table child made with `chatstate.CreateChat` gets the tools of a `spawn_agent` child made with `chatstate.CreateChatWithID`. The `TestSpawnAgent_*` tests cover spawning. The deleted sub-agent test replied with an escaped NUL sequence but never checked the stored reply; `TestNulEscapeRoundTrip/BackslashU0000Text` covers that text. Coverage: in 6 runs per head of `go test ./coderd/x/chatd/... -count=1 -p 4 -covermode=set -coverpkg=./coderd/x/chatd/...`, every block that all runs at #30990 reach is also reached at #30993. The other differences are blocks that some runs of the same head reach and others miss, mostly error paths that depend on timing, so one run per head can show them as lost or gained. ### Timing From 10 runs, the two deleted tests took 1.14 s summed (median per test). The basic test went from 0.51 s to 0.41 s (median of 5). ### Validation - `go test -overlay` mutant runs of the whole `./coderd/x/chatd/` package before and after this PR: results above - `go vet ./coderd/x/chatd/`: clean; the pre-commit hook (gen, fmt, lint, slim build) passed ### Stack The stack moves advisor eligibility and the root versus child tool split into `TestBuildTurnEnvironmentToolPolicy` and deletes the end-to-end tests that only checked them, finishing #30868. #30911 has merged, so the stack now starts at `main`. 1. #30990 Advisor and general child rows in the tool policy table 2. #30991 Remove the end-to-end advisor gating tests 3. #30992 Remove the end-to-end root and child tool list tests (this PR) 4. #30993 Fold the duplicate advisor scenarios > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
ac62f2e760 |
test(coderd/x/chatd): remove the end-to-end advisor gating tests (#30991)
`TestAdvisorGating_ExperimentDisabled`, `_ChildChat`, `_PlanMode`, and `_ExploreSubagent` each started Postgres, an active server, and a fake model server for one chat turn, only to check that the request had no advisor tool and, except for `_ExperimentDisabled`, no advisor guidance. The rows from #30990 check the same absence in the turn environment, so this PR deletes the four tests (353 lines). To keep one request-level check, `TestComputerUseSubagentToolsAndModel` now also checks that its child's first streamed request has no `advisor` tool and no guidance block. ### Why it is safe Each test guarded one condition of the advisor gate (`turn_environment.go:291`). Removing the condition failed the test and fails its row: | Deleted test | Its assertions | Row | Gate mutant | | --- | --- | --- | --- | | `_ExperimentDisabled` | No advisor tool with the experiment off and a stored config that says enabled | `RootAdvisorOff` (same config) | experiment check removed | | `_ChildChat` | No advisor tool or guidance in a chat with a parent | `GeneralChild`, the computer use test | root check removed | | `_PlanMode` | Same, in a plan mode root chat | `PlanRoot` | plan check removed | | `_ExploreSubagent` | Same, in an Explore chat | `ExploreRoot` | Explore check removed | The rows read the turn environment, not the request. A mutant that adds the guidance to every request (`generation.go:898`) failed `_ChildChat`, `_PlanMode`, and `_ExploreSubagent` and passes every row; it fails the computer use test. `_ExploreSubagent` made an Explore root chat (`isExploreSubagentMode` matches any Explore chat); `ExploreChild` also rejects the advisor. `_ExperimentDisabled` enabled every other known experiment, but the gate reads only `ExperimentChatAdvisor`. Coverage: in 6 runs per head of `go test ./coderd/x/chatd/... -count=1 -p 4 -covermode=set -coverpkg=./coderd/x/chatd/...`, every block that all runs at #30990 reach is also reached at #30993. The other differences are blocks that some runs of the same head reach and others miss, mostly error paths that depend on timing, so one run per head can show them as lost or gained. ### Timing From 10 runs, the four tests took 1.25 s summed (median per test). ### Validation - `go test -overlay` mutant runs of the whole `./coderd/x/chatd/` package before and after this PR: results above - `go test ./coderd/x/chatd/ -run '^TestComputerUseSubagentToolsAndModel$' -count=10`, and with `-race -count=3`: pass - `go vet ./coderd/x/chatd/`: clean; the pre-commit hook (gen, fmt, lint, slim build) passed ### Stack The stack moves advisor eligibility and the root versus child tool split into `TestBuildTurnEnvironmentToolPolicy` and deletes the end-to-end tests that only checked them, finishing #30868. #30911 has merged, so the stack now starts at `main`. 1. #30990 Advisor and general child rows in the tool policy table 2. #30991 Remove the end-to-end advisor gating tests (this PR) 3. #30992 Remove the end-to-end root and child tool list tests 4. #30993 Fold the duplicate advisor scenarios > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
56fe6ec5e3 |
test(coderd): run the TestPostChats workspace, input, and MCP rejections on one server (#30976)
This PR moves the remaining 9 isolated rejection subtests of `TestPostChats` into the shared `Rejects` table from the previous PR: the 4 workspace cases, `EmptyText`, `UnsupportedPartType`, `RejectsInvalidReasoningEffort`, and the cross-org and third-org MCP server cases. Each one no longer starts its own coderd and AI Bridge daemon. `MCPServerIDsDisabledConfigRejected` keeps its own server: after the create rejection it sends a message on a chat it creates, which a single-request case cannot express. ### Why it is safe - Cases keep the old subtest names, callers, status, and message checks, and now also check the exact `Detail`. The reasoning-effort case compares the full detail instead of two substrings. - I mutated 12 lines in `postChats` and its workspace, input, effort, and MCP helpers and ran the old and new test files against each one. The old file caught 10 and the new file catches the same 10, each in the case that owns it, plus a detail-text mutant the old file missed. The one mutant both survive (reading the workspace as system) returns the same response from the SSH check. ### Review focus The workspace cases now run with the shared default model present. `postChats` rejects them before it resolves a model, so the model does not change their result. `EmptyText` and `UnsupportedPartType` run in an organization without a model, so they still prove that input is rejected before model resolution: moving the input check after it fails both. The MCP cases add their configs to orgs that no other case reads, or to the default org with `default_off`, where no other case passes MCP IDs. ### Timing From 5 alternating runs, the moved subtests took 2.83 s summed (median); their 9 cases take 0.27 s on the shared server. For the whole stack, `go test` reports 1.96 s instead of 3.19 s for the package. ### Validation - `go test ./coderd -run '^TestPostChats$' -count=3`: pass - the same run with `-race`: pass - `go test -overlay` mutant runs against the old and new test files: results above - `go vet ./coderd` and `golangci-lint run ./coderd/...`: clean; the pre-commit hook passed ### Stack The stack runs every isolated `TestPostChats` rejection case on one shared server instead of one server per case. 1. #30975 Model and organization rejection cases 2. #30976 Workspace, request input, and MCP server rejection cases (this PR) > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
6cf18f4c73 |
feat(site): add Agents label to the Coder Agents PWA icon (#31277)
Add an "Agents" label under the Coder mark in the PWA icon. The background, full-bleed format and manifest icon entries are unchanged: the background is the same crop of the brand light background as before, and the mark is the Shorthand SVG with a Lay Grotesk Semibold label fitted to its width. Static files are served with immutable caching, so the manifest, icon and apple-touch-icon URLs now carry ?v=2 to reach browsers that already fetched the old files. |
||
|
|
f34aaeb017 |
test(coderd): share one server across the chat child archive tests (#30956)
Merges `TestPatchChatArchiveChildRejected`, `TestPatchChatUnarchiveChildRejected`, and `TestPatchChatArchiveRootRollsBackWhenChildCannotArchive` in `coderd/exp_chats_chatstate_test.go` into `TestPatchChatChildArchive`. Each old test started its own coderd server and built the same root and child family. The new subtests share one server and a `createFamily` helper that takes the child statuses, and each subtest still builds its own family. The file starts 11 coderd servers instead of 13. **Why it is safe:** each subtest makes the same requests and the same status and archive-state assertions as the test it replaces. With the old tests compiled back in through `go test -overlay`, both production mutants failed the old tests that guarded the line and the subtests that replace them: | Mutant | Failed, old and new | |---|---| | a child archive or unarchive returns 409 instead of 400 | `ArchiveChildRejected`, `UnarchiveChildRejected` | | the family cascade ignores a child's `SetArchived` error | `RootArchiveRollsBackWhenChildCannotArchive` | **Review focus:** the subtests share a server, user, and model config. Each one builds its own root and children and checks only those rows, and `withChatWorkerDisabled` stays on. **Timing** (`-count=1 -v -p 4 -parallel 4`, median of 5 paired runs on a shared host): the three old tests took 1.4 s summed. The new test takes 0.5 s. **Validation:** - `go test ./coderd -run '^TestPatchChatChildArchive$' -count=10`: pass - the same run with `-race -count=3`: pass - `go vet ./coderd` and `golangci-lint run ./coderd/...`: clean; the pre-commit hook passed **Stack:** these two PRs share coderd servers across the copy-pasted chatstate endpoint tests. 1. #30941: queue and invalid-state tables 2. #30956 (this PR): child archive tests on one server > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
300f73b05a |
test(coderd/x/chatd): cover advisor eligibility in the tool policy table (#30990)
`TestBuildTurnEnvironmentToolPolicy` ran every row with the advisor experiment off and had no general sub-agent row, so only end-to-end tests checked advisor eligibility and the tools that only root chats get. This PR adds those checks to the table and deletes nothing; the PRs above it delete the end-to-end tests. - The rows run on a server with `ExperimentChatAdvisor`; the new `RootAdvisorOff` row uses a second server without it. The stored advisor config says `Enabled: true`, which must not matter: the experiment is the only gate (`codersdk/chats.go:1277`). - `Root` now wants the advisor, its guidance, and the five workspace and five sub-agent tools, and rejects `propose_plan`. The new `GeneralChild` row rejects all of those and `ask_user_question`. The plan and Explore rows reject the advisor. - Every row checks the guidance and the exclusive tool set: only the advisor when the row wants it, otherwise empty. ### Why it is safe The rows pass on `main` (`e53cfef8643`), which now includes #30911. Each of 15 mutants of `turn_environment.go` fails a row: | Mutant | Row that fails | | --- | --- | | Advisor gate ignores the experiment, the root check, plan mode, or Explore mode | `RootAdvisorOff`, `GeneralChild`, `PlanRoot`, `ExploreRoot` in that order | | No advisor guidance, no advisor tool, or no exclusive set | `Root` | | Root-only tools in every chat, or in none | `GeneralChild`, or `Root`, `RootAdvisorOff`, `PlanRoot` | | `ask_user_question` in standard root turns, or in child turns | `Root`, or `GeneralChild` | | `propose_plan` in every turn | `Root` | | Plan children get `write_file`, or plan turns drop `read_file` | `PlanChild` | | Plan turns drop approved MCP tools | `PlanRoot` | The deletion PRs above map each deleted assertion to these rows. Under the plan and Explore gate mutants, the plan filter and the Explore allowlist still drop the advisor tool, so those rows fail on the new guidance and exclusive set checks. ### Review focus Both servers are built once and never changed, and each row creates its own chat, so the rows stay parallel. ### Timing From 5 alternating runs, the table took 0.29 s (median) before this PR and 0.28 s after. ### Validation - `go test ./coderd/x/chatd/ -run '^TestBuildTurnEnvironmentToolPolicy$' -count=10`, and with `-race -count=3`: pass - `go test -overlay` mutant runs: results above - the pre-commit hook (gen, fmt, lint, slim build) passed ### Stack The stack moves advisor eligibility and the root versus child tool split into `TestBuildTurnEnvironmentToolPolicy` and deletes the end-to-end tests that only checked them, finishing #30868. #30911 has merged, so the stack now starts at `main`. 1. #30990 Advisor and general child rows in the tool policy table (this PR) 2. #30991 Remove the end-to-end advisor gating tests 3. #30992 Remove the end-to-end root and child tool list tests 4. #30993 Fold the duplicate advisor scenarios > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
cfddedb95c |
test(coderd): run the TestPostChats model and org rejections on one server (#30975)
`TestPostChats` started a full coderd and AI Bridge daemon for each of its 34 subtests. This PR adds a `Rejects` table on one shared server and moves the 9 model and organization rejection subtests into it: the non-default org model cases, disabled, provider-disabled and denied model configs, `NilOrganizationID`, and `NonMemberOrganization`. Each case creates its own state in `prepare` and returns the caller. Four rejection subtests keep their own servers because they need or change state that the cases share: `MissingDefaultModelConfig` needs a default org with no model, `ProviderDisabledDefaultModelRejected` disables the default model's provider, `DeniedSameOrganizationDefaultIsRejected` adds a second default model to the org, and `AgentsAccessDefaultRole` rewrites org roles. ### Why it is safe - Cases keep the old subtest names, callers, status, and message checks, and now also check the exact `Detail` (empty where the old subtests did not check it). - I mutated 11 lines in `postChats` and its model helpers and ran the old and new test files against each one. The old file caught 8 and the new file catches the same 8, each in the case that owns it. The 3 mutants that both survive return the same response through another check: dbauthz hides other-org configs from members, and the provider status check repeats the provider-enabled check. ### Review focus Cases run in parallel against one deployment. Each case writes only to its own new orgs, users, providers, or non-default configs. No case changes the default model, its provider, or member roles. ### Timing From 5 alternating runs, the moved subtests took 3.12 s summed (median); the table setup plus its 9 cases take 0.59 s. ### Validation - `go test ./coderd -run '^TestPostChats$' -count=3`: pass - the same run with `-race`: pass - `go test -overlay` mutant runs against the old and new test files: results above - `go vet ./coderd` and `golangci-lint run ./coderd/...`: clean; the pre-commit hook passed ### Stack The stack runs every isolated `TestPostChats` rejection case on one shared server instead of one server per case. 1. #30975 Model and organization rejection cases (this PR) 2. #30976 Workspace, request input, and MCP server rejection cases > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
26aa086e56 |
chore(site): upgrade storybook and addons to 10.6.2 (#30688)
Upgrades Storybook and its addons to the latest compatible versions (DASH-122). | Package | From | To | |---|---|---| | `storybook` | 10.5.10 | 10.6.2 | | `@storybook/addon-a11y`, `addon-docs`, `addon-links`, `addon-themes`, `addon-vitest`, `react-vite` | 10.3.3 | 10.6.2 | | `@storybook/addon-mcp` | ^0.7.0 | 10.6.2 (now released from the Storybook monorepo) | | `storybook-addon-remix-react-router` | 6.0.0 | 7.0.0 (same public API, widens the `react-router` peer to `^8`) | The only code change is in the `FilterCombobox` `InlineOptionsRetrying` story. Under Storybook 10.6 a decorator re-render re-runs the story's `render`, which reset its "fail once" closure flag so Retry failed again. The flag now lives in a `useRef`, and the render function is named so it satisfies `rules-of-hooks`. <details> <summary>Verification</summary> - `pnpm check`, `pnpm lint` (incl. `tsc`), `pnpm format`: clean - `pnpm storybook:build`: succeeds - `vitest --project=storybook`: 468 files, 3790 tests pass - `pnpm test`: 4713 pass, 2 skipped - `storybook doctor`: no issues - `InlineOptionsRetrying` failed consistently on the upgrade without the story fix and passed on `main`. </details> _This PR was generated by Coder Agents._ |
||
|
|
5a1a0594c4 |
test(coderd): share one server across the chat message pagination tests (#30965)
`TestGetChatMessages_Pagination` started a coderd server with its own database in each of its ten leaves, although the leaves differ only in cursors and their own chat rows. This PR builds the client, database, owner, and chat model once in the parent. The six successful-page leaves become one table (options, expected ID positions, `HasMore`, queued count), and the two malformed `after_id` leaves become another. The transposed or equal cursor case and the burst walk stay separate subtests, and every subtest keeps its name. **Why it is safe:** every leaf still creates its own chat, messages, and queued message, and every request and query is scoped to that chat. No leaf changes users, roles, models, or deployment values. I ran 24 mutants of `getChatMessages` and its two paginated queries (limit+1 and `HasMore`, truncation, ASC dispatch, queued suppression, `after_id` parsing, the transposed check, cursor comparison, and ordering) against the old and the new test with `go test -overlay`. The new test fails on all 20 mutants that the old test fails on, in the same leaves. It also fails on the two mutants that drop the `chat_id` filter, which the old test missed because each leaf had its own database. Two mutants survive both tests: the DESC path fetching `limit` rows instead of `limit+1`, and `HasMore` using `>=`. No test on `main` covers them, and this PR does not add coverage. **Review focus:** the shared database interleaves message IDs across leaves. Assertions use only the IDs that each leaf's `seedChat` returned, so interleaving cannot change a result for a correct handler. `AfterIDAtOrAboveMaxReturnsEmpty` now seeds five messages instead of three, like the other page cases, and still sets `after_id` to the last ID. **Timing** (prebuilt test binaries, `-test.parallel 4`, median of 5 alternating runs on a shared host): binary wall time went from 1.21 s to 0.72 s. Leaf times summed went from 3.89 s to 0.39 s, plus 0.48 s for the one shared server, and coderd boots went from 10 to 1. **Validation:** - `go test ./coderd -run '^TestGetChatMessages_Pagination$' -count=10`: pass - the same run with `-race -count=2`: pass - `go vet ./coderd` and `golangci-lint run ./coderd/...`: clean; the pre-commit hook passed > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
83cdc8e346 |
test(coderd): table the chatstate queue and invalid-state endpoint tests (#30941)
Replaces nine copy-pasted endpoint tests in `coderd/exp_chats_chatstate_test.go` with two table tests that each share one coderd server. `TestChatQueueEndpointErrors` turns the four queue delete and promote tests into rows. `TestInvalidChatStateEndpoints` turns the two shared invalid-state response tests into rows and holds the three reconcile cases as subtests. Every old case stays a parallel subtest with its own chat, and the file starts 13 coderd servers instead of 20. **Why it is safe:** each subtest sends the same request and makes the same assertions as the test it replaces. With the old tests compiled back in through `go test -overlay`, each of 10 production mutants failed exactly the old test that guarded the line and the subtest that replaces it: | Mutant | Failed, old and new | |---|---| | queue delete or promote returns 409 for an unknown ID, or 404 for an empty queue (4 mutants) | the matching `Missing` or `EmptyQueue` case | | send or tool results skip `writeChatInvalidState` (2 mutants) | the matching `ReturnsSharedResponse` case | | reconcile changes its not-invalid message | `ReconcileNotInvalidReturnsConflict` | | reconcile returns the old chat, or drops the default `last_error` (2 mutants) | `ReconcileSucceeds` | | the chat URL parameter maps a missing chat to 500 | `ReconcileNotFound` | **Review focus:** subtests now share a server, user, and model config. Each subtest creates its own chat and reads only that chat, and `withChatWorkerDisabled` stays on, so no worker moves a chat between steps. **Timing** (`-count=1 -v -p 4 -parallel 4`, median of 5 paired runs on a shared host): the nine old tests took 3.8 s summed. The two new tests take 0.9 s. **Validation:** - `go test ./coderd -run '^(TestChatQueueEndpointErrors|TestInvalidChatStateEndpoints)$' -count=10`: pass - the same run with `-race -count=3`: pass - `go vet ./coderd` and `golangci-lint run ./coderd/...`: clean; the pre-commit hook passed **Stack:** these two PRs share coderd servers across the copy-pasted chatstate endpoint tests. 1. #30941 (this PR): queue and invalid-state tables 2. #30956: child archive tests on one server > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
10e7b3f769 |
chore: bump github.com/andybalholm/brotli to v1.2.7 (#31231)
Bumps `github.com/andybalholm/brotli` from v1.2.2 to v1.2.7. Changes from https://github.com/andybalholm/brotli/compare/v1.2.2...v1.2.7 --- *This PR was generated by Coder Agents on behalf of @Shelnutt2.* Co-authored-by: Lisa Fiander <lisa@coder.com> |
||
|
|
cc51592c6f |
test(coderd): replace the plan-mode lock counterexample test (#30921)
Deletes `AuditConcurrentIdenticalPUTsDuplicateWithoutLock` and its test-only store `lockSwitchChatPlanModeInstructionsStore` from `TestChatPlanModeInstructions`. That test turned the advisory lock off inside the fake store and asserted the duplicate audit row that follows, so it checked the fake's schedule, not `putChatPlanModeInstructions`. The remaining positive test, `AuditConcurrentIdenticalPUTsSingleEntry`, now holds the per-setting lock until both PUTs wait on it, so it fails whenever the handler skips the lock or reads Old before taking it. **Why it is safe:** mutants of `putChatPlanModeInstructions`, run with `go test -overlay`: | Mutant | Deleted test on `main` | `SingleEntry` on `main` | `SingleEntry` after | `AuditLockFailureRejectsWrite` | |---|---|---|---|---| | `AcquireLock` call removed | passed 20 of 20 | failed 2 of 20 | failed 5 of 5 | failed 20 of 20 | | `AcquireLock` moved after the Old read | passed 20 of 20 | failed 2 of 20 | failed 10 of 10 | passed 20 of 20 | The deleted test passed on both mutants, so it guarded no handler line. On `main` the positive test caught a missing lock only when the two PUTs happened to overlap, and 8 or 16 concurrent PUTs did not raise that rate. With the lock held, it fails on every run of both mutants and passed 30 of 30 runs on the real handler, plus 5 under `-race`. The lock-holding pattern is the one in `coderd/experiments/write_test.go`. **Review focus:** the `pg_locks` wait counts every waiting advisory lock in the test database. This subtest creates no chats, so chatd never requests its admission or heartbeat locks, and the two PUTs are the only waiters. **Timing** (`-count=1 -v`, median of 5 paired runs on a shared host): the deleted subtest took 0.80 s. `SingleEntry` took 0.70 s before and 0.58 s after. The whole `TestChatPlanModeInstructions` took 7.0 s before and 5.0 s after, though host noise is larger than that gap. **Validation:** - `go test ./coderd -run '^TestChatPlanModeInstructions$' -count=1`: pass - `go test ./coderd -run '^TestChatPlanModeInstructions$/^(AuditConcurrentIdenticalPUTsSingleEntry|AuditLockFailureRejectsWrite)$' -count=30`: pass - the same `SingleEntry` run with `-race -count=5`: pass - `go vet ./coderd` and `golangci-lint run ./coderd/...`: clean; the pre-commit hook passed > Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description. |
||
|
|
4e4a56b665 |
fix: show configured provider icons and names in AI settings (#31033)
Admin-configured provider icons were ignored on the AI Settings Models
page (model rows, Add model menu, provider filter, model form header and
provider select) and in Agents compaction settings. These views derived
the icon only from the provider type, so a provider like DeepSeek on an
OpenAI-compatible type showed a generic icon even though the Providers
page and chat model selector showed the configured one. They now pass
the configured icon to `ProviderIcon`, which falls back to the type
icon.
The Spend page showed provider types (OpenAI) instead of configured
providers (DeepSeek) because `ListOrganizationAISpendUsers` aggregated
`ai.provider` while its filter matched `ai.provider_name`. It now
aggregates `provider_name`, and the page resolves names to display names
and icons from the AI Gateway providers list, which it shares with the
provider filter through one query. `OrganizationAISpendUser.providers`
now holds provider names; records from before configured names existed
have the type as their name, so they render as before.
AI Gateway Sessions views have the same type-versus-name issue and are
left for a separate fix.
**Note:** the Spend page resolves provider display names and icons from
`/aibridge/providers`, which requires deployment-wide read access
(`viewAnyAIBridgeInterception`). Owners and Auditors see the custom
display name and icon; Template Admins, User Admins, Org Admins, Org
Auditors and Org User Admins see the provider name rendered as a type
without the icon. Revisiting that endpoint's permissions is tracked in
AIGOV-726.
Refs CODAGT-1421
<details>
<summary>Decision log</summary>
- Root cause: callers rendered `<ProviderIcon provider={type} />`
without the descriptor's `icon`; nothing was stale.
- Spend page provider metadata is fetched only for viewers who can
already use the provider filter (`viewAnyAIBridgeInterception`); other
viewers see names formatted like provider types.
- Extended `ProvidersBadge` with an optional `providersByName` map
instead of adding a Spend-specific badge, so the Sessions fix can reuse
it.
- Removed `providerTypeByIDFromUserConfigs`, which became unused once
compaction settings used `providerInfoByIDFromUserConfigs`.
- Visual coverage is in Storybook stories (ModelRow, ModelForm,
UserCompactionThresholdSettings, SpendPage) per the repo's FE1 rule.
</details>
---
_Generated by Coder Agents on behalf of @tracyjohnsonux._
|
||
|
|
b97d048862 |
fix(site/src/pages/AISettingsPage): open model settings filtered to the selected provider (#30392)
The "Model settings" link on a provider's settings page opened the full models list. It now opens `/ai/settings/models?provider=<provider id>`, so the models page shows only that provider's models. The models page already reads this query param for its provider filter. The link is also now a router `Link`, so it no longer triggers a full page reload. Fixes DES-22159. Tests: added an `UpdateProviderPageView` Vitest test that clicks the link and checks it lands on the models page with the provider's ID, and a `ModelsPageView` test that checks the `?provider=` URL param filters the list. --- _Generated with Coder Agents on behalf of @tracyjohnsonux._ |
||
|
|
8cf19bd03c |
chore: bump Node.js to 22.23.4 (#31263)
Bump the Node.js toolchain pinned in `mise.toml` from 22.19.0 to 22.23.4, the latest 22.x patch release, and regenerate `mise.lock` with `mise lock node` so `mise install --locked` resolves the new checksums. <details> <summary>Decision log</summary> - Scope is limited to the `mise` pin. `flake.nix` gets `nodejs_22` from nixpkgs and is not changed here. - Stays on the Node 22 line to match `site/package.json` `engines` (`>=22.0.0 <25.0.0`). - Lockfile checksums for linux-x64, linux-arm64, darwin-x64, darwin-arm64 and win-x64 were checked against the official `SHASUMS256.txt` for v22.23.4. - Checked locally on Node 22.23.4: `pnpm install`, `pnpm check`, `pnpm lint`, `pnpm build` and `pnpm test:ci` (4,997 passed) in `site/`. </details> _This PR was generated by Coder Agents on behalf of @Lisa-Fiander._ |
||
|
|
9fe52826da |
feat: send include_related from WorkspaceByOwnerAndName options (#29908)
Stacked on #29855. Wires `WorkspaceOptions.IncludeRelated` through `codersdk.Client.WorkspaceByOwnerAndName`. The method now applies `params.asRequestOption()` (matching `Client.Workspace`), so the `include_related` query parameter is sent to the server. Previously it only forwarded `include_deleted` and silently dropped `IncludeRelated`. - `include_deleted` behavior is unchanged: `asRequestOption` sets it when true; the server treats an omitted value the same as `false`. - Updated the `TemplateOnly` and `LatestBuildOnly` subtests of `TestWorkspaceByOwnerAndNameIncludeRelated` to drive narrowing through the SDK method and its options, exercising the wiring end to end. Option-level encoding is already covered by `TestWorkspaceOptionsAsRequestOption`. _This PR was created by Coder Agents on behalf of @spikecurtis._ |