test(coderd/x/chatd): pin TestGetWorkspaceConn_StatusCheck to mock clock - #25130
#25130Merged
ibetitsmike merged 1 commit intoMay 11, 2026
maincoder/coder:mainfrom
mike/codagt-369-fix-chatd-status-check-flakecoder/coder:mike/codagt-369-fix-chatd-status-check-flakeCopy head branch name to clipboard
Merged
test(coderd/x/chatd): pin TestGetWorkspaceConn_StatusCheck to mock clock#25130ibetitsmike merged 1 commit intomaincoder/coder:mainfrom mike/codagt-369-fix-chatd-status-check-flakecoder/coder:mike/codagt-369-fix-chatd-status-check-flakeCopy head branch name to clipboard
ibetitsmike merged 1 commit into
maincoder/coder:mainfrom
mike/codagt-369-fix-chatd-status-check-flakecoder/coder:mike/codagt-369-fix-chatd-status-check-flakeCopy head branch name to clipboard
Conversation
The TimedOutAgentCacheHit, CacheHitHealthyAgent, and CacheHitDBError subtests built their WorkspaceAgent timestamps with time.Now() in the test slice literal and then ran the actual check against the server's real wall clock. On slow runners, more than agentInactiveDisconnectTimeout (30s) of wall time could elapse between slice construction and the subtest body, so the cached agent was reclassified as disconnected and CacheHitHealthyAgent failed with errChatAgentDisconnected. Build each agent inside the subtest with quartz.NewMock(t) and feed the same clock into the Server so the agent timestamps and status math share one frozen now. Reproducing the flake by inserting a 35s sleep at the top of the subtest body reliably triggers the original failure on the parent commit and is fixed by this change. Closes coder/internal#1522 Co-authored-by: Coder Agents <noreply@coder.com>
ibetitsmike
added a commit
that referenced
this pull request
May 11, 2026
…ies (#25141) PR bodies copied from a commit message body keep their 72/80-column hard wraps, and GitHub renders those as ragged-right line breaks instead of soft-wrapped paragraphs (e.g. the original body of #25130, fixed in this branch). The rule already exists in `.claude/docs/PR_STYLE_GUIDE.md`, but it is buried in a 200-line style guide and easy to miss when an agent is mechanically running `gh pr create`. This change adds a short "Body Formatting" section directly to `.agents/skills/pull-requests/SKILL.md`, which is the proximate context loaded at PR-write time, and explicitly tells callers to unwrap commit-message paragraphs before reusing them as a PR body. > Generated by Coder Agents on behalf of the assignee.
ibetitsmike
marked this pull request as ready for review
May 11, 2026 17:53
ThomasK33
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
TimedOutAgentCacheHit,CacheHitHealthyAgent, andCacheHitDBErrorsubtests ofTestGetWorkspaceConn_StatusCheckbuilt theirWorkspaceAgenttimestamps withtime.Now()in the parent test's slice literal and then ran the actual check against the server's real wall clock (quartz.NewReal()). On slow Windows CI runners, more thanagentInactiveDisconnectTimeout(30s) of wall time can elapse between slice construction and the parallel subtest body. In that window, the cached "healthy" agent gets reclassified as disconnected byagentDisconnectedFor, andCacheHitHealthyAgentfails witherrChatAgentDisconnectedinstead of returning the cached connection.Build each agent inside the subtest with
quartz.NewMock(t)and feed the same clock into theServerso the agent timestamps and the status math share a single frozennow. This matches the pattern already used byTestGetWorkspaceConn_DialTimeoutDisconnectedRecoveryThresholdin the same file.Closes coder/internal#1522
Verification
Inserting
time.Sleep(35 * time.Second)at the top of each subtest's body reliably reproduces the original failure (errChatAgentDisconnectedonCacheHitHealthyAgent) on the parent commit and passes with this change. After removing the synthetic sleep,go test ./coderd/x/chatd -run TestGetWorkspaceConn_StatusCheck -count=50passes cleanly.