Repository navigation
feat(mobile): carry browser screencast frames over the bridge as base64 (OTA phase C, C6.1) - #21758
Conversation
…phase C, C6.1) `bridge-screencast-binary.ts` landed in C0 as the page's half of the binary lane and named C6 as the owner of the encoder that satisfies it. This is that encoder, plus the host honouring `wantsBinary`: a subscribe that asked for binary gets an `onBinaryFrame` on the native stream, and each frame crosses as the envelope's `event.binary` on the same `seq` ledger as the stream's JSON events, because the page acks by that count. The base64 encoder is grouped rather than per byte or per `fromCharCode` window. Its docstring carries the measurement, including the part that contradicts the design note this came from: on V8 the per-byte form is the fastest of the three, not the quadratic one, and the chunked form it was meant to beat is the slowest. The grouped one is here because its cost does not depend on how an engine ropes `+=`, and Hermes is what the shell runs. No new opcode, no `v` bump, no negotiation added: `wantsBinary` is already in the contract and is the negotiation. Over-cap behaviour is unchanged in this commit — a binary event over the frame cap still ends the stream, which is what C6.2 changes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… stream (OTA phase C, C6.1) Measured at the pane's own request parameters, a screencast frame exceeds the 640 KiB envelope on a phone layout whenever the page will not compress: JPEG's worst case is 0.545 bytes per pixel at quality 72, so mobile view mode at 780x1424 is 811,289 bytes, 124% of the cap. Ending the stream there blacks out a browser tab for the life of the pane over one frame. So the two kinds of event part at the cap. A JSON event that will not fit still ends the stream with `overflow`, because its reader cannot see the hole it would leave; a screencast frame is dropped and the stream lives, because the next frame is one throttle interval away and the pane is still showing the last one. Both are asserted side by side so neither turns into the other. A drop leaves no other trace: the diagnostic beside it prints once per host, so a stream shedding a frame a second and one that shed a single frame read the same. The host therefore counts them per stream for the diagnostic and keeps a session total, and the shell's dev facts carry that total — the surface that already shows build state, with the line moved into its own module so what it says is pinned rather than inferred from a template. The 12-character build prefix it has always shown is unchanged. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…, C6.1) Ruling 5's negotiation, and the check it asked for first: no reader of a grant is a closed enum, so there is no blocker and nothing an older page has to tolerate. `BridgeGrantsSchema.native` and the shell's manifest reader are both open string arrays, and the shell reader's own docstring already states the degradation — a grant name a build does not know leaves that one route native rather than refusing the bundle. What does constrain the name is the host contract's `GRANT_NAME_PATTERN`: a grant is one camelCase token or a `native.<domain>.<action>` verb with at least two dot segments. So `browser.screencast` and `native.screencast` are both refused, and the lane is `screencastBinary`. `screencast` alone would be wrong: the page can already subscribe to `browser.screencast` and receive its JSON events, and only the binary frames need the encoder. Added to the shell's implemented set, which is the same list `init.grants.native ` offers, so a route declaring it is served by a shell that has the encoder and left native by one that does not. No route declares it here; C7's session route does. The contract-side case is a characterisation pin, not a red-first one: the pattern already admitted this name, and the test records that the two tempting spellings are the ones it refuses. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…OTA phase C, C6.1) The hook gained a required `onBinaryFramesDropped` two commits ago and this test kept calling it without one, so the tests-typecheck ratchet went red on that commit — caught here rather than in CI because an exit code was read off a pipeline's last stage instead of the script. Fixed by wiring the callback into the probe rather than by a cast, and with the case that makes the wiring evidence instead of types: a dropped frame raises the total the screen receives, and the stream stays subscribed while it does. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…elongs to (OTA phase C, C6.1) Declared between a getter and a method, which is not where this class keeps state: the subscription map is at the top and the counter is the same kind of thing. Move only. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… it (OTA phase C, C6.1) Reported as a gap after C6.1's third commit and ruled on: the host honoured `wantsBinary` from any page, so a route that never declared `screencastBinary` could still make the shell encode base64 on its behalf. That is the hole per-route grants exist to close — the same class as a route granted only `navigate` and `storage` reaching the clipboard. The rule now reads the session's resolved list, which is what its route declared narrowed to what this shell implements, and is the same set `init.grants.native` is built from. So the host offers the lane in `init` exactly when it will serve it. Ungranted is not a refusal. The subscription proceeds and its JSON events cross as before, which is the silence every other grant gives at the call site; a page that reads its own grants never reaches that state. Both branches are pinned beside each other, and `grantsForRoute` is pinned dropping a grant this shell does not implement — granted-but-unimplemented and never-granted arrive at the host as the same absence, so its rule reads one case. The grant name moves into the module that holds the rule reading it, so the two cannot drift. `bridge-host.ts` is at 298 of its 300-line cap after this. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…(OTA phase C, C6.1) `bridge-host.ts` reached 298 of its 300-line cap, so the next main merge that touched it would have crossed under CI pressure on someone else's PR. Split deliberately instead, at the boundary the growth came from. `bridge-host.ts` is the host's lifecycle and its dispatch. Opening a stream is the only frame kind whose handling is more than one line of delegation — four refusals and, since C6.1, the binary-lane decision — so it moves whole, and `cancel` and `ack` move with it so all three stream frames are decided in one place. The host's `cancel` arm still chooses between a stream and a request where it always did: a page's `cancel` names one or the other, and splitting that choice would leave half an arm in each module. Counted without blank lines or comments, as the rule counts them: bridge-host.ts 298 -> 270, and the new module is 59. A pure move. No test changed and none was added, which is what makes the existing suites the proof: 45 files and 745 tests green on the same assertions as before. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ot granted (OTA phase C, C6.1) An ungranted `wantsBinary` is not a refusal on the wire, so nothing crosses back: the subscription proceeds and its JSON events cross as they always have. That left a page which did ask getting JSON for the life of the document with no side able to say why. `notify-refused` has covered the equivalent notify case since C0; this is the same shape for the one frame kind that lacked it. The rule now answers a verdict rather than a boolean, because `not-asked` and `ungranted` are the same answer for different reasons and only one is worth reporting. So the decision and the report read one rule, and a page that never asked stays silent — pinned, along with a granted route staying silent, so the line cannot start firing on either. The wire is unchanged and pinned unchanged: the case beside this one still asserts one JSON event delivered and zero error frames. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
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)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe mobile web shell now supports a granted binary screencast lane. It encodes and delivers binary frames, preserves shared event sequencing, and drops oversized or unacknowledged binary frames without ending the stream. The bridge emits refusal and drop diagnostics, forwards cumulative drop counts to the screen, and displays them in development facts. Tests cover encoding, grants, routing, backpressure, diagnostics, and rendering. Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides extensive technical context and testing details, but it does not follow the required template. It omits the required ELI5, What Changed, Why, Linked Issue with a Fixes reference, Visual Proof or explicit N/A, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections. Resolution Rewrite the description using the repository template. Add every required section, include a valid linked issue in the Linked Issue section, provide visual proof or write exactly N/A with a reason, complete the testing and checklist items, and address AI Disclosure and Agent skill upstream boundary.
✨ 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 97658b10-cfd0-4d26-a0a9-922e5c8e8ad4
📒 Files selected for processing (20)
mobile/src/mobile-web-shell/MobileWebShellScreen.tsxmobile/src/mobile-web-shell/bridge-diagnostic-log.tsmobile/src/mobile-web-shell/bridge-host-contract.tsmobile/src/mobile-web-shell/bridge-host-init.test.tsmobile/src/mobile-web-shell/bridge-host-screencast.test.tsmobile/src/mobile-web-shell/bridge-host-stream-frames.tsmobile/src/mobile-web-shell/bridge-host-subscriptions.tsmobile/src/mobile-web-shell/bridge-host-test-fakes.tsmobile/src/mobile-web-shell/bridge-host-test-harness.tsmobile/src/mobile-web-shell/bridge-host.tsmobile/src/mobile-web-shell/bridge/bridge-screencast-encoder.test.tsmobile/src/mobile-web-shell/bridge/bridge-screencast-encoder.tsmobile/src/mobile-web-shell/bridge/bridge-screencast-grant.tsmobile/src/mobile-web-shell/mobile-web-shell-dev-facts.test.tsmobile/src/mobile-web-shell/mobile-web-shell-dev-facts.tsmobile/src/mobile-web-shell/page-route-policy.test.tsmobile/src/mobile-web-shell/page-route-policy.tsmobile/src/mobile-web-shell/use-mobile-web-shell-bridge.test.tsmobile/src/mobile-web-shell/use-mobile-web-shell-bridge.tssrc/shared/mobile-web-bundle/manifest-contract.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| // A dropped screencast frame leaves no other trace on a device: the stream stays up by design | ||
| // and the diagnostic beside it prints once per host. | ||
| onBinaryFramesDropped: setDroppedBinaryFrames |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n "screencastBinary|onBinaryFramesDropped|isDevelopmentBuild|routeGrants|granted" mobile/src/mobile-web-shell src/shared/mobile-web-bundle | head -240
sed -n '135,230p' mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
sed -n '145,200p' mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.ts
sed -n '1,100p' mobile/src/mobile-web-shell/bridge-host-stream-frames.tsRepository: stablyai/orca
Length of output: 33734
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- candidate route and manifest files ---'
rg -l -n "MobileWebShellScreen|screencastBinary|grantsForRoute|DevFacts|createBridgeHost|droppedBinaryFrames" mobile src/shared --glob '!**/*.test.*' | head -120
printf '%s\n' '--- route/session grant resolution ---'
sed -n '1,240p' mobile/src/mobile-web-shell/mobile-web-shell-session.ts
sed -n '1,220p' mobile/src/mobile-web-shell/page-route-policy.ts
printf '%s\n' '--- screen remainder and DevFacts ---'
sed -n '1,330p' mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
printf '%s\n' '--- host drop path and subscriptions ---'
sed -n '1,230p' mobile/src/mobile-web-shell/bridge-host.ts
sed -n '1,280p' mobile/src/mobile-web-shell/bridge-host-subscriptions.ts
printf '%s\n' '--- non-test route declarations mentioning shell/manifest ---'
rg -n "routes\s*:|pathname\s*:|screencastBinary|mobile-web-shell|web-shell" mobile src/shared --glob '!**/*.test.*' --glob '*.{ts,tsx,js,jsx,json}' | head -260Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
set -e
printf '%s\n' '--- route/session grant resolution ---'
sed -n '1,230p' mobile/src/mobile-web-shell/mobile-web-shell-session.ts
sed -n '1,180p' mobile/src/mobile-web-shell/page-route-policy.ts
printf '%s\n' '--- screen and host callback ---'
sed -n '1,290p' mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
sed -n '1,220p' mobile/src/mobile-web-shell/bridge-host.ts
sed -n '1,300p' mobile/src/mobile-web-shell/bridge-host-subscriptions.ts
printf '%s\n' '--- production declarations ---'
rg -n "routes[[:space:]]*:|pathname[[:space:]]*:|screencastBinary|MobileWebShellScreen|DevFacts" mobile src/shared --glob '!**/*.test.*' --glob '*.{ts,tsx,js,jsx,json}' | head -300Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
set -e
printf '%s\n' '--- exact binary grant bindings outside tests ---'
rg -n "screencastBinary|BRIDGE_SCREENCAST_BINARY_GRANT|MOBILE_WEB_SHELL_GRANTS" . --glob '!**/*.test.*' --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**'
printf '%s\n' '--- manifest route/grant producers and readers outside tests ---'
rg -n "MobileWebBundleManifest(Read|Facts)|read-manifest|manifest\.routes|routes:.*grants|grants:.*pathname|MobileWebBundleRoute" mobile src modules --glob '!**/*.test.*' --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | head -260
printf '%s\n' '--- manifest contract and transport binding ---'
sed -n '80,135p' src/shared/mobile-web-bundle/manifest-contract.ts
sed -n '1,180p' mobile/src/transport/mobile-web-bundle-reply-schemas.ts
rg -n -A18 -B12 "kind: 'read-manifest'|readManifest|read-manifest" mobile/src --glob '!**/*.test.*'Repository: stablyai/orca
Length of output: 28824
Do not update React state for invisible production facts.
When a manifest route grants screencastBinary and an unacknowledged binary subscription drops frames, BridgeHostSubscriptions calls onBinaryFramesDropped for each dropped frame. The callback reaches setDroppedBinaryFrames, so changing totals can trigger repeated production renders even though DevFacts returns null.
Gate the state update with isDevelopmentBuild, or keep the production total outside React state.
Proposed fix
- onBinaryFramesDropped: setDroppedBinaryFrames
+ onBinaryFramesDropped: isDevelopmentBuild ? setDroppedBinaryFrames : () => undefined📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // A dropped screencast frame leaves no other trace on a device: the stream stays up by design | |
| // and the diagnostic beside it prints once per host. | |
| onBinaryFramesDropped: setDroppedBinaryFrames | |
| // A dropped screencast frame leaves no other trace on a device: the stream stays up by design | |
| // and the diagnostic beside it prints once per host. | |
| onBinaryFramesDropped: isDevelopmentBuild ? setDroppedBinaryFrames : () => undefined |
…it (OTA phase C, C6.1) Round 1 on #21758, three findings. The real one: the count is per host and the screen's copy was not. A rebuilt host starts its own total at zero, so the screen kept the retired host's number until the new one dropped a frame and then read *lower* — a falling count looks like frames coming back, which is worse than starting over. The hook now announces a fresh count as it builds a host. That also reports zero on the first build, where the screen is already at zero and React bails out of the render; the two hook cases pin that leading zero rather than leave it to be rediscovered. Two docstrings that described nothing: `BUILD_ID_PREFIX_LENGTH`'s stayed behind when the constant moved to the dev-facts module and had drifted above `failureMessage`, and `page-route-policy.test.ts` kept the docstring of the test it replaced above the one that replaced it. Both deleted; the first's text lives on the new module. Red-first for the reset, checked against its final expectations rather than its first: with the one line reverted both hook cases fail on the missing zero, and both pass with it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
ℹ️ No critical issues — one stale doc reference plus a couple of small notes.
Reviewed changes
- Shell encodes screencast frames to base64 —
BridgeHostSubscriptionsnow honourswantsBinary, handing the client anonBinaryFramelistener and wrapping each frame intoevent.binaryvia a new three-bytes-at-a-time encoder. - Over-cap binary frames are dropped, not fatal — a frame over the message cap or the unacked window bumps a dropped count and leaves the stream open; JSON events still end with
overflow. screencastBinarygrant gates the lane —bridgeBinaryLaneVerdictserves binary only to a session whose resolved route grants include it, reportsbinary-lane-refusedlocally otherwise, and the name joins the shell's implemented set.- Dropped-frame total reaches the dev-facts line — a per-host total flows through
onBinaryFramesDroppedtoformatMobileWebShellDevFacts, absent at zero. - Stream-frame handling moved —
open/cancel/ackextracted frombridge-host.tsintobridge-host-stream-frames.tsas a pure move.
I traced the cross-module pieces that carry risk: the page's ack thresholds (64 frames / 1 MiB) sit well inside the shell's window (256 / 4 MiB), so the new drop rule is a stalled-page backstop rather than a normal-path behavior; byte accounting matches on both sides (utf8ByteLength(json)); a dropped frame spends no seq, and the grant gate is fed by grantsForRoute (declared ∩ implemented), so granted-but-unimplemented and never-granted are the same absence at the host. The encoder is pinned against Node's Buffer, which is a genuine oracle.
ℹ️ Stale reference to the removed handleSubscribe
bridge-host-requests.ts:65 still says the native. subscribe fence lives in handleSubscribe, but that function was deleted by this PR; the fence now lives in createBridgeHostStreamFrames's open.
Technical details
# Stale comment after the stream-frame extraction
## Affected sites
- `mobile/src/mobile-web-shell/bridge-host-requests.ts:64-66` — the docstring on `forward` names `handleSubscribe`, which no longer exists.
## Required outcome
- Point the comment at the module/function that now owns the subscribe fence (`bridge-host-stream-frames.ts`, `createBridgeHostStreamFrames.open`), or describe it without naming the removed symbol.ℹ️ Nitpicks
bridge-host-subscriptions.ts—deliverBinaryFramebase64-encodes andJSON.stringifys the whole frame beforesendEventdecides it does not fit, so an over-cap or window-full frame pays the full encode cost to be discarded. Since the cap is enforced on the encoded event, the unacked frame-count branch could short-circuit before the encode; entirely optional given the measured cost and the C6.6 device pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… render path (OTA phase C, C6.1) CodeRabbit's Major on #21758. The total went into React state on every dropped frame in every build, and outside a development build the line that reads it renders null — so an over-cap page re-rendered the whole shell screen up to ten times a second for a fact nobody can see. Measured, not argued: five drops, five extra renders. Fixed at the seam rather than with a ternary at the call site. The dev-facts module owns the line, so it now owns the number behind it and the rule that the number is only state where something renders it. The screen holds no flag and no counter; it asks for both and passes the reporter on. The reporter is stable, so the bridge host is never rebuilt for it. `isDevelopmentBuild` becomes a call rather than a module constant. A build flag never changes at runtime so this costs nothing, and as a constant the branch was unreachable to anything that did not set the global before the module loaded — which is why the production case could not be written at the screen at all. Also fixed, found while writing that case: the screen test's `usePageHostSnapshot` double returned a fresh object on every render, so the host effect's identity changed each time and the bridge host was torn down and rebuilt on every render of the screen, settling every pending request with it. The real hook holds the snapshot in `useState` and is stable. One object for the file now. This was masking the fold under test — the count reset to zero on every render — and every other case in that file was measuring a rebuild storm. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Dropped-frame total now resets with the host that owns it —
useMobileWebShellBridgecallsbinaryFramesDroppedRef.current(0)in the same layout effect that builds the host, so a rebuilt host starts its count over instead of the screen showing the retired host's number and then going down on the next drop. - The reset is pinned at both ends — the existing hook case now expects
[0, 1, 2]to record the leading zero, and a new case rebuilds the host and expects[0, 1, 0]. - Two dead docstrings deleted — the orphaned
BUILD_ID_PREFIX_LENGTHblock that had drifted abovefailureMessage(the constant and its text live inmobile-web-shell-dev-facts.tsnow), and the duplicated JSDoc inpage-route-policy.test.tsraised in the previous review.
I traced the reset through the hook: the ref-refresh useLayoutEffect is declared above the host-building one, so binaryFramesDroppedRef.current reads the current render's handler when the reset fires, and setDroppedBinaryFrames is stable so the reset cannot re-enter the effect. The new reset case fails without the one line, so it is real coverage. The change is correct and mergeable as-is.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…C, C6.1) Round 2 on #21758, two lows. The encode is a base64 pass over the whole image and the window decides whether the frame can be posted at all, so deciding after encoding made a page that had stopped acking pay for every frame the shell then threw away — the reviewer's case is ten 300 KB frames against a closed window, 3 MB encoded and nothing sent. The size is knowable without encoding: base64 is ASCII, so JSON escapes none of it and the frame is its header serialized plus exactly the image's encoded length. `encodeBridgeScreencastFrame` is now built from that header rather than beside it, so the shape measured and the shape sent cannot drift, and the window arithmetic is one rule read before the encode and again on the frame that was. Exact, not conservative, so the drop diagnostic still reports the whole frame and the committed byte pin is untouched. Red-first with the real encoder wrapped in a counter: window full, ten frames, ten encodes before and zero after, with the drop count still ten. An over-cap frame likewise goes from one encode to none. A third case holds the other direction — two carryable frames still encode twice — so the fix cannot pass by encoding nothing. Second low: the dev-facts block sat outside the only `beforeEach` and left `routeGrants` and `client` mutated, inert only because it runs last. The shared setup moves to file level where the mutable dependencies actually live, resets both, and a case at the end of the file pins it — deleting the reset fails there and nowhere else, since nothing else runs after a case that mutates them. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review is commit 65c36e70f8 (CodeRabbit's Major), which keeps the dropped-frame total out of a production build's render path.
- Dropped-frame total stopped re-rendering production builds —
useMobileWebShellDroppedFramesinmobile-web-shell-dev-facts.tsnow owns the counter state and its reporter no-ops outside a development build, so an over-cap page no longer re-renders the whole shell screen once per dropped frame. isDevelopmentBuildbecame a call, not a constant — reading the flag where it is used makes the production branch reachable from a test that toggles the global, which is what let the fix be pinned.- Screen test's snapshot double made stable — the
usePageHostSnapshotmock returned a fresh object per render, changing the identity the host effect is keyed on; it had been rebuilding the bridge host on every render of that file. One hoisted object now. - New coverage — a counted
viewRenderscase pins the production no-extra-render property, and a running-total/reset case pins the dev-facts line.
I traced the gate through the callback path (BridgeHostSubscriptions.onBinaryFrameDropped → host → onBinaryFramesDropped → the hook): the drop still fires and the stream stays up in both builds; only the state write is folded away in production. The reporter is a useCallback([]), so the bridge host is not rebuilt for it, and the host-scoped reset from d9311e0 is unchanged. The production test can fail with the gate removed (five drops would produce five renders), so it is real coverage rather than theatre. Mergeable as-is.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review is commit 290c35f872 ("price a screencast frame before encoding it").
- A screencast frame is priced before it is encoded —
deliverBinaryFramecomputes the frame's exact byte size from the serialized header plus the image's base64 length and reads the window rule before the base64 pass, so a stalled page no longer pays a full encode for every frame the shell then drops. - One carry rule — the cap/window test moves into
canCarry, read once before the encode and again insendEventon the encoded frame, so the shape measured and the shape sent cannot drift. - The encoder exposes the price —
bridgeScreencastFrameHeader(the event with an emptyb64) andbridgeScreencastBase64Length(Math.ceil(n/3)*4), withencodeBridgeScreencastFramebuilt from the former. - Screen test setup hoisted to file level — the shared mutable
dependenciesis reset per test, includingrouteGrantsandclient, pinned by a final guard case so a case that grants the screencast lane cannot leak into the next.
I checked the exactness premise — base64 is ASCII, so JSON escapes none of it and the pre-encode price equals the encoded frame — and the existing over-cap diagnostic case pins the reported frame size to 666,668 + 194 bytes, which the new price still reproduces. I also removed the pre-encode check locally and confirmed the two new window/over-cap cases go red (encodes: 10 and encodes: 1 where zero is expected), so the new coverage is real. The three changed test files pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… carries (OTA phase C, C6) (#21769) C6.1 (#21758) pinned the frame `decodeBridgeScreencastFrame` hands back with an exact `toEqual`; C6.2 (#21754) made that decoder carry the wire's `b64` on the frame so the page's data URI can reuse it. Each PR was green against the main it branched from, and their squashes together red two of C6.1's cases on main. The pins stay exact and gain the field, with the encoded string spelled out rather than wildcarded. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

Summary
Phase C, C6.1: the shell's half of the screencast binary lane (
design-ota-c6.md§1, §7; rulingsrulings-ota-c6.md1, 2 and 5). Eleven commits onee61e3bd41, inert: no route declares the grant, no registered route reaches the browser pane, and a page that does not ask for binary frames sees the same JSON stream as before.The bridge contract already carried the lane (
event.binarywithb64,format,frameSeqand metadata;subscribe.wantsBinary; the page-side decoderdecodeBridgeScreencastFrame, whose docstring handed the encoder to C6). The shell side never honouredwantsBinary, so a page asking for binary frames got nothing, and a screencast frame over the 640 KiB message cap ended the stream withoverflowfor good.4833dcdc06BridgeHostSubscriptionshonourswantsBinary: the native listener is handed an encoder that turns aBrowserScreencastFrameinto the envelope'sevent.binary, round-tripped through the real decoder byte for byte; a fresh three-bytes-at-a-time base64 encoder (bridge/bridge-screencast-encoder.ts), written for a cost argument that survives not knowing Hermes rather than the per-byte one being quadratic, which on V8 it is not (the docstring carries the four measured variants and the correction)73c46f4563event.binaryover the frame cap or the unacked window is dropped and the stream lives, a JSON event over the same cap still ends withoverflow, both pinned side by side; a per-subscription and per-host dropped-frame count reaches the shell's dev facts line (mobile-web-shell-dev-facts.ts, absent at zero)ca304ac887screencastBinary(bridge/bridge-screencast-grant.ts) in the shell's implemented set; one camelCase token because the manifest'sGRANT_NAME_PATTERNadmits one token or anative.<a>.<b>verb and refusesbrowser.screencast, characterised inmanifest-contract.test.ts(not red-first: the pattern already admitted the name)94d831a235dd019cba1bf843f2b48ebridgeBinaryLaneVerdictreads the session's resolved grants, the same listinit.grants.nativeis built from, so the host offers the lane ininitexactly when it will serve it (pinned as its own case); ungranted, the subscription proceeds as today (JSON events, no error frame, pinned positively). Found by the lane and ruled in: per-route grants exist to stop exactly this class. The existing bridge-hook test red on it, because its dropped-frame case had been receiving binary frames ungranted all along8174f8bf0bbridge-host.tswas at 298 of 300 counted lines; the page's three stream frames (open with its four refusals and the lane verdict, cancel, ack) move intobridge-host-stream-frames.ts, a pure move apart from a two-line local alias (servesBinaryFrames) inlined at its one call site: no test changed or added, 745 tests green on the same assertions; host 298 → 270 and new module 59 at the split, 271 and 60 at the head290c35f872bridge-host-subscriptions.ts228 → 179 lines65c36e70f8onBinaryFramesDropped: setDroppedBinaryFramesupdated React state on every dropped frame in a production build too, where the dev-facts line renders nothing, so an over-cap page re-rendered the shell screen once per dropped frame (measured: five drops, five extra renders; with the fold, zero). The dev-facts module now owns the number behind its line and the rule that it is state only where something renders it; the screen holds neither flag nor counter.isDevelopmentBuildbecame a call rather than a module constant so a production case can exist at all (a build flag never changes at runtime). Found while writing that case: the screen test'susePageHostSnapshotdouble returned a fresh object per render, the identity the host effect is keyed on, so every case in that file had been measuring a host rebuilt on every render; the double now returns one objectd9311e0c8c[1]where[1, 0]was expected; the reset also fires on the first build, so both hook cases pin a leading zero rather than a flag suppressing it); theBUILD_ID_PREFIX_LENGTHdocstring that stayed behind abovefailureMessagewhen the constant moved, and the doubled docstring on oneitinpage-route-policy.test.ts, deleted846be963aabinary-lane-refused(one arm in the union, one line in the reporter, deduped per host) when a page asks for the lane ungranted; the verdict answersserve/not-asked/ungrantedso the decision and the report read one rule; silent when never asked and silent when granted are both pinnedNo reader of a grant is a closed enum (page
BridgeGrantsSchema.nativeand the shell's route schema are both open string arrays, the latter's docstring saying an unknown grant leaves that one route native), so an older shell parses a manifest namingscreencastBinaryand renders the session route natively, and an older page holds the string and does nothing with it.BRIDGE_PROTOCOL_VERSIONis untouched.Measured (Node, the vitest runtime; Hermes unmeasured, C6.6 measures the device)
The dropped-frame counter read back in test: totals
[1, 2]across two streams,dropped: 1each,bytes: 666,862(image 666,668 plus the 194-byte envelope, computed independently).Not in this PR
bridge-screencast-grant.tsonce both have landed.Verified
846be963aa: mobile tsc, ratchet (728 files), whole-tree oxlint, oxfmt, root oxlint and oxfmt on the changed files, full mobile suite (732 files, 8276 passed, noErrorsline), config/scripts with mobile deps required (223 files, 2053 passed), root shared suite, both changed-code gates, node tsc, machine-path grep clean;origin/mainis an ancestor, so the merge tree is the head.846be963aa): approve, every ruling reproduced under mutation (binary branch cancelling: 6 red with the JSON control green; verdict alwaysserve: 4 red; grant out of the implemented set: 12 red); its lows ared9311e0c8c.65c36e70f8): approve; ten mutations red as claimed with the JSONoverflowcontrol green throughout; the realusePageHostSnapshotholds oneuseStateobject, so the old test double was rebuilding the host per render; its two lows are290c35f872.846be963aa: the reset on host rebuild (alreadyd9311e0c8c) and the production render path (65c36e70f8).verify-gates.shondd019cba1b,846be963aa,d9311e0c8c,65c36e70f8and290c35f872againstee61e3bd41(mobile 732/8269, 732/8276, 732/8277, 732/8279 and 732/8283, config 2053, all exit 0, machine paths 0; merge-tree clean against8dee68a8d1); forcing the over-cap binary branch to cancel reds the five drop and counter cases and leaves the JSONoverflowcontrol green; making the lane verdict alwaysservereds exactly the two ungranted cases (no listener handed, diagnostic reported) and nothing else of 748; on290c35f872, removing the pre-encode window check reds exactly the two counting-encoder cases; the split commit's diff touches only the two modules and no test.Part of the mobile OTA plan (Phase C). Reference PR #13386, never merged.