Skip to content

Scrawl for iPhone: show an agent anything on your phone - #100

Draft
adamdotdevin wants to merge 4 commits into
kitlangton:mainfrom
adamdotdevin:feat/iphone-app
Draft

adamdotdevin wants to merge 4 commits into
kitlangton:mainfrom
adamdotdevin:feat/iphone-app

Conversation

@adamdotdevin

Copy link
Copy Markdown

Scrawl is great for showing an agent a problem on the Mac. This does the same for whatever's on your phone, in any app, without a cable.

What it is

An iPhone app in ios/ with two extensions:

  • Screen recording (ReplayKit broadcast extension): records the whole screen, whatever app you open, with your voice. Start it from the app's Record Screen or Control Center › Screen Recording › Scrawl; stop from the red indicator and it's on its way. A notification says where it went ("Sent to SCRAWL", "On your Mac", "Couldn't reach your Mac").
  • Share sheet: screenshots (up to ten, a keyframe each, ⟨Screenshot 2 of 3⟩) or a screen recording from any app, with a note that lands as Note: in the summary.

It speaks ScrawlKit's protocol: the same scrawl link pairing, POST /ingest framing and replies. So the Mac builds the same bundle and queues it into OpenCode, and nothing in the bundle pipeline changes. The phone lists the Mac's OpenCode sessions so you can pick where captures go, or leave it on Newest session.

iOS doesn't let one app see another's touches or draw over it, so there's no ink or tap tracking. Spoken cues ("look here") still cut keyframes, and a Flag Moment App Shortcut (Action button, Back Tap, Siri) adds ⚑ flags, like the mirror's M key.

Mac side

Small, all behind the existing token:

  • GET /sessions on the ingest port lists open root sessions for the picker (502 with the error when OpenCode doesn't answer, routing: false with --no-opencode). Older Macs answer any GET with {"ok":true}, which the app reads as "can't list".
  • The token is also accepted as X-Scrawl-Token, since iOS may drop or replace Authorization on background uploads. (ScrawlKit's outbox already sends it to hosted endpoints.)
  • Timeline capture (broadcast / shared → device.capture) and note (→ the bundle's note when import got none).
  • scrawl link defaults to --scheme scrawl.

Existing captures and ScrawlKit uploads are unchanged.

Delivery

Uploads are file uploads on background URLSessions, one identifier per attempt, so an extension can hand one to iOS and exit; iOS wakes the app for the reply. An attempt owns its capture (a claim under an flock the app and extensions share), and only its outcome counts. Lost uploads are reconciled against the tasks iOS actually has, and transient failures retry with backoff, including on a background refresh. Details are in ios/README.md and docs/iphone-and-routing.md.

Testing

  • cargo test: new tests for /sessions (listing, routing off, OpenCode down, no token), the token header, the timeline fields, and recent_root_sessions.
  • iOS unit tests (29): pairing links, upload outcomes and framing, attempt ownership (including 16 concurrent claims), timelines, retention, and both movie writers on synthetic ReplayKit buffers (scaled H.264, 48 kHz AAC, no audio track with the mic off, narration past the last frame kept).
  • ios/scripts/e2e.sh runs simulator UI tests against a sandboxed scrawl serve (its own HOME, captures and port) whose OpenCode is a stand-in: a Python server lists sessions, and OPENCODE_BIN points at a script that writes prompts down. One test pairs, picks a session, sends a test capture and waits for "Sent to"; the other shares a screenshot from Photos through the share extension with a note. The script then checks both bundles and both prompts.
  • Not yet: the broadcast extension on a real device, since ReplayKit broadcasts don't run in the simulator. That's why this is a draft; I'll record on my phone and report back.

Build

cd ios && xcodegen generate. To sign with your own team, copy Config/Local.xcconfig.example to Config/Local.xcconfig. The generated project isn't checked in. The feature map has three new iphone entries.

…ead a timeline's capture and note

- GET /sessions (token required) lists the open root OpenCode sessions a phone can address its
  captures to, newest first, with this Mac's name; routing off lists none, and OpenCode not
  answering is a 502 with the error.
- The ingest token is also accepted as X-Scrawl-Token: background URLSession uploads send it
  because iOS may drop or replace Authorization.
- A timeline's `capture` ("broadcast" or "shared", from the Scrawl iPhone app) becomes
  device.capture, and its `note` the bundle's note when import got none.
- `scrawl link` defaults to --scheme scrawl, the Scrawl iPhone app's.
…ts, and send it to your Mac

An iPhone app (ios/, XcodeGen) that speaks ScrawlKit's protocol, so Scrawl on the Mac builds
the bundle and queues it into OpenCode as it does for ScrawlKit:

- A ReplayKit broadcast extension records the whole screen, whatever app is in front, with the
  microphone (from the app's Record Screen or Control Center's Screen Recording), and hands the
  upload to iOS when it stops.
- A share extension sends screenshots (a keyframe each) or a screen recording, with a note.
- The app pairs from `scrawl link`, lists the Mac's sessions to send to, shows what became of
  each capture, sends a test capture, and offers a Flag Moment App Shortcut for ⚑ flags.
- Uploads are file uploads on background URLSessions, one identifier per attempt; an attempt
  owns its capture (a claim under an flock the app and extensions share), lost uploads are
  reconciled against iOS's tasks, and transient failures retry with backoff.

Unit tests cover pairing, delivery and ownership, timelines, retention and both movie writers on
synthetic ReplayKit buffers; scripts/e2e.sh runs the app and the share extension against a
sandboxed `scrawl serve` with a stand-in OpenCode in the simulator.
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