minutes icon indicating copy to clipboard operation
minutes copied to clipboard

Screen-context: Screen Recording permission failure is completely silent (stderr-only; System Settings shows stale grant as enabled)

Open rymalia opened this issue 4 months ago • 4 comments

Summary: When check_screen_permission() (crates/core/src/screen.rs) fails, the only diagnostic is an eprintln! to stderr — invisible when the desktop app records (GUI stderr is discarded). Nothing reaches ~/.minutes/logs/minutes.log, there is no UI signal, and recordings proceed normally minus screenshots. The user has no way to discover why screenshots aren't happening.

Why this bites hard on macOS: macOS never re-prompts for Screen Recording (unlike microphone). After an app re-sign — routine during development — the stale TCC grant still shows as enabled in System Settings while being silently denied. Every layer that could tell the user something is wrong stays quiet.

Repro:

  1. Re-sign (or rebuild ad-hoc) the app so its code-signing identity changes.
  2. Record with screen_context.enabled = true.
  3. Transcript and summary are produced normally; zero screenshots; zero log evidence. (Observed across four real recordings on 2026-07-09 before the cause was found.)

User-side fix once diagnosed: toggle the app off/on under System Settings → Privacy & Security → Screen & System Audio Recording (or remove with − and re-add with +).

Suggested fixes (any subset):

  • Emit a structured log line at recording start: screen_context requested / permission-denied / started (the information already exists; today it only goes to stderr).
  • Surface the denial in the app UI — a badge on the recording indicator, or a health-check row in Settings alongside the other capability checks.
  • Docs note for contributors: changing the signing identity invalidates TCC grants; Screen Recording must be re-granted manually because macOS will never re-prompt for it.

rymalia avatar Jul 10 '26 07:07 rymalia

Case study: how this played out in practice (2026-07-09, one evening, three identities)

Adding a concrete timeline from the dogfooding that led to this issue, because it shows how invisible this failure is even when you're watching closely.

The same /Applications/Minutes.app path went through three signing identities in a single evening:

Time Identity Screen Recording state
(baseline) Notarized Homebrew cask 0.18.2, installed weeks earlier granted — this is the identity the TCC entry was keyed to
~7:38 PM ad-hoc local build (recovery install after #422) grant silently dead; recording at 7:52 PM produced transcript + summary, zero screenshots
~10:27 PM rebuild signed with a personal Apple Development cert still dead (grant keyed to the cask identity); recording at 10:41 PM — same silent result

Throughout all of this, System Settings → Screen & System Audio Recording showed Minutes toggled ON — the stale entry from the cask identity. Meanwhile microphone access re-prompted after each identity change and kept working, which made the recordings look perfectly healthy: live waveform, transcript, summary. The only missing artifact was the screenshots, and nothing anywhere said why.

The trap is the asymmetry: mic self-heals by re-prompting; Screen Recording has no re-prompt path — it silently fails forever behind a healthy-looking Settings toggle until the user manually cycles it. Notably, the session guiding the rebuild explicitly predicted "expect one more round of mic/screen prompts" after the identity change — mic prompted, screen never did. If it fooled a careful build session in real time, it will fool users.

Additional cheap mitigation, script-level: the identity churn happens in exactly two places — scripts/build.sh --install and scripts/install-dev-app.sh. Before replacing the bundle, they can capture the outgoing identity (codesign -dvv /Applications/Minutes.app 2>&1 | grep ^Authority=, or the ad-hoc/unsigned cases), compare it to the identity they're about to sign with, and when they differ print a loud post-install warning:

⚠ Signing identity changed (was: <old>, now: <new>).
  macOS has silently invalidated this app's Screen Recording grant and will NOT re-prompt.
  Re-enable it: System Settings → Privacy & Security → Screen & System Audio Recording → toggle Minutes off/on, then relaunch.
  (Microphone will re-prompt on its own; Screen Recording never does.)

This complements rather than replaces the in-app/log visibility proposed above — the scripts catch the moment the grant dies; the runtime check catches every other way to reach the broken state.

rymalia avatar Jul 10 '26 08:07 rymalia

Confirmed. This is squarely the honest-degradation problem we've been closing across the app (silent engine fallback, silent remote-audio loss, etc.) — a permission failure that only eprintln!s to a discarded GUI stderr, with the macOS stale-TCC-grant twist making it worse. We'll take this one too: surface the failure to ~/.minutes/logs/minutes.log and a status/UI signal, not just stderr. Shout if you'd rather own it given how deep you are in this code. Grouping it with #423 since they share screen.rs.

silverstein avatar Jul 10 '26 17:07 silverstein

Taking you up on that — I'll own this one, grouped with #423 in the same PR (claimed there). Plan, following the honest-degradation pattern:

  • ~/.minutes/logs/minutes.log: structured error line (via logging::log_error) when the permission probe fails at recording start, in both record paths — the stderr line stays for CLI users.
  • ~/.minutes/events.jsonl: new screen_context.unavailable event so agents and the app can react to it live.
  • Immediate UI signal: a macOS notification at recording start ("Screen context is enabled but Screen Recording permission is missing/stale…"), reusing the existing notification path the safety guard uses. This is the one that would have caught my three-identity evening in real time — the app process is exactly where stderr is discarded.
  • minutes health: a Screen Recording item (shown when screen_context.enabled) so there's a one-shot check for the stale-grant trap.

Will link the PR here when it's up.

rymalia avatar Jul 10 '26 17:07 rymalia

Delivered in the same PR: #427. Screen Recording failures are now visible through minutes.log (structured error), events.jsonl (screen_context.unavailable), a desktop notification at recording start, and a new minutes health "Screen recording" item that probes with a real capture attempt. The health check is platform-aware and explicit about which TCC identity it validates.

rymalia avatar Jul 10 '26 18:07 rymalia