Repository navigation
fix: review leftovers (task id escaping, transcoder limit, fewer polls, leftover HID state) - #193
Merged
Merged
Conversation
A task's id is the page's own (`t<n>`), but it is read back from localStorage on reload and was put into attributes unescaped (turnHtml, the run bar) and into querySelector strings (the elapsed-time timer). It now goes through esc() in HTML and CSS.escape() in selectors, so an edited stored record can't add attributes or break the timer. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A page whose browser can't decode HEVC gets the phone's own video (iOS 27+) as H.264 from an ffmpeg of its own, which decodes 60 fps HEVC and encodes again: a core or more each without a hardware decoder, and hardware encoders only take a few sessions. There was no limit. Now `transcode::Slots` gives out 4 places; a page past that gets 503 with Retry-After, shows "picture lost, retrying" and gets in once another page closes. Logged at most once a minute. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Each page polled /api/info every 2 s, the task list every 3 s and the device panel every 10 s with three requests, two of which (/api/daemon, /api/devices) read the same daemon snapshot, and kept doing so in a background tab. Now: - the task list comes with /api/info (`?tasks=1`, asked only while the page wants to pick up a task: the same condition adoptTask had), so it has no poll of its own; adoptTask takes the list it is given - /api/daemon carries the device list (`devices`, `fixed`, `auto`, as /api/devices, which stays), so the device panel asks two requests - a page in a background tab doesn't poll /api/info or the device panel (the alert check already didn't) and catches up when shown again Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ehind A daemon that ends with the HID session open (the watchdog's exit(1) while a request is stuck holding the device lock, a crash, SIGKILL) never stops the screen media stream. On an iPhone 15 Pro Max (iOS 27.2.1) the Dynamic Island then kept the "viewed" icon and the phone didn't auto-lock for 5 minutes and more, until something opened a HID session again and closed it properly, which clears it. The watchdog can't close the session first: the lock it is behind is held by the stuck request. So the next daemon does it: a marker `hid-open/<udid>` is written when a session opens and removed when it closes properly (close_hid, drop_tunnel, and so shutdown). Markers found at start are cleared in the supervision round once that phone is ready, by opening a session and closing it (3 tries at most), with a line in the event log. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
With the list in /api/info on every poll an idle page fetched its 10 KB (50 tasks) every 2 s instead of every 3 s. It is asked for at most every 3 s again, as when it had a poll of its own. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
13 of 15 tasks
Derrors
added a commit
that referenced
this pull request
Nov 25, 2026
- /mcp chunked bodies: the raw body is bounded too (the decoded 1 MB plus 64 KB of framing; endless trailer lines or long chunk extensions got 413 instead of growing for a minute), read in 64 KB pieces (about 16 decoding passes for 1 MB instead of 256), and a broken chunk gets 400 instead of a closed connection - /mcp answers: 1xx, 204 and 304 are never sent chunked (they have no body, RFC 9112 6.3) - MjpegStream errors are in the page's language (the stream ran outside the request's language scope) - the scoped-task foreground check matches `Route` like the other dispatch sites - a page's native video connection that closes while it waits for the next media stream (an unlock holds the device for seconds) no longer opens the stream again for nobody - the viewer lets its port go before stopping the agents - media.rs's comment and the changelog no longer say unwatched frames aren't assembled: they are depacketized and scanned, only not copied or queued - CONTRIBUTING's per-package fmt list includes ictl-ax, as CI does - the Unreleased changelog: PR numbers on every line, the iOS 17-18 disk image fix (#186), sections and wording per CONTRIBUTING Not changed: a TTL in front of the token file's stat (microseconds per request; a revoked token would keep working for the TTL). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The last items left from the architecture review of 0.2.14:
t<n>) but is read back from localStorage on reload, and went into attributes (turnHtml, the run bar) andquerySelectorstrings unescaped. Nowesc()in HTML,CSS.escape()in selectors.transcode::Slotsgives out 4 places; a 5th page gets 503 withRetry-After: 10, shows "picture lost · retrying" and gets in once another page closes. Logged at most once a minute./api/info?tasks=1(asked only while the page wants to pick up a task, at most every 3 s as before) instead of its own poll;/api/daemoncarries the device list (devices,fixed,auto;/api/devicesstays), so the device panel asks two requests a round instead of three; a background tab doesn't poll/api/infoor the device panel and catches up when shown.exit(1)while a request is stuck holding the device lock, a crash, SIGKILL) never stops the screen media stream. Onmain, afterkill -9with a HID session open, the Dynamic Island kept the "viewed" icon and the phone didn't auto-lock for 5 minutes and more. The watchdog can't close the session first (the stuck request holds the lock), so the next daemon does:hid-open/<udid>is written when a session opens and removed when it closes properly; markers left over are cleared once that phone is ready, by opening a session and closing it (3 tries at most), with a line in the event log.Not in this PR: moving the
idevicepin. The latest release is still 0.1.68 (2026-09-15), which doesn't contain our pinned commit89702099; master has 6 more commits but no release.Tests
1. Unit tests
cargo test --workspace --all-features --locked: 553 passed;cargo clippy --workspace --all-targets --all-features --locked -- -D warnings;cargo fmt --checkper package;node --test tests/viewer/*.test.mjs: 36 passed;tests/check_regression_cases.py: 0 missinga task id from storage stays inside its attributes(fails onmain, passes here),transcoding_pages_are_limited_and_their_places_come_back,a task list from the info poll is used as it is,markers_outlive_the_process_until_clearedwantsTasks)#[ignore]tests of the changed area: none apply2. Real-device regression
e8e011f; the last commit (asking for the task list at most every 3 s) only changes the page and was checked with the page teststests/device/run.py: 2 rounds, 32 calls, 0 failedtests/device/scenarios.py --lock --url tools typing delivery batch menu idle lock url: 52/523. Regression cases (docs/dev/regression-cases.md)
scenarios.pyas above4. Real-device proof of the fix or feature
main,kill -9of the daemon with a HID session open left the "viewed" icon and no auto-lock for 5+ minutes (checked by status without unlocking, then a screenshot). On this branch, the marker was there while the session was open; afterkill -9the new daemon was ready 13 s later, logged "cleared the phone's leftover viewed remotely", the marker was gone and so was the icon. After a normal 30 s idle close the marker is removed tooGET /video?udid=…at once: four got H.264 (one VAAPI ffmpeg each), the fifth503withRetry-After: 10, one warning in the log; when they closed the ffmpegs ended and a new/videogot 200/api/info?tasks=1carriestasks,/api/infodoesn't;/api/daemoncarries the samedevices/fixed/autoas/api/devicesChecklist
🤖 Generated with Claude Code