Repository navigation
Conversation
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
56a7b203-c3a9-4a0a-9537-62f24be0fa1d
📒 Files selected for processing: 2
mobile/src/session/mobile-dictation-mode-refresh.test.tsxmobile/src/session/use-mobile-session-native-chat-dictation.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| try { | ||
| const setup = await fetchDictationSetup(client) | ||
| setDictationMode(setup.dictationMode) | ||
| if (read === dictationModeReadRef.current) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Invalidate old reads when the connection changes.
If the connection changes before the focus effect cleanup runs, a reply from the old connection can still pass the generation check. Invalidate the read generation during the connection-change commit so the old reply cannot update the microphone mode.
Source: Learnings
Honor enabled voice settings across terminal/chat controls and capture. Refresh hold/toggle state on connection, focus and foreground while fencing stale replies. Adversarial review: 63 existing tests plus six disable/late-finish/unmount/settings ownership probes pass; final required CI and aggregate gate pass. Existing native screenshots and microphone lifecycle exercise are attached to the PR. Fixes #30307. Fixes #30511. Adapted from community #30316 and #30513 by @innocarpe. Co-authored-by: Wooseong Kim <[email protected]>
|
Closing as superseded by merged #31349 ( Native hold/toggle, reconnect and foreground behavior were exercised and screenshots attached to #31349. Independent adversarial review passed 63 existing tests plus six disable/late-finish/unmount/settings-race probes; CI and aggregate gate passed. Thank you @innocarpe. |
ELI5
The phone remembers whether you hold or tap the mic to dictate, but it only asked the desktop once, sometimes before it was even connected. Now it asks again when the connection comes up or the app comes back.
What Changed
refreshDictationModeinuse-mobile-session-native-chat-dictation.ts:[client, connState]and only once the connection isconnected(a read before that is rejected by the relay);activewhile the screen is focused;Before: a cold start or reconnect could leave the mic in toggle mode while the host was set to hold (or the reverse). After: the mic follows the host's current setting after connecting, reconnecting or returning to the app.
Why
The client is a long-lived logical object that survives reconnects, so keying the read on it alone misses every reconnect. Keying on connection state follows the same pattern as other host-backed settings in the session screen (
use-live-worktree-name.ts, tab reconciliation).Linked Issue
Fixes #30511
Visual Proof
N/A — no new UI; the existing mic binds hold (press-in/out) or toggle (tap) according to the mode it reads. The regression tests below assert that binding after connect and reconnect.
Testing
New
mobile-dictation-mode-refresh.test.tsx(4) mounts the real screen-state hook, the dictation hook andMobileTerminalInputActionswith a client that rejects reads while disconnected and keeps its identity across reconnects: first connect, reconnect, a late reply from a dropped connection, and app-foreground/focus-loss cleanup. Without the change all 4 fail; with it they pass, together with the existingmobile-dictation-refused-start-routing.test.tsx.Mobile
tsc --noEmit, the tests typecheck ratchet, and oxfmt/oxlint on the changed files passed.Not run: the full mobile suite, a release build, or a physical device check.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Prepared with Claude Code (Claude Opus).
Review
Self-review: mobile-only; uses the existing
speech.models.listread, so no host or protocol change and the same behavior over local, SSH and relay connections. Adds at most one small read per connect or app foreground. No security impact. If #30316 (hide the mic when dictation is disabled) lands first, itssetDictationEnabledline in the same function should sit under the same request guard; the conflict would be textual and small.Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)