Skip to content

test(coderd/x/chatd): make the zero wait timeout test reach the default - #30985

Draft
ibetitsmike wants to merge 2 commits into
mike/chatd-subagent-managerfrom
mike/chatd-subagent-await-timeout-test
Draft

ibetitsmike wants to merge 2 commits into
mike/chatd-subagent-managerfrom
mike/chatd-subagent-await-timeout-test

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

ZeroTimeoutUsesDefault passed a zero timeout to awaitSubagentCompletion, but it marked the child chat waiting first, so the call returned before it normalized the timeout. The test passed with the normalization deleted. This PR deletes it and turns the Timeout subtest into a two-row table, Explicit (1 s) and ZeroUsesDefault (0, which must become 5 minutes). Each row checks the duration of the trapped subagent_await timer, then advances the mock clock until the call times out.

Why it is safe

Mutants, applied with go test -overlay to TestAwaitSubagentCompletion:

Mutant Old tests New tests
Delete if timeout <= 0 { timeout = defaultSubagentWaitTimeout } pass ZeroUsesDefault fails: 0s, want 5m0s
defaultSubagentWaitTimeout = 1 * time.Minute pass ZeroUsesDefault fails: 1m0s, want 5m0s
Always use the default timeout Timeout fails after 25 s Explicit fails: 5m0s, want 1s

ZeroUsesDefault expects 5 * time.Minute rather than the constant, so it also pins the wait_agent schema text "Defaults to 5 minutes." The deleted subtest's assertions (no error, the child's ID, its report) duplicate AlreadyWaiting, which runs the same early-return path. With handleSubagentDone mutated to return an error, an empty chat, or an empty report, AlreadyWaiting fails each time.

Review focus

The clock moves in steps of at most 5 s, because the pubsub fallback poll ticks every 5 s and the mock clock cannot advance past a pending tick in one step. The zero row takes 60 steps and runs in about 0.2 s.

Validation

  • go test ./coderd/x/chatd/ -run '^TestAwaitSubagentCompletion$' -count=1: pass.
  • go test ./coderd/x/chatd/ -race -run '^TestAwaitSubagentCompletion$/^Timeout$' -count=20: pass.
  • Mutants: a copy of subagent_manager.go with a syntax error fails to build, so the overlay applies.
  • The pre-commit hook (make pre-commit) passed.

Stack

This PR is stacked on #28758, which moves awaitSubagentCompletion into subagent_manager.go.

  1. refactor(coderd/x/chatd): extract subagent manager #28758 refactor(coderd/x/chatd): extract subagent manager
  2. test(coderd/x/chatd): make the zero wait timeout test reach the default #30985 test(coderd/x/chatd): make the zero wait timeout test reach the default (this PR)

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

ZeroTimeoutUsesDefault marked the child chat waiting before it called
awaitSubagentCompletion with a zero timeout, so the call returned before
it normalized the timeout and the test passed with the normalization
deleted. Delete it and turn the Timeout subtest into a two-row table that
checks the trapped subagent_await timer's duration (1s explicit, 5m for
zero) before advancing the mock clock to the timeout.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T18:43:31.109574Z cb6ad32 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: f8f1ac2c3d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: cb6ad32735

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant