fix(device): stop stream and clear first-frame timer on unsupported Simlock AVCC codec #48247
main fromrefs/pull/48247/head·opened View on GitHubProblem#
In packages/client-runtime/src/device/stream.ts (readIosVideo), the serveSimOnly unsupported H.264 codec branch called setStatus("error", detail) and returned without calling fail(detail). Because start() arms frameTimer for FIRST_FRAME_TIMEOUT_MS (15 s), the timer stayed armed, left the input WebSocket open, and 15 seconds later fired fail("No video received from the device. Reconnect to try again."). On web and desktop (Electron), DeviceWorkspace.tsx (serveSimOnly={props.hostKind === "simlock"}) and ThreadPreviewMiniPlayer.tsx pass serveSimOnly: true for Simlock hosts, deviceStreamSession.ts stores each onStatus update, and DeviceStreamView.tsx renders the latest detail, overwriting the specific codec error after 15 seconds. (Mobile's DeviceStreamWebView.tsx already latches the first error, ignores later messages, and stops the WebView stream, so mobile shares the createDeviceStreamClient cleanup without reproducing the visible overwrite.)
Deterministic repro on origin/main (9a08ffb84084c441dcf4a2f595682a44632ecc89):
- Start
createDeviceStreamClientwith{ platform: "ios", deviceId: "test-device", serveSimOnly: true, access: { httpBase: "https://test/api/device-hub", wsBase: "wss://test/api/device-hub", credentials: true, query: {} } }, mockVideoDecoder.isConfigSupportedto resolve{ supported: false }, enqueue a valid AVCC description envelope (tag = 1,avcCforavc1.64001f), and advance fake timers by15_000ms. - Command:
vp test run packages/client-runtime/src/device/stream.test.ts -t "stops the stream and clears the first-frame timer on unsupported Simlock AVCC codec" - Observed on
origin/main:sockets[0].closeis called0times,vi.getTimerCount()remains1, and after15_000msonStatusreceives a second"error"with"No video received from the device. Reconnect to try again.". - Expected:
fail(detail)stops the client (closing the input WebSocket and clearingframeTimer), notifiesonInputConnected(false, detail), and emits the specific codec error once.
Change#
Replaced setStatus("error", ...) with fail(...) in the serveSimOnly unsupported-codec branch of readIosVideo (packages/client-runtime/src/device/stream.ts), matching the other terminal errors in createDeviceStreamClient. Web, desktop, and mobile all share createDeviceStreamClient from packages/client-runtime, so web/Electron no longer overwrite the visible codec error and mobile shares the immediate client cleanup, with no contract, i18n, or UI changes required. Added one focused regression test in packages/client-runtime/src/device/stream.test.ts with a complete avcC record.
Scope#
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification#
- Base (
9a08ffb84084c441dcf4a2f595682a44632ecc89):serveSimOnlyunsupported-codec regression test failed becausesockets[0].closewas called0times and the 15 sframeTimerremained armed. - Head (
f4990e525e5859ce42fd55c71f0b304ca7d96ffa):vp test run packages/client-runtime/src/device/stream.test.tspassed (29/29), includingstops the stream and clears the first-frame timer on unsupported Simlock AVCC codec. - Checks:
vp run check:changedexited0(vp format,vp lint,vp knip,vp typecheckacross 7 packages, andpackages/client-runtime/src/device/stream.test.ts29/29 passed). - Before/after transcript & SHA-stamped check summary: https://gist.github.com/saphid/bab5d97162f2e5a63bfa16feed8d7582
- Not shown: Browser scenario rendering the live Simlock Device panel alert past the 15 s first-frame deadline against a real Simlock host (verified via
createDeviceStreamClientruntime unit test with fake timers, a completeavcCrecord, and stubbedVideoDecoder.isConfigSupportedrejection).
Authored by Gemini 4 Neon (Antigravity); reviewed by GPT-6.2 Sol (Codex).
Not shown#
- .github/pull_request_template.md:27 — Replace the evidence link or update the gist: it shows the superseded three-branch patch and a filtered 30-test suite, not the 29/29 run or
check:changedresult at f4990e525e58. Attach the exact-head logs, or say that the linked transcript does not verify them. - packages/client-runtime/src/device/stream.test.ts:646 — The linked base run stops at the socket-close assertion, before measuring the timer or observing a second status. Label those effects as source-traced unless a separate transcript records them, and describe the decoder stub as resolving
{ supported: false }, not rejecting. - apps/web/src/components/device/DeviceStreamView.tsx:491 — No runnable
scenarios:provefixture or live-client proof exercises the visible alert past 15 seconds; the currentNot showndisclosure is accurate. If adding a fixture, assert that the codec message remains visible after the deadline.
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
d3dbe18Macroscope's review found this PR approvable — Unsupported Simlock AVCC codecs now stop the affected stream and clear its timers while preserving the codec-specific error. The change is limited to an existing failure path and uses established cleanup behavior.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Walkthrough
-
When AVCC decoder configuration fails on a
serveSimOnlyhost,readIosVideonow callsfailwith the device-stream decode error. A regression test checks the error and resulting stream cleanup.Changes: Simlock AVCC decoder failure
Layer / File(s) Summary Route decoder failure through fail
packages/client-runtime/src/device/stream.ts,packages/client-runtime/src/device/stream.test.tsFor serveSimOnlyhosts, the decoder failure branch now callsfail. The test checks the codec-specific error, socket closure, input disconnection, timer cleanup, and absence of a duplicate error after 15 seconds.Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Merge Risk:
Minimal · up tod3dbe-
Unsupported H.264 codec failures on simulator-only hosts now stop the stream and keep the specific codec error instead of a later timeout error. The change is small and tested, and the risk of merging it is low.
Pre-merge checks:
4-
Check name Status Explanation Title check The title is a conventional commit that names the main change: the Simlock AVCC unsupported-codec path now stops the stream and clears the first-frame timer. It matches the raw summary, which describe… Description check The description follows the template's Problem, Change, Scope, and Verification sections and gives concrete detail. The Problem section names the faulty branch, the timer behavior, and the 15 s overwr… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title is a conventional commit that names the main change: the Simlock AVCC unsupported-codec path now stops the stream and clears the first-frame timer. It matches the raw summary, which describes replacing setStatus with fail in readIosVideo, and the objectives, which describe the same terminal-path behavior. It is specific and does not rely on vague terms.
Full details: Description check
-
Explanation
The description follows the template's Problem, Change, Scope, and Verification sections and gives concrete detail. The Problem section names the faulty branch, the timer behavior, and the 15 s overwrite. The Change section explains the fail() replacement and the regression test. Scope states why no issue is needed. Verification gives a base-versus-head comparison and a check summary, and it discloses what was not shown. Some evidence is weak. The linked gist reportedly shows a superseded patch and a filtered suite, and the base run stops before the timer and second-status assertions. The description's own review notes flag these gaps. The template also asks for the agent model and harness at the end, and the description includes that line. Overall the description is mostly complete, so it passes, but the evidence link should be corrected.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 7b6a2c9
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6d827f2c-ba47-4eff-b49a-cbfeed5f895a
Commits-
Reviewing files that changed from the base of the PR and between 7b6a2c96f646830f10183339c2031141dd2801ca and d3dbe18219e086f086bdcc868f9ee02594644db6.
Files selected for processing: 2-
packages/client-runtime/src/device/stream.test.tspackages/client-runtime/src/device/stream.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
-
-
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes