Repository navigation
fix: idle MCP servers don't block updates; native video survives HID closing - #190
Merged
Merged
Conversation
`iphone-control mcp` held the shared maintenance lease for its whole life, and agents (Claude Desktop, Cursor, Claude Code) keep it running for hours, so an update, and auto-patch in particular, was almost always busy on a desktop. The server now takes the lease for each tool call (waiting up to 15 s while an update holds the lock), and the updater's check for older clients lets an `iphone-control … mcp` process be: one of this version is idle if the exclusive lease could be taken, and its next call reconnects to the new daemon (protocol::connect waits for a restarting one). `mcp --url` talks to another machine and takes nothing. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…oses Unlocking natively reads the lock screen with the HID session closed (iOS hides the keypad from accessibility while the screen is streamed), and a bitrate change for a low-bandwidth page reopens it. Each time, every ScreenStream ended and the page reconnected. Now the connection waits for the next media stream (once the device is free: unlocking holds it until done) at the same device and rate, asks for a keyframe and goes on; the page sees a pause. Ten closes in a row without a frame in between, or a changed device, still end it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Derrors
force-pushed
the
fix/mcp-update-lease
branch
from
November 25, 2026 02:57
b906141 to
bfcd181
Compare
This was referenced Nov 25, 2026
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
From the architecture review of 0.2.14 (operations, native unlocking):
iphone-control mcpheld the shared maintenance lease for its whole life, and agents (Claude Desktop, Cursor, Claude Code) keep it running for hours, soupdate, andauto-patchin particular, was almost always busy on a desktop: on the test host five idlemcpprocesses of other sessions held it. The stdio server now takes the lease for each tool call (waiting up to 15 s while an update holds the lock, then going on without it; the daemon takes its own lease per device request anyway). The updater's check for older clients lets aniphone-control [--data-dir D] [--socket S] mcp …process be: one of this version is idle if the exclusive lease could be taken, and its next call reconnects to the new daemon (protocol::connectwaits for a restarting one).mcp --urltalks to another machine and takes nothing. Oldermcpprocesses still hold the lease for life, so they keep blocking until their client restarts them.ScreenStreamended and the page reconnected. Now the connection waits for the next media stream (once the device is free: unlocking holds it until done) at the same device and rate, asks for a keyframe and goes on. Ten closes in a row without a frame in between, or a changed device, still end it.Tests
1. Unit tests
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings,cargo test --workspace --all-features --locked: 535 passedonly_mcp_servers_idle_without_the_lease; the stream reopening has no unit test (it needs a HID session), see 4.#[ignore]tests of the changed area: none apply2. Real-device regression
lockscenario was also run on this branch alone (see below)tests/device/run.py: iPhone 3 rounds, 48 calls, 0 failed; iPad 15 rounds, 240 calls, 0 failedtests/device/scenarios.py: iPhonetools typing delivery collect editing fresh batch menu idle url64/64 andlock13/13; iPadtools typing delivery collect editing fresh batch menu url60/60main(run.py --repeat,compare.py): iPad 23.71 s → 24.01 s total, no step clearly slower; iPhone 17.09 s → 18.21 s,iphone_statusandiphone_wait_forflagged slower on medians of 3, butmain's own rounds range over the same values (status 0.02–0.29 s, wait_for 0.23–0.57 s)scenarios.py --lock lock3 runs, 39/39 (before the video commit was added); iPhone native-video lock/unlock check (section 4) with this branch alone, both commitsOn the iPad,
scenarios.py --lock locknow and then fails one lock: the IOHID power press takes 5.4 s instead of 0.4 s (XCTest waiting for the app to go idle) and the screen stays on. It happens in stretches and onmaintoo: in the same hourmainpassed 7 runs and failed 1 the same way. Not caused by this change; noted in the regression notes for later.run.py output
3. Regression cases (docs/dev/regression-cases.md)
scenarios.pyas above4. Real-device proof of the fix or feature
iphone-control mcpis not among the holders ofmaintenance.lockin/proc/locks; the five older ones are/video?src=deviceconnections open, lock button, then an action that unlocks first (10.3 s): neither connection ended; while locked the phone sent about a frame a second, during the unlock none for 10.1 s, then both resumed from a keyframe. On the combined branch the same (9.7 s unlock). Before this change the stream ended whenever the HID session closed (RecvError::Closedreturned)mcp(needs a signed release install), the low-bandwidth bitrate switch, macOSChecklist
website/guide/cli.md(both languages) no longer asks to close MCP before updating🤖 Generated with Claude Code