#533

feat(ios): separate time-limited Screen History agent grants from UI lock

DraftDreaminmasterwants to merge intofrom

Coordination draft

Follow-up proposed by @JosssphZhou in #446 and tracked in #529. This is an initial implementation for discussing policy, not a request to merge or a claim of completed iOS verification.

  • Keep the existing UI lock on backgrounding while preserving a separate, process-local agent grant after explicit consent and fresh owner authentication. Neither first-time PIN setup, normal history viewing, nor automatic Face ID grants agent access.
  • Provisional fixed five-minute duration using ContinuousClock. Queries, backgrounding and foreground refresh never extend it. Expiration changes the access revision under the same lock used to check the grant, including when a read was already in flight.
  • Explicit lock, device lock/protected-data loss, credential changes, biometric enrollment changes and disabling Screen History revoke access. Turning it on again does not restore the old grant; reauthenticate. Existing deletion/app scope revision invalidation remains in effect.
  • Add an independent Allow Agent Access consent sheet, explaining the five-minute window, background operation and possible sending of text to a provider or connected agent, with fresh PIN or biometric authentication and an explicit Lock Screen History Now action. The separate merged disclosure in #523 is preserved. English, Simplified Chinese and Traditional Chinese copy included.

Verification

  • Based on upstream d5711d2; scoped to six files, no workflow changes in this PR; string catalog parses and has exactly two new keys.
  • Added a deterministic continuous-clock expiration test, off/on non-restoration test, and real production-source background/explicit-lock test; updated existing credential and model-request tests to require fresh authentication after revocation.
  • Initial implementation 9d6a5a9: Xcode 27.2 iOS simulator CI — 68 passed, 0 failed, 0 skipped (20 ScreenHistoryTests, 35 ChatHarnessTests, 13 HistoryLockTests). All four standard PR checks also passed.
  • Added two deadline-boundary regression cases in 5bf998b: suspend the production SQLite read, advance an isolated instance of the real grant lease to expiry, and assert the old read is discarded both with and without fresh authentication. The fresh grant must only authorize new reads.
  • Synced to upstream ba0428d and implemented separate consent in 38f3020. Added a regression for setup/view-only authentication, and a connected MCP JSON-RPC session using the real core and history source across simulated background and protected-data notifications. The remote tree matches the locally checked merge; git diff --check and the catalog parse passed.
  • Re-run the exact new revision: isolated Xcode CI, targeting 23 ScreenHistoryTests, 14 HistoryLockTests and 36 ChatHarnessTests. Workflow pushed, execution not yet confirmed.
  • Physical-device/MCP end-to-end checks, actual background suspension and device-lock ordering, and maintainer agreement on duration, duration and consent UX policy. The new deterministic timeout tests use the real lease and production SQLite reader, but isolate the clock and authorization closures; the real singleton gate and device lifecycle are covered separately.

The five-minute value is provisional; happy to adjust the duration/consent UI in coordination. No unrelated retention or page/clipboard follow-ups included.

  • No secrets or private screen contents included.
  • I release this contribution under the AGPL-3.0-only license.

Activity

6
JosssphZhou2d ago

Thanks for taking this on. Keeping the UI lock separate and discarding in-flight results at expiry looks like a good direction. Please keep this in draft while we agree on duration and explicit consent, especially during PIN setup. The updated expiry tests and a device-lock check with a connected agent would help settle the design.

Dreaminmaster2d ago

Thanks for the direction. Updated in 38f3020: PIN setup and normal or automatic unlock are now view-only; a separate Allow Agent Access sheet explains the bounded grant and provider/agent disclosure and requires an explicit fresh authentication. The five-minute maximum remains provisional. I added a regression for setup/view-only unlock and a real MCP JSON-RPC session through the production core and SQLite source across simulated background and protected-data notifications, alongside the two deterministic expiry tests. It is a simulator notification test, not yet a physical connected-device check. Synced current main including #523 and verified the remote tree. The new isolated simulator workflow targets 23 history, 14 lock and 36 chat tests. Keeping Draft as requested until verification and agreement.

This pull request is a draft

Merging is unavailable until it is marked ready for review.