Skip to content

feat(station): add Mac privacy curtain and phone-sized or 120 Hz virtual displays - #10511

Merged
CommaBot merged 2 commits into
mainfrom
feat/screen-virtual-display-curtain
Dec 6, 2026
Merged

CommaBot merged 2 commits into
mainfrom
feat/screen-virtual-display-curtain

Conversation

@CommaBot

@CommaBot CommaBot commented Dec 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Phone-sized & 60/120 Hz virtual displays (VirtualDisplay.swift, Resolution.swift):
    • Allow upright and rotated phone virtual display bounds (short side >= 360 pt, long side >= 600 pt, e.g. 390x844 and 844x390) while keeping physical display offered() modes unchanged.
    • Size the single reused CGVirtualDisplayDescriptor to max(pixelWidth, pixelHeight, 3840) on both axes so portrait/landscape rotation reuses the same display cleanly; support 60 Hz and 120 Hz mode selection (physical displays still mirror it).
  • macOS Privacy Curtain (Curtain.swift, Daemon.swift, ScreenView.swift):
    • New curtain op and hello.capabilities entry (curtain): places black pass-through NSWindow overlays (sharingType = .none) on physical displays, intercepts local keyboard/mouse via .cgSessionEventTap passing only events tagged with a random per-process Curtain.mark, excludes Helper windows from ScreenCaptureKit (excludingApplications + unframed fallback when capture starts before Helper has an on-screen window), and silences default audio output (mute or per-channel volume-0 fallback, default-output switch listener, per-UID crash recovery marker).
    • Double-Esc within 1s locks the screen first then uncovers and revokes remote control; passive teardown (last view ends, station lock: true) locks first and keeps the curtain up if lock is not confirmed, while double-Esc and Helper quit/restart/signals always uncover so the local owner is never locked out.
    • Refuses activation with no open view, while IsSecureEventInputEnabled() is active, without Accessibility event tap, or when audio cannot be silenced.
  • Node Station & Pion Station (station/src/screens/, station/src/mesh/screens.ts, pion/station-host/host_connects/):
    • Driving-view-only {t: "curtain", on} and {t: "resolution", width, height, hz?} (min side 360, hz 60/120), atomic Helper-side owner tracking across overlapping views, eager Pion Helper watch wake + reconnect reconciliation, and per-source resolution restore when the last view (driving or watch-only) leaves.
    • 5-language i18n strings (station.helper.curtain) synced across Node & Pion catalogs.

Verification

  • Swift: swift test — 111/111 passed (pure-logic/mock FakeHost, avoiding macOS 27.0.1 WindowServer virtual display leak on shared host).
  • Node Station: tsgo --noEmit clean; screens.test.ts + mb-reader-contracts.test.ts + screen-input.test.ts — 112 passed, 1 skipped.
  • Pion Station: pionc check + fmt --check clean; host_connects — 143/143 passed.
  • Repo gates: station-pion-sync.ts, changelog.ts, gen-i18n.mjs --check, gen-pion-i18n.mjs --check all passed.

Remaining Real-Mac Manual Smoke Checklist (before production reliance)

  • Start ScreenCaptureKit stream with no Helper windows -> activate curtain -> verify viewer sees desktop (not black) and local displays are black.
  • Verify remote keyboard/mouse pass through while local keyboard/mouse (including cursor movement) are blocked.
  • Verify double-Esc locks screen before uncovering and drops viewer to watch-only; verify network disconnect / app close locks screen.
  • Verify audio mute / HDMI volume-0 restore and default-output hot-switch muting.
  • Verify 390x844 <-> 844x390 virtual display creation/rotation and measure real SCK fps at 120 Hz mode.

Prepared & reviewed with Gemini 4 Neon, Claude Opus 5.5, and GPT-6.2 Astra; verified via Swift Testing, Node test runner, and Pion test runner.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

zuozijian and others added 2 commits December 6, 2026 13:37
…ual displays

The Mac Helper now makes its own virtual display at phone sizes, upright or
turned (short side at least 360 points, long side at least 600, such as
390x844 and 844x390), with its modes at 60 or 120 Hz. It reuses the one
virtual display it already makes, sized so that display turns both ways, and
the Mac's display still mirrors it, so a mirrored panel shows it at the
panel's own rate. The offered physical display modes do not change.

The Helper also adds a privacy curtain (`curtain` op, `curtain` capability in
`hello`). While it is up, the Mac's own displays are black, a session event
tap holds the local keyboard and mouse, and the default output is muted. The
tap passes only events that carry the Helper's random per-process mark, which
the Helper sets on the viewer's input. Capture leaves out every Helper window,
so the viewer still sees the desktop. A view whose capture started before the
Helper had a window on screen gets a new filter once the curtain windows are
up. The Helper refuses the curtain with no view open, while an app has secure
event input on, without the event tap, or when it cannot silence an output
that is there. It mutes the output, or sets the volume to 0 on an output with
no mute, and it does the same to an output that becomes the default while
the curtain is up. It records each output by UID and restores each one later,
also on the next start after a crash.

Pressing Esc twice on the Mac within a second locks the screen, then takes the
curtain away. The Helper also locks first when the last view ends, on quit,
restart, or a termination signal, and when the station asks with `lock`. If
the screen does not report that it locked, the curtain stays up when the last
view ends or the station asks with `lock`. It still goes after an Esc or when
the Helper ends, so the person at the Mac can always get back in. The Helper
takes the curtain away for a named `owner` only if that owner put it up. It
answers a `lock` request after the screen reports locked, or with `on: true`
if it kept the curtain up. If a newly switched output cannot be silenced, the
Helper locks the screen and takes the curtain away.

The Node station gives the curtain only to a person's driving view
(`{t: "curtain", on}`), and the view that put it up holds it. When that view
only watches or ends, the station locks the screen and takes the curtain
away. It does not take away a curtain that another view put up later. The
station also locks first when the last view ends and before the Helper quits.
Only the driving person's own off request skips the lock. After an Esc on the
Mac, the station tells the view why and makes it only watch.

The Pion station has the same curtain input, holder (named to the Helper as
`owner`), lock, and Esc notice from the Helper's watch. A desktop view wakes
that watch, and the watch checks the curtain each time it connects. It also
now handles `{t: "resolution", width, height, hz?}` for the Mac and puts the
first mode back when the screen's last view ends, whether that view drove or
only watched. Resolution asks accept 360-point sides and an optional
`hz` of 60 or 120.

Changelog: 新增:远程控制 Mac 时可开启隐私幕布,本机屏幕黑屏、本地键鼠与扬声器被暂停,在本机连按两次 Esc 会先锁屏再结束幕布;虚拟屏支持手机竖横屏尺寸,并可选 60Hz 或 120Hz 模式
Changelog-parts: station
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ost or refused ask

A Pion view whose curtain ask got no answer read the curtain back and took any
`on: true` as its own, including another view's curtain that was still
locking before it went. The Helper now says the holder (`owner`) when the
curtain is read. The view claims the curtain only when that owner is its own
serial, so a refused ask holds nothing and reports nothing up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CommaBot
CommaBot merged commit 125df50 into main Dec 6, 2026
108 of 109 checks passed
@CommaBot
CommaBot deleted the feat/screen-virtual-display-curtain branch December 6, 2026 04:54
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.

2 participants