Skip to content

🤖 fix: attach useVoiceInput's key listeners on mount so its test imports it normally - #4609

Merged
ThomasK33 merged 2 commits into
mainfrom
test-audit/ws7-10-voice-lazy-listeners
Sep 25, 2026
Merged

ThomasK33 merged 2 commits into
mainfrom
test-audit/ws7-10-voice-lazy-listeners

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

useVoiceInput now attaches its Space-held tracking listeners when the hook mounts instead of when the module is first evaluated, so its test imports the hook normally (no per-test require("./useVoiceInput?test=<uuid>")). Also drops a leftover stub for the deleted useProjectGitStatuses export.

Background

The module registered keydown/keyup/blur listeners on window at load time. One process-wide instance therefore stayed bound to whichever window existed when some file first imported it (or to none if that happened without a DOM). useVoiceInput.test.tsx had to load a fresh module per test, and a static import failed all 8 tests in the full browser suite (#4554). Fixes #4554.

Implementation

  • The tracker is a per-hook ref updated by listeners added in a mount effect (window event subscriptions are an external system, so an effect is appropriate) and removed on unmount. The recording-keybind effect reads that ref where it used to read the module variable.
  • Listener order is unchanged: the tracker is registered at mount, before the recording-only keybind listeners.
  • Behavior difference: Space presses before any useVoiceInput consumer mounts are no longer seen. The only consumer (ChatInput) mounts with the composer, long before a recording can start.
  • MultiProjectGitStatusIndicator.test.tsx: removes the useProjectGitStatuses entry from its store stub (the export was deleted in 🤖 tests: delete dead StatsTab, comparators, and test-only browser exports #4472).

Validation

  • useVoiceInput.test.tsx with a static import: 8 pass alone and in the previously failing order ProjectPage.autofocus → SelectableDiffRenderer.dragSelect → useVoiceInput (12 pass).
  • Mutation: making the tracker never record a held Space fails "guest Space keyup cannot clear the host held-at-start guard".
  • Whole bun test src/browser in one process: 4279 pass, 0 fail.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $67.78

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 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-09-25T21:21:19.156228Z dac2bc1 Manual request
🔒 Security Review ✅ Completed 2026-09-25T21:21:42.822560Z dac2bc1 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. 🎉

Reviewed commit: dac2bc1c01

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: dac2bc1c01

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit 2810bf2 Sep 25, 2026
30 of 31 checks passed
@ThomasK33
ThomasK33 deleted the test-audit/ws7-10-voice-lazy-listeners branch September 25, 2026 21:58
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.

🤖 useVoiceInput binds window listeners at module load, blocking a static test import

1 participant