Skip to content

feat(mobile): dictation on the OTA page over native audio verbs (Phase C, C7.10 PR D) - #21905

Merged
Jinwoo-H merged 34 commits into
mainfrom
ota-c7-10d-dictation
Sep 21, 2026
Merged

Jinwoo-H merged 34 commits into
mainfrom
ota-c7-10d-dictation

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2616 $\color{#cf222e}{\Huge{\mathbf{−}}}$​68 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2548
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1281 $\color{#cf222e}{\Huge{\mathbf{−}}}$​87 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1194

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-audio and streams chunks to the desktop as speech.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_VERSION and the frame kinds unchanged.

Verbs and grants (bridge-audio-verbs.ts, handlers native-audio.ts and native-wakelock.ts over 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 of MOBILE_DICTATION_MAX_PENDING_AUDIO_BYTES (160,000 B, the page's own pending budget), drops the newcomer when full and reports droppedBytes once; a read after stop is refused with the new code native_audio_not_capturing.

One flow on both hosts. use-mobile-dictation.ts takes capture through src/platform/dictation-capture.ts (native: the Expo module and expo-keep-awake) or dictation-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 native onAudioInterruption reaches; keep-awake is one seam over native.wakelock.set on the page. ExpoTwoWayAudioModule.web.ts and its web-overrides.json entry 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.tsx runs 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 start the 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 ended interruption cancelling on the page only, two weak test claims, and the chunk sender's type. CodeRabbit and pullfrog independently raised the wake-tag and ended findings.

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 simctl has no audio-input subcommand, so a fixture cannot reach a simulator microphone. The chunk carries raw PCM: an encode-on-demand shape would have edited dictation-mount-adapters.ts and moved adapterSha256 on five dictation goldens, so the corpus is untouched.

Commits:

commit what
e6b13328cf feat(mobile): serve dictation capture over four native audio verbs
feb7285c33 refactor(mobile): take dictation capture through one seam on both hosts
a577bbc3b5 perf(mobile): drain the shell's audio ring on a 500 ms batch
4a72cb163e test(mobile): derive dictation's grant rows from the route closure
efb660cccd test(mobile): keep the mic control's render case inside the tests typecheck
f5ab4a3052 merge of origin/main (7b97551acf)
0b6a025cb8 GitHub merge of origin/main (e9b180685b)
3cd1d0f2a8 fix(mobile): drain the shell's ring once before native.audio.stop, so the utterance's tail is not discarded (round 1; probe: 12,288 B spoken in the last 400 ms reached onChunk as [] before, one chunk of 12,288 B after; end is async and stop() awaits it)
ad93ba2f53 fix(mobile): dispose the wakelock server with the page session like the microphone, so a held tag is released (round 1; ['+orca-a'] → ['+orca-a','-orca-a'] on unmount)
b25c052edd refactor(mobile): delete the unread canCaptureAudio surface member; the per-verb ungranted refusal is the fence (round 1; surface pin 13 of 13)
c9adcc24aa test(mobile): the dictation census records the eight vendored modules the seam removes (five @orca/expo-two-way-audio, three expo-keep-awake) with a resolution precondition, reads the shell's verb table through import(), and drives its grant control through the rule's own loop (round 1)
28ac7afdb1 fix(mobile): serialise starts and stops in the native audio handler so a second start during the permission prompt cannot overwrite a live capture (round 1; 2 listeners → 1; start-after-dispose 0)
debc3bfdec fix(mobile): a lone ended interruption no longer cancels on the page; one predicate (`began
e7dcd17ca4 refactor(mobile): type the chunk sender's parameter as DictationCaptureChunk (round 1)
735a68ce02 merge of origin/main (2d697a4012, #21908)
becb88536d test(mobile): re-record the session route's page closure at 4,319 (base 4,324 − 8 vendored + 3 local; measured both ends)
589977db1b merge of origin/main (5d13a70ea3, C2.9); the closure docstring keeps C2.9's two sentences and adds this PR's paragraph
bb9064af10 test(mobile): re-record the closure at 4,321 (base 4,326 / 976 with 5 + 3 vendored; head 4,321 / 979 with 0 + 0)
798c4c25ae perf(config): memoise the dictation census's route closure builds (15 → 6 esbuild builds; with the census excluded the config/scripts shard was green under load, the control for its cost)
e6a03b76d6 fix(config): gate the dictation census's verb-table case on the mobile install (round 2 / CI: a mobile module reached through import() is still transformed against mobile/tsconfig.json, absent its Expo base on the root-only shard)
e48a025959 fix(mobile): make the page's capture end idempotent (round 2 / pullfrog: end() re-entered itself through interruption → cancel() → end() without bound; the pin exhausted the worker heap before the fix; reads bounded at 2)
caf3b67060 fix(mobile): give back a wake tag whose activation landed after dispose (pullfrog: held.add ran after the device call, so a dispose between activate and its reply missed the tag)
97b885529a fix(mobile): swallow the native audio session's shutdown failures (pullfrog: async end rejected against the contract; release was bare in the unmount path and took the wake-tag release and desktop cancel with it)
4ba6f1c1c2 test(mobile): pin the order stop() hands the tail over in (round 2: await capture.end() before acceptingChunksRef.current = false; reversed, no chunk is sent at all)
3d9775df16 fix(mobile): keep a wake tag recorded until the device really drops it (round 2: held means the device still has the tag, so the owner's queued retry reaches it)
120de9f7bb fix(mobile): tear the audio device down for a start that lost the race (round 2: the disposed guard returned after engine.open() without ending it)
65d10d1b75 test(mobile): drive the stop-tail pin through the typed fake client (drops three type assertions the quality gate refused)
ffe4d6d785 merge of origin/main (4e45fd04a1: C7.5b, #21936): one conflict, the closure test's SESSION_ROUTE_MODULES rename 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)
64481ae9a6 fix(mobile): clear the page capture's end when it settles (CodeRabbit: a start that went stale after activeIdRef was set ended before begin() ever ran, so the latched promise shadowed the next end; pinned by ends a capture opened after the last end, though 'begin' never ran between them)
f14959def3 fix(mobile): serialise the shell's wake tags and record them before compensating (CodeRabbit: a swallowed compensating release let the owner record a stuck tag as active; a release racing its own activate issued no deactivate; tags recorded on activate, deleted on device drop, refusal rejects, operations chained per tag; new native-wakelock.test.ts)
86a298e1c1 fix(mobile): let dispose re-read the tag set once its turn comes (a dispose queued behind a release deactivated a tag already given back; guard proven load-bearing: three device calls instead of two without it)
920ed47a6d merge of origin/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 orphaned terminal-webview-document-factory.generated.ts deleted; 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 main e6de7a4bbe) against e6de7a4bbe (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) against 4e45fd04a1 (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 + the macos-computer-helper-owner-loss-processes.test.mjs timing flake under full-suite load, 21 of 21 alone.

Lead gate on ffe4d6d785 (merge of main 4e45fd04a1) against 4e45fd04a1 (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 on 798c4c25ae, main not re-merged) against 5d13a70ea3 (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 at 798c4c25ae) 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-entrant end() (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 on 798c4c25ae was the census verb-table case: a mobile module reached through import() is still transformed against mobile/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 through 5d13a70ea3, re-pins) against 5d13a70ea3 (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 f5ab4a3052 against 7b97551acf (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.tsx 3 of 3; no file under mobile/rpc-foundation/ or dictation-mount-adapters.ts in 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-src widening (ruling 27), C7.7 route entry, C7.9 device proof (dictation's simulator legs land there).

Jinwoo-H and others added 7 commits September 20, 2026 23:37
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
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 905aae29-b9a9-42f4-a7d1-1c77a2cc87cb

📥 Commits

Reviewing files that changed from the base of the PR and between ffe4d6d and 86a298e.

📒 Files selected for processing (4)
  • mobile/src/platform/dictation-capture.web.test.tsx
  • mobile/src/platform/dictation-capture.web.ts
  • mobile/src/platform/native-wakelock.test.ts
  • mobile/src/platform/native-wakelock.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • mobile/src/platform/dictation-capture.web.test.tsx
  • mobile/src/platform/native-wakelock.ts
  • mobile/src/platform/dictation-capture.web.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 72 functions across 35 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 refere… 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, A…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: mobile-page dictation over native audio verbs. It is concise and related to the changeset.
Full details: Description check

Explanation

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 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: af3ab19e-5b5e-4b26-936d-2af0e68bcc72

📥 Commits

Reviewing files that changed from the base of the PR and between e9b1806 and 0b6a025.

📒 Files selected for processing (29)
  • config/scripts/mobile-web-app-session-dictation-capture.test.mjs
  • mobile/packages/expo-two-way-audio/src/ExpoTwoWayAudioModule.web.ts
  • mobile/src/hooks/mobile-dictation-foreground-keep-awake.ts
  • mobile/src/hooks/mobile-dictation-keep-awake.test.ts
  • mobile/src/hooks/mobile-dictation-keep-awake.ts
  • mobile/src/hooks/use-mobile-dictation-source.test.ts
  • mobile/src/hooks/use-mobile-dictation.ts
  • mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsx
  • mobile/src/mobile-web-shell/bridge-host-errors.ts
  • mobile/src/mobile-web-shell/bridge-host-init.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-audio-verbs.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-audio-verbs.ts
  • mobile/src/mobile-web-shell/bridge/bridge-native-verbs.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-native-verbs.ts
  • mobile/src/mobile-web-shell/bridge/bridge-port-pair-test-harness.ts
  • mobile/src/mobile-web-shell/bridge/use-native-verbs.ts
  • mobile/src/mobile-web-shell/page-route-policy.test.ts
  • mobile/src/platform/dictation-capture-bridge-budget.test.tsx
  • mobile/src/platform/dictation-capture-contract.ts
  • mobile/src/platform/dictation-capture.ts
  • mobile/src/platform/dictation-capture.web.test.tsx
  • mobile/src/platform/dictation-capture.web.ts
  • mobile/src/platform/native-audio-device.ts
  • mobile/src/platform/native-audio.ts
  • mobile/src/platform/native-wakelock.ts
  • mobile/src/platform/use-native-device-verbs.test.tsx
  • mobile/src/platform/use-native-device-verbs.ts
  • mobile/src/session/mobile-dictation-mic-control.web.test.tsx
  • mobile/web-entry/web-overrides.json

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Comment on lines +30 to +31
const serveWakelock = useMemo(() => createNativeWakelockServer(nativeWakelockDevice), [sessionId])
useEffect(() => () => audio.dispose(), [audio])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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 a dispose that deactivates every tag still in held.
🔒 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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|stop and native.wakelock.set added to the verb table with strict Zod schemas, the new native_audio_not_capturing refusal code, and grant names held to GRANT_NAME_PATTERN (bridge-audio-verbs.ts, bridge-native-verbs.ts).
  • Shell capture over a budget-sized ring — native-audio.ts rings PCM (drop-newcomer), reports droppedBytes/recording/interruption on 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.ts make 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.ts plus dictation-capture.ts (native) and dictation-capture.web.ts (page); use-mobile-dictation.ts and the keep-awake owner now take an injected DictationKeepAwakeDevice instead of importing Expo directly.
  • 500 ms page drain — the page pulls the ring on a timer; dictation-capture-bridge-budget.test.tsx measures in-flight slot cost against BRIDGE_MAX_PENDING_REQUESTS at 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 end with a tail drain — dictation-capture.web.ts awaits the in-flight read and issues one last native.audio.read before native.audio.stop; the contract's end is now Promise<void> and stop() 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 lone ended no longer cancels on the page; dictation-capture.test.ts pins the native side.
  • Wakelock dispose — createNativeWakelockServer returns { serve, dispose }, and use-native-device-verbs.ts releases held tags on session teardown.
  • Serialised audio starts/stops — native-audio.ts queues start/stop and refuses a start that lands after dispose, so overlapping permission prompts cannot leak listeners.
  • Surface and census cleanup — dropped the unread canCaptureAudio and pinned the surface; reworked the dictation census (memoised closures, control drives the rule itself, install-resolution precondition) and re-pinned the terminal closure.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread mobile/src/platform/native-wakelock.ts Resolved
…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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 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 win

Clean 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 call end(). The hook cleanup runs only when the session unmounts or changes. Wrap engine.begin() in try/catch, call end(), 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

📥 Commits

Reviewing files that changed from the base of the PR and between 798c4c2 and 65d10d1.

📒 Files selected for processing (10)
  • config/scripts/mobile-web-app-session-dictation-capture.test.mjs
  • mobile/src/hooks/mobile-dictation-stop-tail.test.tsx
  • mobile/src/hooks/use-mobile-dictation-source.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-audio-verbs.test.ts
  • mobile/src/platform/dictation-capture.test.ts
  • mobile/src/platform/dictation-capture.ts
  • mobile/src/platform/dictation-capture.web.test.tsx
  • mobile/src/platform/dictation-capture.web.ts
  • mobile/src/platform/native-audio.ts
  • mobile/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.

Comment thread mobile/src/platform/native-wakelock.ts Resolved
Comment thread mobile/src/platform/native-wakelock.ts Resolved
# Conflicts:
#	config/scripts/mobile-web-app-session-terminal-closure.test.mjs

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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/release no longer reject — dictation-capture.ts wraps toggleRecording(false) and tearDown() in try/catch and logs, so end honours its never-rejects contract and release cannot abort the rest of unmount cleanup.
  • Page end is idempotent — dictation-capture.web.ts holds an ending promise set before any await; begin() clears it, release() marks it ended. The interruption lane's re-entrant end() now returns that promise instead of issuing another bridge read, closing the unbounded loop.
  • Wakelock dispose/retry correctness — native-wakelock.ts now treats held as "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 after dispose is given back and answered { active: false }.
  • Start that loses the dispose race is torn down — native-audio.ts calls engine.end() when open() 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.tsx pins the stop() ordering (tail accepted and sent before finish); dictation-capture.test.ts drives a throwing engine; the census's verb-table case is now it.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.

Pullfrog  | View workflow run | Using 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 end no longer latches a settled promise — dictation-capture.web.ts clears ending when it settles and adds a released flag (set by release(), cleared by begin()), so an open()-without-begin() cleanup still issues its last read and stop.
  • Shell wake tags serialised per tag — native-wakelock.ts runs serve/dispose for a tag through a per-tag promise queue, records held the moment activate resolves (compensating when disposed), and has dispose re-check held once its turn comes.
  • Regression coverage — the new native-wakelock.test.ts (gated device) and the added dictation-capture.web.test.tsx case 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 main e6de7a4bbe (C7.5c) — the render rig and HTML-preview iframe; one conflict in the session closure pin, re-recorded to 4,323.
  • Merged main 963da57 — adds the source-control hub and diff-review page routes, taking MOBILE_WEB_PAGE_ROUTES from five entries to seven; clean merge, both sides' web-overrides.json entries 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.mjs now pins all seven registered route modules, adding app/h/[hostId]/source-control/[worktreeId].tsx and app/h/[hostId]/review/[worktreeId].tsx. The previously red case passes locally.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit a91ca8b into main Sep 21, 2026
31 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-c7-10d-dictation branch September 21, 2026 10:42
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