Repository navigation
feat(mobile): dictation on the OTA page over native audio verbs (Phase C, C7.10 PR D) - #21905
Conversation
The page owns dictation's state machine and speaks `speech.dictation.*` to the desktop, where transcription runs; the microphone is the shell's. So the shell gains `native.audio.start|read|stop` and `native.wakelock.set` — four rows, four grants — and rings what the microphone produces at the page's own pending-audio budget rather than pushing bytes the page would hand straight back. `native_audio_not_capturing` joins the refusal vocabulary: a read for a capture this session does not have is the one refusal the page must tell from a device that failed. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`use-mobile-dictation.ts` held the microphone and the wake tag directly, so the page had a hook whose every device call was a stub answering denied. The five calls move behind `src/platform/dictation-capture.ts`: natively the same calls in the same order, on the page the shell's four verbs, with the drain raising the events the engine emits. The tag bookkeeping stays where it was and stops importing `expo-keep-awake`: two calls come in through the seam and the pools, the queue, the timeouts and the retries are the same on either host. The chunk sender is untouched. A chunk carries raw PCM because that is what the budget counts and what `speech.dictation.chunk` is built from, so the page pays one decode of 32 KB a second rather than the flow carrying two shapes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
One `speech.dictation.chunk` per native microphone event is 31.25 forwarded requests a second, and each holds one of the bridge's 64 in-flight slots for a whole desktop round trip. Measured over ten seconds against a two-second link: 63 in flight at the peak and one slot left for the rest of the page. Drained every 500 ms instead: 5 in flight, 60 slots free, the same 42 KiB/s, and 38 frames out and 34 back for the whole session. The frame cap was never the bound — half a second of PCM is 3.3% of one. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Which routes need the four audio verbs is a census, not a hand list: the rule reads each registered page route's own closure and holds its `grants` to what that closure reaches. Vacuous on today's route list — the session route is the only closure carrying the seam and is not registered yet — so a control runs the same rule against the session module and names all four as missing. The closure also records what the seam took off the page: `@orca/expo-two-way- audio` and `expo-keep-awake` are gone from it entirely, and removing the web file puts four of the vendored stub's modules back. The mic control's render case found a real one. A start the shell refused outright left the button on "Starting voice dictation" with no way back, which is every tap on a route without the grants. It reports the refusal and returns to idle. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…echeck A `let` the renderer assigns inside a callback narrows to `never` afterwards, and the mocked `Pressable` took `children` as `unknown`. Both are type-level only, and the ratchet is the gate that notices: a test outside `tsc` can pin a shape that stopped existing. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change adds a pull-based mobile web dictation bridge with audio start, read, stop, and wakelock verbs. Native and web capture implementations share a capture contract. Dictation now uses that contract for audio, interruptions, cleanup, and keep-awake ownership. Native audio uses bounded buffering with dropped-byte reporting. Tests cover bridge schemas, lifecycle behavior, route grants, dependency closures, bridge capacity, and microphone control behavior. Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed change and verification information, but it does not complete the repository template. It omits the required ELI5, What Changed, Why, Linked Issue with a Fixes reference, Visual Proof or N/A statement, Testing checkboxes, AI Disclosure, Review, Notes, and Checklist sections. Resolution Rewrite the description using all required template headings. Add a linked issue in the required Fixes # format, provide visual proof or state N/A with a reason, complete the Testing and Checklist items, and address AI Disclosure, Review, Agent skill upstream boundary, and Notes. ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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: af3ab19e-5b5e-4b26-936d-2af0e68bcc72
📒 Files selected for processing (29)
config/scripts/mobile-web-app-session-dictation-capture.test.mjsmobile/packages/expo-two-way-audio/src/ExpoTwoWayAudioModule.web.tsmobile/src/hooks/mobile-dictation-foreground-keep-awake.tsmobile/src/hooks/mobile-dictation-keep-awake.test.tsmobile/src/hooks/mobile-dictation-keep-awake.tsmobile/src/hooks/use-mobile-dictation-source.test.tsmobile/src/hooks/use-mobile-dictation.tsmobile/src/mobile-web-shell/MobileWebShellScreen.test.tsxmobile/src/mobile-web-shell/bridge-host-errors.tsmobile/src/mobile-web-shell/bridge-host-init.test.tsmobile/src/mobile-web-shell/bridge/bridge-audio-verbs.test.tsmobile/src/mobile-web-shell/bridge/bridge-audio-verbs.tsmobile/src/mobile-web-shell/bridge/bridge-native-verbs.test.tsmobile/src/mobile-web-shell/bridge/bridge-native-verbs.tsmobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.tsmobile/src/mobile-web-shell/bridge/use-native-verbs.tsmobile/src/mobile-web-shell/page-route-policy.test.tsmobile/src/platform/dictation-capture-bridge-budget.test.tsxmobile/src/platform/dictation-capture-contract.tsmobile/src/platform/dictation-capture.tsmobile/src/platform/dictation-capture.web.test.tsxmobile/src/platform/dictation-capture.web.tsmobile/src/platform/native-audio-device.tsmobile/src/platform/native-audio.tsmobile/src/platform/native-wakelock.tsmobile/src/platform/use-native-device-verbs.test.tsxmobile/src/platform/use-native-device-verbs.tsmobile/src/session/mobile-dictation-mic-control.web.test.tsxmobile/web-entry/web-overrides.json
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| const serveWakelock = useMemo(() => createNativeWakelockServer(nativeWakelockDevice), [sessionId]) | ||
| useEffect(() => () => audio.dispose(), [audio]) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Wake tags held by the shell are never released when the page session ends. The session cleanup disposes the audio capture only, and the wakelock server keeps its held tags in a Set with no release path. If the page navigates, faults, or is swiped away while dictation holds a tag, the page never sends native.wakelock.set with active: false, so activateKeepAwakeAsync stays in effect and the screen never locks again for the app's lifetime.
mobile/src/platform/use-native-device-verbs.ts#L30-L31: dispose the wakelock server alongside the audio capture in the session cleanup effect.mobile/src/platform/native-wakelock.ts#L19-L22: return a handle that exposes both the verb handler and adisposethat deactivates every tag still inheld.
🔒 Proposed fix
--- a/mobile/src/platform/native-wakelock.ts
+++ b/mobile/src/platform/native-wakelock.ts
-export function createNativeWakelockServer(
- device: WakelockDevice
-): (params: unknown) => Promise<{ active: boolean }> {
+export type NativeWakelockServer = {
+ readonly serve: (params: unknown) => Promise<{ active: boolean }>
+ /** Gives back every tag this session still holds; the page session's end calls it. */
+ readonly dispose: () => void
+}
+
+export function createNativeWakelockServer(device: WakelockDevice): NativeWakelockServer {
const held = new Set<string>()
- return async (params) => {
- const { active, tag } = wakelockSetParamsSchema.parse(params)
- if (active) {
- await device.activate(tag)
- held.add(tag)
- return { active: true }
- }
- if (held.delete(tag)) {
- await device.deactivate(tag)
- }
- return { active: false }
- }
+ return {
+ serve: async (params) => {
+ const { active, tag } = wakelockSetParamsSchema.parse(params)
+ if (active) {
+ await device.activate(tag)
+ held.add(tag)
+ return { active: true }
+ }
+ if (held.delete(tag)) {
+ await device.deactivate(tag)
+ }
+ return { active: false }
+ },
+ dispose: () => {
+ for (const tag of held) {
+ void device.deactivate(tag).catch(() => undefined)
+ }
+ held.clear()
+ }
+ }
}--- a/mobile/src/platform/use-native-device-verbs.ts
+++ b/mobile/src/platform/use-native-device-verbs.ts
- const serveWakelock = useMemo(() => createNativeWakelockServer(nativeWakelockDevice), [sessionId])
- useEffect(() => () => audio.dispose(), [audio])
+ const wakelock = useMemo(() => createNativeWakelockServer(nativeWakelockDevice), [sessionId])
+ useEffect(() => () => audio.dispose(), [audio])
+ useEffect(() => () => wakelock.dispose(), [wakelock])
return useMemo(
() => (verb, params) => {
if (verb === 'native.clipboard.write' || verb === 'native.clipboard.read') {
return serveNativeClipboardVerb(verb, params)
}
if (verb === 'native.wakelock.set') {
- return serveWakelock(params)
+ return wakelock.serve(params)
}
return verb.startsWith('native.audio.') ? audio.serve(verb, params) : serveMedia(verb, params)
},
- [audio, serveMedia, serveWakelock]
+ [audio, serveMedia, wakelock]
)The test callers in mobile/src/mobile-web-shell/bridge/bridge-audio-verbs.test.ts and mobile/src/platform/dictation-capture.web.test.tsx call the returned value directly, so they need the .serve member after this change.
📍 Affects 2 files
mobile/src/platform/use-native-device-verbs.ts#L30-L31(this comment)mobile/src/platform/native-wakelock.ts#L19-L22
There was a problem hiding this comment.
Important
Two real, currently-untested issues: the page cancels dictation on an 'ended' audio interruption that the native half ignores, and the shell's wake-lock server never releases a held tag when the page session ends. Both have small fixes; everything else read clean.
Reviewed changes
- Four native audio verbs —
native.audio.start|read|stopandnative.wakelock.setadded to the verb table with strict Zod schemas, the newnative_audio_not_capturingrefusal code, and grant names held toGRANT_NAME_PATTERN(bridge-audio-verbs.ts,bridge-native-verbs.ts). - Shell capture over a budget-sized ring —
native-audio.tsrings PCM (drop-newcomer), reportsdroppedBytes/recording/interruptionon each read, clears the drop count per drain, and replaces a capture a dead page left behind. - Device halves —
native-audio-device.ts/native-wakelock.tsmake the engine injectable so the denied-permission, full-ring and interruption arms are unit-testable without a simulator. - One capture seam, two hosts —
dictation-capture-contract.tsplusdictation-capture.ts(native) anddictation-capture.web.ts(page);use-mobile-dictation.tsand the keep-awake owner now take an injectedDictationKeepAwakeDeviceinstead of importing Expo directly. - 500 ms page drain — the page pulls the ring on a timer;
dictation-capture-bridge-budget.test.tsxmeasures in-flight slot cost againstBRIDGE_MAX_PENDING_REQUESTSat both the native event rate and the shipped interval. - Tests/census — route-closure grant census, web-overrides reason update, mic-control render cases covering the ungranted-route refusal and the granted route reaching recording.
Two inline comments follow. A minor note: canCaptureAudio (use-native-verbs.ts:84) is documented as the page's only microphone but never read — dictation-capture.web.ts maps the start refusal instead — so it is currently dead; either wire it into the composer's disabled state or drop it.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…e shell `end` cancelled the drain and stopped the capture without a last read, so up to one drain interval of the utterance's tail — 16,000 bytes, the 400 ms a user is still speaking as they lift the button — was discarded on every stop. The reviewer's probe spoke 12,288 bytes in the last 400 ms and the page delivered none of them. Natively that audio is already in the hook's hands, so this was a page-only loss of the end of every sentence. `end` is now asynchronous: it cancels the timer, waits for any read in flight, reads once more, and only then stops the shell — stopping first takes the capture away and the read after it is refused. `stop()` awaits it before it stops accepting chunks and before it takes the pending set, or the tail would be dropped one line later and `finish` could overtake the last send. A release still skips the last read: the screen is going away and there is nobody left to hand the tail to. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The wake-lock server held its tags per instance and a new one was built per page
session with nothing ever disposing it, so a tag a session took was never given
back and the screen stayed awake for the app's lifetime. The page is a document
that can navigate, fault or be swiped away mid-dictation, so nothing else was
ever going to call deactivate. Its own docstring claimed the opposite.
It now answers `{ serve, dispose }` and is disposed with the session exactly as
the microphone and the staged media handles are. `dispose` drops only what is
still held, so a tag the page already gave back is not deactivated twice.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`canCaptureAudio` answered four grants to nobody and had no test. The fence that actually holds is the per-verb `ungranted` check every member already makes before a frame is sent, and the mic control's render case pins what a screen does with it. The surface's member list is pinned instead, so the next flag with nothing behind it has to be added there on purpose. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…d make its controls real Three corrections to the census, all of them about the census lying rather than the product being wrong. The recorded number was four modules; measured on this head it is eight — five from `@orca/expo-two-way-audio` and three from `expo-keep-awake` — for a net +7 once the local file that left is counted. The absolute closure counts are provenance in the docstring and are not asserted, because every merge of main moves them. The absence now has a precondition: both package names are resolved from the install, so a substring matching nothing fails as a typo. The case named "reads the census file" read no file. It reads the shell's own verb table through `import()`, behind the closure guard, so a grant the shell has no row for reds instead of agreeing with itself. And the grant control re-implemented the rule's filter inline. Both the rule and the control drive one function now, over the entry C7.7 would write if it copied its neighbours' grants. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Two starts racing the OS permission prompt — a page reloaded while it is up, which is the case the replacement rule exists for — both reached `listen()`, and the second overwrote the first's handlers without removing them. The engine went on calling into a capture nobody could read, and `dispose` freed one of the two. A stop that overlapped a start found nothing to end and the start opened a microphone behind it. Starts and stops now run one at a time in the order the page asked for them, and a start that comes back after the session ended opens nothing. Reads stay off the queue: they must not wait behind an opening capture, and a read with no capture is already a refusal. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The page treated any interruption as the capture being taken away, while the native seam has always gated on `began` and `blocked`. So an `ended` on its own — the OS handing the session back after a notification chime — cancelled a live dictation on the page and did nothing natively. The rule is now one predicate beside the vocabulary it belongs to, read by all three places that decide it: the shell, which stops filling its ring; the native seam, which raises it off `onAudioInterruption`; and the page, which raises it off a read reply. `recording` still ends the page's capture whatever the kind, because a capture the shell no longer has is gone however it went. The native half had no test of its own, which is why the drift was invisible. It has one now: the five calls it makes, the chunk it hands over, the wake tag, and which interruptions end it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The sender's parameter was the native `MicrophoneDataEvent` though both callers hand it a `DictationCaptureChunk`. Structurally the event is the wider type, so it accepted either and read `droppedBytes` off neither — a page whose audio the shell's ring had dropped would have sent it as though nothing were missing, and nothing would have failed to compile. Typed as the chunk, with a compile fence beside the seam holding both directions: a chunk is accepted, an event is refused, and a raw buffer is not a chunk. The seam normalises the bytes, so the widening the sender did has no caller left. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ules on it The capture seam moves this count down rather than up. Measured at 2d697a4 and at this head: modules 4,324 to 4,319 and local modules 974 to 977. Three local modules join — the page's capture seam, its contract and the audio verb shapes — and eight vendored ones leave, because the seam is what stops the page importing a microphone it does not have: five of `@orca/expo-two-way-audio` and three of `expo-keep-awake`, replaced by four verbs the shell answers. Named beside the sentences already there, with the counterfactual that puts the eight back pointing at the census that runs it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
# Conflicts: # config/scripts/mobile-web-app-session-terminal-closure.test.mjs
…dules C2.9 moved this pin to 4,326 by putting the page-route grants and the manifest grammar behind `bridge-envelope.ts`, which every page closure reads. Dictation's capture still moves it down from wherever it lands: measured at 5d13a70 and at this head, modules 4,326 to 4,321 and local modules 976 to 979. Three local modules join — the page's capture seam, its contract and the audio verb shapes — and eight vendored ones leave, five of `@orca/expo-two-way-audio` and three of `expo-keep-awake`, replaced by four verbs the shell answers. Recorded beside C2.9's sentences rather than in place of them. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Every `mobileWebAppRouteClosure` call is a full esbuild metafile build, and the cases here ask about six route modules across nine of them — fifteen builds. The CPU that cost tipped two timing-sensitive neighbours in this shard over: a benchmark whose child has 100 ms to write a pid file, and a census globbing a scratch tree another test was removing. Neither is reached by this file and both are fragile without it; the added load was the difference. With the census excluded the shard was green, with it three runs of three were red. Memoised per route module, so six builds. The shard still fails intermittently on this machine for its own reasons, but not because of this file. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Caution
The round-1 tail fix makes the page's end() re-enter itself through the interruption lane: a refused read or an OS interruption calls interrupted() → the hook's cancel() → closeDictationAudio() → capture.end() again, with nothing guarding re-entry. On the page that is an unbounded loop issuing another bridge read every iteration. The two prior review threads are addressed and resolved; the two minor items are new in this delta.
Reviewed changes
- Async page
endwith a tail drain —dictation-capture.web.tsawaits the in-flight read and issues one lastnative.audio.readbeforenative.audio.stop; the contract'sendis nowPromise<void>andstop()awaits it while chunks stay accepted. - One interruption predicate —
bridgeAudioInterruptionEndsCapture(began || blocked) is shared by the shell, the native seam and the page, so a loneendedno longer cancels on the page;dictation-capture.test.tspins the native side. - Wakelock dispose —
createNativeWakelockServerreturns{ serve, dispose }, anduse-native-device-verbs.tsreleases held tags on session teardown. - Serialised audio starts/stops —
native-audio.tsqueuesstart/stopand refuses a start that lands after dispose, so overlapping permission prompts cannot leak listeners. - Surface and census cleanup — dropped the unread
canCaptureAudioand pinned the surface; reworked the dictation census (memoised closures, control drives the rule itself, install-resolution precondition) and re-pinned the terminal closure.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…e install `import()` defers when a module loads, not what loading costs. Vite transforms the file at that moment and resolves the nearest `tsconfig.json` for it, which is `mobile/tsconfig.json`, which extends `expo/tsconfig.base.json` — absent on the root-only shard, so the transform threw `TSConfckParseError` and reddened `test / tests node 24 1/8`. The comment claiming the dynamic import avoided that was wrong. Gated on `mobileWebAppDependenciesPresent()`, the same guard the closure cases use, which is the only thing that keeps a mobile module off that shard. Reproduced both ways in this tree by moving `mobile/node_modules` aside: before, 1 failed with that error; after, 3 passed and 6 skipped; with the install back, 9 passed. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The hook's interruption handler is `() => void cancel()`, and `cancel` reaches `capture.end()` synchronously through `closeDictationAudio`. So the last read in `end` could raise an interruption that called straight back into `end`, whose own last read was refused for the same reason the first was — the shell has no capture — and the recursion issued bridge reads until the page ran out of memory. The pin crashed the test worker with `JavaScript heap out of memory` before the fix. A second `end` returns the first one's promise, assigned before anything can await so a handler re-entering from inside the read finds it set. `begin` clears it, because the seam is memoised per client and the next dictation on the same screen has to be able to drain — pinned by a case that ends, starts again and reads the new audio. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`held.add(tag)` ran after the device call, so a `dispose()` falling between the activate and its reply walked an empty set and the tag was recorded afterwards. Nothing walks that set again, so the screen stayed awake for the app's lifetime — and the page is a document that can be swiped away mid-dictation, which is exactly when that window is open. A tag that lands after the session ended is deactivated on the spot and reported to the page as not held. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The contract says `end` never rejects, and the native one did: it is `async`, so a throwing JSI binding rejects rather than throws. Every caller reaches it as `void capture.end()` inside a synchronous `try`, which cannot see a rejection — so a device that would not stop recording left an unhandled rejection, and the cleanup the `try` was written to protect was never what was at risk. `release` was worse in kind: it runs bare in the unmount path, so a throwing `tearDown` took the wake tag's release and the desktop's cancel with it. Both log and continue. Pinned behaviourally against an engine that refuses to stop and a tear-down that throws; the source case that claimed the hook's `try` was the guard now says where the guard actually is. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The tail fix depends on `await capture.end()` running before chunks stop being accepted, and nothing held that: the source check only asserts `end()` precedes `Promise.allSettled`, which both orders satisfy, so reversing the two lines left the whole mobile suite green while the page silently dropped the end of every sentence. Driven against a capture whose `end()` delivers a chunk — what the page's seam does and the device's never does, which is why only this case can tell the orders apart. It asserts the tail reaches the desktop as `speech.dictation.chunk`, with those bytes, before `finish`; reversed, no chunk is sent at all. The mocked seam is one object for the module's life, because the hook keys its teardown effect on the capture's identity: a seam returning a fresh object per render cancels the dictation on every render. Both real seams are stable. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`held` was cleared whether or not `deactivate` succeeded, so a tag the device refused was forgotten. The page's owner queues exactly that failure for a retry (`pendingCleanupTags`), and the retry arrives here as another `active: false` — which a shell that had already forgotten the tag answered without calling anything, leaving the native tag on for the life of the app. The boundary: the set means "the device still has this tag", not "the page asked for it". That keeps the reason the set exists — never call `deactivateKeepAwake` for a tag this shell never took, since its failure would read to the page as a wake lock it could not drop — while letting every retry for a live tag through. Always reaching the device regardless of the set would have traded the second property for the first. Pinned with a device that refuses once and then accepts, and with a dispose whose deactivation is refused. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A start that came back after `dispose()` returned without ending the engine, and the local `end()` is a no-op with no capture, so nothing tore down the session `initialize()` had just brought up. Nobody else would: the dispose had already run and no capture was ever recorded. The device's audio session stayed up for the life of the app. It ends the engine on that path now. Pinned on both places the race can be lost — inside the permission prompt and inside the open itself — each asserting exactly one teardown and no live listeners. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The hand-rolled client fake needed three type assertions to stand in for an `RpcClient`, which the changed-code quality gate refuses on new lines. It drives `createFakeRpcClient` instead — a real one — answering each request as the hook makes it, and reads the chunk's base64 by narrowing rather than asserting. Re-confirmed the pin still reds on the reversed order after the rewrite. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Clean up the opened session when engine.begin() throws. · native-audio.ts:202
mobile/src/platform/native-audio.ts:202
🩺 Stability & Availability | 🟠 Major | ⚡ Quick winClean up the opened session when
engine.begin()throws.If
engine.begin()throws,start()rejects after registering both listeners. The queue advances after rejection, but it does not callend(). The hook cleanup runs only when the session unmounts or changes. Wrapengine.begin()intry/catch, callend(), and rethrow the original error.Proposed fix
- if (!engine.begin()) { - end() - return { started: false, sampleRate: opened.sampleRate, permission } - } + try { + if (!engine.begin()) { + end() + return { started: false, sampleRate: opened.sampleRate, permission } + } + } catch (error) { + end() + throw error + }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 0555ebf1-51d4-4ed9-aa9f-16d094d44043
📒 Files selected for processing (10)
config/scripts/mobile-web-app-session-dictation-capture.test.mjsmobile/src/hooks/mobile-dictation-stop-tail.test.tsxmobile/src/hooks/use-mobile-dictation-source.test.tsmobile/src/mobile-web-shell/bridge/bridge-audio-verbs.test.tsmobile/src/platform/dictation-capture.test.tsmobile/src/platform/dictation-capture.tsmobile/src/platform/dictation-capture.web.test.tsxmobile/src/platform/dictation-capture.web.tsmobile/src/platform/native-audio.tsmobile/src/platform/native-wakelock.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- mobile/src/hooks/use-mobile-dictation-source.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
# Conflicts: # config/scripts/mobile-web-app-session-terminal-closure.test.mjs
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the eight commits since the prior pullfrog review (798c4c25ae → 65d10d1b75), which fold the round-2 findings and add their regression tests.
- Native
end/releaseno longer reject —dictation-capture.tswrapstoggleRecording(false)andtearDown()in try/catch and logs, soendhonours its never-rejects contract andreleasecannot abort the rest of unmount cleanup. - Page
endis idempotent —dictation-capture.web.tsholds anendingpromise set before any await;begin()clears it,release()marks it ended. The interruption lane's re-entrantend()now returns that promise instead of issuing another bridge read, closing the unbounded loop. - Wakelock dispose/retry correctness —
native-wakelock.tsnow treatsheldas "the device still has the tag": it is deleted only after a successful deactivate,serve(active:false)calls the device while the tag is recorded, and an activation that resolves afterdisposeis given back and answered{ active: false }. - Start that loses the dispose race is torn down —
native-audio.tscallsengine.end()whenopen()succeeded but the session was disposed, so the audio session is not left up for the app's lifetime. - Regression tests —
mobile-dictation-stop-tail.test.tsxpins thestop()ordering (tail accepted and sent beforefinish);dictation-capture.test.tsdrives a throwing engine; the census's verb-table case is nowit.skipIf(!bundles)gated on the mobile install.
All three prior pullfrog threads are addressed and resolved. I traced each fix against the hook lifecycle (use-mobile-dictation.ts) and the shell handler; they hold, and no new findings surfaced.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
A finished `end` stayed in `ending` until `begin` cleared it, and `begin` is not guaranteed to run between two ends: `open` starts the shell recording, and a start that goes stale after the hook sets `activeIdRef` cleans up through `capture.end()` without ever committing. The second end answered from the first one's settled promise and never issued `native.audio.stop`, leaving the shell holding a live microphone. Cleared on settle instead, and only for its own flight. The re-entrancy the latch was really for happens while the promise is still pending, so guarding the flight is enough. `release` keeps its own flag rather than a settled `ending`, which now clears itself and would unlatch it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ompensating
Two ways the device could end up holding a tag nothing would ever give back.
A release that arrived while its own activate was still in flight read `held`
before the activate had recorded anything, found nothing, deactivated nothing and
reported the tag off; then the activate landed and the device stayed on. `held` is
read and written across an await, so operations are now chained per tag. Per tag
rather than per server, so one hanging device call cannot hold up another
dictation.
And on the late-tag path, a compensating deactivate the device refused was
swallowed while `{ active: false }` was returned: the device still held the lock,
`held` lacked the tag, `dispose` had already walked the set, and the page believed
an activate had succeeded. The tag is now recorded as soon as `activate` resolves,
deleted only once the device has really dropped it, and a refusal rejects so the
caller's retry path runs.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Queueing dispose behind each tag's own operations introduced a call the module says it does not make: a release already in flight can give the tag back before dispose runs, and deactivating an unheld tag is a native call whose failure would read to the page as a lock it could not drop. Re-reads the set when the queued action runs rather than trusting what it held when dispose was called. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the three commits since the prior pullfrog review (ffe4d6d785 → 86a298e1c1), which fold the CodeRabbit findings.
- Page
endno longer latches a settled promise —dictation-capture.web.tsclearsendingwhen it settles and adds areleasedflag (set byrelease(), cleared bybegin()), so anopen()-without-begin()cleanup still issues its last read and stop. - Shell wake tags serialised per tag —
native-wakelock.tsrunsserve/disposefor a tag through a per-tag promise queue, recordsheldthe momentactivateresolves (compensating whendisposed), and hasdisposere-checkheldonce its turn comes. - Regression coverage — the new
native-wakelock.test.ts(gated device) and the addeddictation-capture.web.test.tsxcase pin the late-activate compensation, per-tag independence, release-while-activate-in-flight, dispose re-read, and the end-after-open-without-begin path.
All prior pullfrog threads are resolved. I traced the new fixes against the documented callers — the re-entrant end through the interruption lane, a release landing during an in-flight end, and a dispose queued behind a release — and no new findings surfaced.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
# Conflicts: # config/scripts/mobile-web-app-session-terminal-closure.test.mjs
There was a problem hiding this comment.
Important
Merging main (963da57) leaves this PR's dictation census red: MOBILE_WEB_PAGE_ROUTES gained the source-control hub and diff-review routes, but mobile-web-app-session-dictation-capture.test.mjs still pins the five route modules it was recorded against. Both the test / tests node 24 8/8 shard and the mobile web app bundle job fail on it, so the PR cannot merge as-is.
Reviewed changes
This run re-reviewed the two merges of main since the prior pullfrog review (86a298e1c1 → 7a4e75dd1c).
- Merged
maine6de7a4bbe(C7.5c) — the render rig and HTML-preview iframe; one conflict in the session closure pin, re-recorded to 4,323. - Merged
main963da57— adds the source-control hub and diff-review page routes, takingMOBILE_WEB_PAGE_ROUTESfrom five entries to seven; clean merge, both sides'web-overrides.jsonentries intact. - One stale census — the dictation census's route-module assertion still lists the five routes it was recorded against, which the two new routes break.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the single commit since the prior pullfrog review (7a4e75dd → f6063f39).
- Re-recorded the dictation census —
mobile-web-app-session-dictation-capture.test.mjsnow pins all seven registered route modules, addingapp/h/[hostId]/source-control/[worktreeId].tsxandapp/h/[hostId]/review/[worktreeId].tsx. The previously red case passes locally.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Phase C, C7.10 PR D (ruling 26: the OTA page loses no capability; ruling 31: shape 1, the page pulls audio): voice dictation works on the page. The native app records the microphone through
@orca/expo-two-way-audioand streams chunks to the desktop asspeech.dictation.chunk; the page has no microphone, so it now asks the shell for one through four native verbs and forwards the audio with exactly the same call. Inert: no page route serves the composer until C7.7 registers the session route; released RPCs,BRIDGE_PROTOCOL_VERSIONand the frame kinds unchanged.Verbs and grants (
bridge-audio-verbs.ts, handlersnative-audio.tsandnative-wakelock.tsover the Expo modules the app already ships; four grant rows, each accepted by the route schema):native.audio.start { sampleRate } → { started, sampleRate, permission }(the shell owns the OS permission prompt; a denial is data, not a throw),native.audio.read { maxBytes } → { base64, droppedBytes, recording, interruption },native.audio.stop {} → { stopped },native.wakelock.set { active, tag } → { active }. The shell keeps a ring ofMOBILE_DICTATION_MAX_PENDING_AUDIO_BYTES(160,000 B, the page's own pending budget), drops the newcomer when full and reportsdroppedBytesonce; a read after stop is refused with the new codenative_audio_not_capturing.One flow on both hosts.
use-mobile-dictation.tstakes capture throughsrc/platform/dictation-capture.ts(native: the Expo module andexpo-keep-awake) ordictation-capture.web.ts(page: the verbs above, draining the ring on a 500 ms batch and raising each reply as the events the engine emits natively). An interruption rides the read reply and reaches the same state the nativeonAudioInterruptionreaches; keep-awake is one seam overnative.wakelock.seton the page.ExpoTwoWayAudioModule.web.tsand itsweb-overrides.jsonentry now say what the page does instead of claiming a denied microphone is the page's answer.Why a 500 ms batch. Android's audio callback fires at 31.25 events/s; one bridge request per event exhausts
BRIDGE_MAX_PENDING_REQUESTS.dictation-capture-bridge-budget.test.tsxruns a 10 s session over a 2 s link at the native rate and at 500 ms and asserts the in-flight peak against the budget: 63 in flight (1 free slot) and 312 requests at the native rate against 5 in flight (60 free) and 19 requests at 500 ms; reproduced by round 1.A defect the render case found and fixed: a
startthe shell refused left the mic control on "Starting voice dictation" with no way back, which is every tap on an ungranted route; the control now reports the refusal.Round 1 (fresh) requested changes; all eight findings folded (rows above): the tail of every utterance was discarded on stop (a capability loss ruling 26 forbids), a page session's wake tag was never released, a dead surface member, a census claim of "four modules" that measured eight, a listener leaked by concurrent starts during the permission prompt, a lone
endedinterruption cancelling on the page only, two weak test claims, and the chunk sender's type. CodeRabbit and pullfrog independently raised the wake-tag andendedfindings.Not in this PR: the simulator proof (brief commit 5) is deferred to C7.9 with C7.7, for three verified reasons: no page route serves the composer before C7.7; no desktop in the lane answers
speech.dictation.*without a downloaded STT model;xcrun simctlhas no audio-input subcommand, so a fixture cannot reach a simulator microphone. The chunk carries raw PCM: an encode-on-demand shape would have editeddictation-mount-adapters.tsand movedadapterSha256on five dictation goldens, so the corpus is untouched.Commits:
e6b13328cffeb7285c33a577bbc3b54a72cb163eefb660cccdf5ab4a3052origin/main(7b97551acf)0b6a025cb8origin/main(e9b180685b)3cd1d0f2a8native.audio.stop, so the utterance's tail is not discarded (round 1; probe: 12,288 B spoken in the last 400 ms reachedonChunkas[]before, one chunk of 12,288 B after;endis async andstop()awaits it)ad93ba2f53['+orca-a']→['+orca-a','-orca-a']on unmount)b25c052eddcanCaptureAudiosurface member; the per-verbungrantedrefusal is the fence (round 1; surface pin 13 of 13)c9adcc24aa@orca/expo-two-way-audio, threeexpo-keep-awake) with a resolution precondition, reads the shell's verb table throughimport(), and drives its grant control through the rule's own loop (round 1)28ac7afdb1startduring the permission prompt cannot overwrite a live capture (round 1; 2 listeners → 1; start-after-dispose 0)debc3bfdecendedinterruption no longer cancels on the page; one predicate (`begane7dcd17ca4DictationCaptureChunk(round 1)735a68ce02origin/main(2d697a4012, #21908)becb88536d589977db1borigin/main(5d13a70ea3, C2.9); the closure docstring keeps C2.9's two sentences and adds this PR's paragraphbb9064af10798c4c25aee6a03b76d6import()is still transformed againstmobile/tsconfig.json, absent its Expo base on the root-only shard)e48a025959end()re-entered itself through interruption →cancel()→end()without bound; the pin exhausted the worker heap before the fix; reads bounded at 2)caf3b67060held.addran after the device call, so a dispose between activate and its reply missed the tag)97b885529aendrejected against the contract;releasewas bare in the unmount path and took the wake-tag release and desktop cancel with it)4ba6f1c1c2await capture.end()beforeacceptingChunksRef.current = false; reversed, no chunk is sent at all)3d9775df16heldmeans the device still has the tag, so the owner's queued retry reaches it)120de9f7bbdisposedguard returned afterengine.open()without ending it)65d10d1b75ffe4d6d785origin/main(4e45fd04a1: C7.5b, #21936): one conflict, the closure test'sSESSION_ROUTE_MODULESrename and docstring, resolved to main's text plus this PR's paragraph; duplicate-declaration sweep over 130 touched files, 0; pin re-measured both ends, main 4,286 / 936 → head 4,281 / 939 (the eight vendored modules out by name, three local in; red-first: 4,281 against main's 4,286 before the edit)64481ae9a6activeIdRefwas set ended beforebegin()ever ran, so the latched promise shadowed the next end; pinned byends a capture opened after the last end, though 'begin' never ran between them)f14959def3native-wakelock.test.ts)86a298e1c1920ed47a6dorigin/main(e6de7a4bbe: C7.5c, PR A, the rig and catalog fixes): one conflict, the closure test's pin block, resolved to main's shape (the retired factory artifact out of the gained list, this PR's paragraph appended); the orphanedterminal-webview-document-factory.generated.tsdeleted; duplicate-declaration sweep over 175 touched files, 0; pin re-measured both ends, main 4,328 / 978 → head 4,323 / 981 (eight vendored out by name, three local in; red-first against main's 4,328)Verification
Lead gate on
920ed47a6d(merge of maine6de7a4bbe) againste6de7a4bbe(verify-gates.sh, four artifacts rebuilt after clearing ignored generated files): tsc 0, tests-typecheck ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 34 changed files 0, machine paths 0; config/scripts 242 files / 2,204 passed, 0 failed; mobile 778 files / 8,737 passed, 6 skipped, 0 failed.Lead gate on
86a298e1c1(CodeRabbit folds) against4e45fd04a1(verify-gates.sh, four artifacts rebuilt): tsc 0, tests-typecheck ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 34 changed files 0, machine paths 0; mobile 782 files / 8,751 passed, 6 skipped, 0 failed; config/scripts 240 passed + themacos-computer-helper-owner-loss-processes.test.mjstiming flake under full-suite load, 21 of 21 alone.Lead gate on
ffe4d6d785(merge of main4e45fd04a1) against4e45fd04a1(verify-gates.sh, four artifacts rebuilt): tsc 0, tests-typecheck ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 33 changed files 0, machine paths 0; mobile 781 files / 8,746 passed, 6 skipped, 0 failed; config/scripts 240 passed + 1 failed under full-suite load (macos-computer-helper-owner-loss-processes.test.mjs, the known timing flake; 21 of 21 alone).Lead gate on
65d10d1b75(round-2 and pullfrog folds, eight commits on798c4c25ae, main not re-merged) against5d13a70ea3(verify-gates.sh, four artifacts rebuilt): tsc 0, tests-typecheck ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 33 changed files 0, machine paths 0; config/scripts 241 files / 2,186 passed, 0 failed; mobile 780 files / 8,743 passed, 6 skipped, 0 failed. Round 2 (Opus, read-only at798c4c25ae) reproduced the tail ordering, the wakelock dispose on unmount and on a session change, the serialised starts, the interruption predicate, the census memoisation and the pin (base 4,326 / 976 → head 4,321 / 979), and asked for changes on four points, all folded above: the re-entrantend()(reproduced to a heap crash at 68 s), the unpinned stop ordering, a rejected release forgotten by dispose, and a start that loses the dispose race leaving the session initialised. The CI shard failure on798c4c25aewas the census verb-table case: a mobile module reached throughimport()is still transformed againstmobile/tsconfig.json, so the case is now gated on the mobile install (reproduced before and after with the install moved aside: 1 failed → 6 skipped → 9 passed).Lead gate on
798c4c25ae(round-1 folds, merges of main through5d13a70ea3, re-pins) against5d13a70ea3(verify-gates.sh, four artifacts rebuilt): tsc 0, tests-typecheck ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 32 changed files 0, machine paths 0; config/scripts 241 files / 2,184 passed, 0 failed; mobile 779 files / 8,732 passed, 6 skipped, 0 failed. Round 1 reproduced the budget table: at the native 32 ms drain 63 in flight with 1 free slot and 312 chunk requests over a 10 s session on a 2 s link (624 frames out / 561 back); at the shipped 500 ms, 5 in flight, 60 free, 19 requests (38 / 34); setting the drain to 32 ms reds "spends four slots of sixty-four".Lead gate on
f5ab4a3052against7b97551acf(verify-gates.sh, artifacts rebuilt): tsc 0, tests-typecheck ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 27 changed files 0, root oxfmt over 1 file 0, machine paths 0; config/scripts 237 files / 2,136 passed, 0 failed; mobile 775 files / 8,650 passed, 0 failed. Lead reproduction:dictation-capture-bridge-budget.test.tsx3 of 3; no file undermobile/rpc-foundation/ordictation-mount-adapters.tsin the diff. The lane's in-flight measurements (peak 63 in flight with 1 free slot at the native rate; 5 in flight with 60 free at 500 ms; 312 vs 19 chunk requests over a 10 s session on a 2 s link) enter this body after round 1 reproduces them.Not in this PR: the rich editor (C1/C2), the
img-srcwidening (ruling 27), C7.7 route entry, C7.9 device proof (dictation's simulator legs land there).