Skip to content

test(coderd/x/chatd): reuse recordingPubsub in the task test fixture - #30923

Draft
ibetitsmike wants to merge 2 commits into
mainfrom
mike/chatd-shared-recording-pubsub
Draft

ibetitsmike wants to merge 2 commits into
mainfrom
mike/chatd-shared-recording-pubsub

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

tasks_test.go kept its own copy of the recording pubsub, taskRecordingPubsub (59 lines), next to recordingPubsub in helpers_test.go. This PR adds the three things the copy had (clear, a published snapshot and an onPublish hook) to recordingPubsub, points the task fixture at it, and deletes the copy. The task fixture now reaches the raw pubsub through the embedded field, so its rawPS field goes too.

Why it is safe

  • The added methods behave like the copy's: onPublish runs outside the lock and before the inner Publish, clear drops the recorded events, and published returns a copy taken under the lock. It replaces the copy's events(), which would collide with the existing events field.
  • recordingPubsub embeds the full dbpubsub.Pubsub, so subscriptions reach the same inner pubsub the copy forwarded SubscribeWithErr to. Servers built by the task helpers still get the raw pubsub.
  • watchEvents is the existing recordingPubsub method. It filters the same way the copy did, reading under the lock instead of from a snapshot.
  • After the change, rg 'taskRecordingPubsub|taskPublishedEvent|rawPS' coderd/ finds nothing.

Review focus

The turn-trace tests set f.pubsub.onPublish while holding f.pubsub.mu. Both names are unchanged, and Publish still reads the hook under that lock.

Validation

I built the package test binary with go test -c ./coderd/x/chatd/ (and with -race). Ten files use either fixture: tasks_test.go, hooks_internal_test.go, turn_trace_internal_test.go and the seven workerTestFixture files. I ran the 142 top-level tests in the ten files with -test.count=1 -test.parallel 4.

Head Plain -race
main (e289c6fe011) 142 passed 142 passed, no data races
this PR 142 passed 142 passed, no data races

The pre-commit hook passed.

Stack

The stack folds the task test fixture into the shared worker test fixture.

  1. test(coderd/x/chatd): reuse recordingPubsub in the task test fixture #30923 reuse recordingPubsub in the task test fixture (this PR)
  2. test(coderd/x/chatd): fold taskTestFixture into workerTestFixture #30924 fold taskTestFixture into workerTestFixture

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

taskRecordingPubsub duplicated recordingPubsub with a clear method, an events snapshot and an onPublish hook. recordingPubsub now has those three, so the task fixture uses it and reaches the raw pubsub through the embedded field instead of a separate rawPS.
@ibetitsmike
ibetitsmike added this pull request to stack #30925 October 18, 2026 14:44
@ibetitsmike ibetitsmike changed the title mike/chatd shared recording pubsub test(coderd/x/chatd): reuse recordingPubsub in the task test fixture Oct 18, 2026
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@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-18T17:25:38.011838Z 54bc9c4 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. Bravo.

Reviewed commit: 4fd409a20e

ℹ️ 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, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 54bc9c4df6

ℹ️ 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