Skip to content

Headed mode + iOS-from-Windows (TCP daemon + MJPEG viewer)#3

Merged
jackulau merged 1 commit into
mainfrom
goal/008-headed-rebased
May 26, 2026
Merged

Headed mode + iOS-from-Windows (TCP daemon + MJPEG viewer)#3
jackulau merged 1 commit into
mainfrom
goal/008-headed-rebased

Conversation

@jackulau

Copy link
Copy Markdown
Owner

Summary

  • TCP transport for the iOS + Android daemon IPC (alongside AF_UNIX). IPH_BIND / IPH_CONNECT and ANH_BIND / ANH_CONNECT accept tcp://host:port.
  • Windows / Linux client-only mode for iOS via remote macOS daemon (--remote-daemon tcp://mac.local:5550). Skips local Xcode / WDA preflight when client-only.
  • Screen-stream RPC on both daemons (JPEG frame loop, configurable fps/quality/max-dim) + MJPEG HTTP viewer sidecar (stdlib only, no new deps).
  • --headed / --headless CLI flags on agent, --ios -c, --android -c. Headed launches the viewer + opens browser; headless is the default.
  • Mock-daemon e2e tests covering: TCP round-trip, Windows-mode bypass on non-darwin, screen-stream start/stop, MJPEG serves multipart frames, --headed launches viewer.
  • README + SETUP sections for "iOS from Windows / Linux" remote bridge, headed-mode usage, TCP security caveats (loopback default + SSH tunnel pattern).

Replaces #1

PR #1 was 30 commits ahead of main after the Linux squash-merge (#2). This branch is the same headed-mode + Windows-iOS feature set re-cherry-picked onto the post-#2 main, with the cli.py conflict resolved by keeping both the new env-preflight (from goal/010 D2) and the viewer-lifecycle wrapping. Net: 16 files, ~1750 insertions.

Test plan

  • python3 -m pytest tests/ -q → 591 passed locally on macOS
  • CI matrix (Ubuntu + macOS × py3.11/3.12/3.13)
  • Manual: mobile-use --android -c 'print(active_app())' --headed opens browser viewer
  • Manual: Windows machine connects to Mac daemon via --remote-daemon tcp://mac.local:5550

…aded CLI + docs

D3 — Screen stream RPC (iphone_harness + android_harness):
  - Daemon class: _stream_task/_stream_frame/_stream_fps/_stream_quality/_stream_max_dim state
  - _m_screen_stream_start(fps, quality, max_dim): spawn capture loop, idempotent
  - _m_screen_stream_frame(): pull latest JPEG (base64) — single-consumer
  - _m_screen_stream_stop(): cancel loop, clear buffer
  - PIL lazy-imported (already a project dep via pillow>=10)
  - Frame loop logs+continues on transient errors; doesn't kill stream
  - Helpers: screen_stream_start/frame/stop wrappers (drop conn first to avoid stale cache)
  - Mock daemons: synthetic 67-byte JPEG stub so tests don't need PIL

D4 — HTTP MJPEG viewer sidecar (mobile_use/viewer/):
  - server.py:ViewerServer(platform, port, fps, quality, max_dim)
  - Routes: GET / (embedded HTML), /stream (multipart/x-mixed-replace),
    /still (single JPEG), /healthz (JSON status)
  - Threaded HTTP server (daemon threads) so /healthz doesn't block behind /stream
  - Lifecycle: start() spawns thread + tells daemon to start capture loop;
    stop() shuts server down, releases port, stops daemon capture
  - Stdlib only — no new pip deps

D5 — CLI --headed / --headless flag wiring:
  - main(): parses flags, sets MOBILE_USE_HEADED env (with try/finally restore
    so in-process tests don't leak state to siblings)
  - _maybe_start_viewer(platform): used by _run_ios + _run_android + agent_loop;
    opens browser via webbrowser.open (silent fallback if unavailable); soft
    warning + None on failure (viewer never blocks the -c script)
  - HELP text: 'iOS FROM WINDOWS / LINUX' section; --headed/--headless documented

D6 — End-to-end smoke tests (tests/test_e2e_headed.py):
  - e2e_headed_ios: mock daemon → ViewerServer → /stream returns multipart JPEG
  - e2e_headed_android: parity
  - e2e_remote_iphone: TCP daemon endpoint + client-only mode + RPC works
  - e2e_stream_loop_progresses: frame_no strictly increasing across polls

D7 — Docs (SETUP.md + README.md):
  - SETUP.md: 'Part A* — iOS from Windows / Linux (remote Mac bridge)' section
    with Mac-side setup, daemon TCP launch, Windows/Linux client connect,
    SSH tunnel pattern, security caveat, troubleshooting checklist
  - README.md: 'Headed mode' section (--headed launches MJPEG viewer in
    browser); 'iOS from Windows / Linux' quick-start pointing at SETUP.md

Tests: 38 new (12 screen_stream + 12 viewer_mjpeg + 7 cli_headed + 4 e2e + 3 sanity);
full suite: 572 passed, 1 pre-existing Linux test failure (008-linux-device-support).
@jackulau jackulau merged commit 4e9e9c7 into main May 26, 2026
7 checks passed
@jackulau jackulau deleted the goal/008-headed-rebased branch May 26, 2026 05:30
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