Skip to content

feat(presentation): presentation mode with manual start and mirror trigger - #504

Merged
tieubao merged 5 commits into
developfrom
feat/presentation-mode
Nov 15, 2026
Merged

tieubao merged 5 commits into
developfrom
feat/presentation-mode

Conversation

@tieubao

@tieubao tieubao commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What

Presentation mode (F4, direct build on macOS 27). While it is on, every app except the keep-list is hidden, and the apps in the sensitive list stay hidden even when the arrow is clicked.

  • Manual start: shortcut (presentationShortcut), an item in the arrow's context menu ("Start/Stop Presentation Mode", the shortcut shown beside it), and the "Presenting" capsule (click for what is hidden and why, and Stop Presenting).
  • One automatic trigger: display mirroring (presentationAutoMirrorEnabled, default off), read from the existing screen-parameters notice with CGDisplayIsInMirrorSet.
  • Camera or microphone: the restriction lifts at once, the capsule reads Paused, and it resumes 2.5 s after both are idle. Level-triggered; starting while capture is already active goes straight to Paused.
  • One desired-list function (hold(whenBar:)) and one reconcile (reconcileHold) in NativeVisibilityEngine. An app launch, a clock click, pressClock's restore and any re-activation compute the list from current state, so the strict list is never swapped back to the normal one while presenting. Turning the mode off recomputes the normal list (the exact pre-mode list when nothing else changed). Quit releases explicitly (willTerminate) as well as by process exit; a crash fails open.
  • Settings, General: "Presentation mode" group (Turn on automatically, Sensitive apps with the Edit picker, Keyboard shortcut) and the camera footnote. The General pane now scrolls inside a 720 pt window.

Pref keys

Key Type Default Whitelist
presentationAutoMirrorEnabled Bool false .number
presentationSensitiveApps Dictionary [bundleId: true] empty .dictionary
presentationShortcut Data unset .data
presentationModeActive Bool false internal, not whitelisted; written for scripts, never read back to resume

All three user-facing keys are in SettingsWindowTests (legacyBoolKeys / legacyOtherKeys, the Bool row is a boundSwitch) and in AppStoreMigrationTests.appKeys. The direct-only rows are in the App Store hidden-rows test.

Decisions (Han approved the plan; these are the calls I made inside it)

  • The slideshow trigger is out: no presentationAutoSlideshowEnabled key, row or code. Future work: build it only after the wave verifier's live Keynote check passes (frontmost app plus a whole-display window it owns). No screen-share detection, no "display added" or AirPlay trigger.
  • The board's "Turn on automatically" popup is a switch with the caption "When a display is mirrored.", because the key is a Bool and the slideshow choice is gone.
  • The capsule is its own status item shown only while the mode is on (own bundle id, so it is always allowed). The arrow stays an arrow: a click expands (sensitive apps stay hidden) and shows the Edge board's note "Slack, 1Password, Tailscale stay hidden". The capsule opens the Light board's panel, Stop Presenting, or the Edge board's pause explanation (shown once per session, later the capsule just reads Paused).
  • Pause copy follows the lead: macOS hides the capsule that names the app using the camera or microphone; the corner dot stays. The copy never says the dot is hidden. The screen-sharing indicator cannot be paused for (no public signal); the pause copy says to share one window.
  • Clock and battery: which of the 0..<64 system item ids are those two has not been measured, so the strict list keeps the same system item ids as the normal one. Every third-party app is hidden. The wave verifier should measure the ids (spike gap 5) and narrow NativeVisibilityEngine.presentationSystemItems.
  • Extra phase "Couldn't hide" (not on a board): when macOS refuses the strict list, the restriction fails open and the capsule says so instead of "Presenting".
  • No Accessibility: the strict list needs no layout read, so a presentation still hides; the expanded presenting list falls back to the strict one, never to revealing.
  • A clock click while presenting does nothing (no lift, no Notification Center expand).
  • A manual start does not survive a relaunch. A mirrored display at launch starts the mode just before the launch collapse.
  • Stopping a mirror-started mode while mirroring continues keeps it off until mirroring ends and starts again.
  • Stopping leaves the bar collapsed under the normal list (it does not re-expand a bar that was open before the mode started).
  • General scrolling: window cap 720 pt (PreferencesWindowController.maxWindowHeight); a pane taller than that is hosted in a scroll view, others are untouched. The height test now asserts the cap and that General scrolls and About does not.
  • Not built: the Shortcuts "Set Presentation Mode" action (needs App Intents, outside the manual-mode scope).

Tests

Full scripts/test.sh (both schemes), exit 0: direct 474 passed, 0 failed (HiddenBarTests + HiddenTests); App Store 328 passed, 0 failed. (Parallel clones on the shared Mini sometimes die with "test runner exited before establishing connection" while another worker's tests run; re-running, or --no-parallel-testing, is clean.)

New tests: PresentationStateTests (state machine: manual, mirror cause, stop, capture pause, quiet period, flap, refused hold), PresentationModeEngineTests in MenuBarEngineTests.swift (swap before drop, app launch while presenting, stop restores the exact list, sensitive apps on the expanded list, clock click, capture lift and resume, flap, start while capturing, no layout, out-of-order completions, refused list fails open, quit lifts, mirror start and stop, manual outlives mirror), DisplayMirroringTests, and PresentationViewsTests (Settings group, direct-only gating, dictionary storage, picker, panels, pause copy, note, capsule, menu shortcut).

Negative control

Committed first, then one production change reverted or mutated per run, bash scripts/test.sh --scheme direct --no-parallel-testing, exit 1 each time, restored with git checkout -- <path> (tree clean after each):

Mutation Failing tests
startPresentation does nothing 15, among them testManualStartSwapsToTheStrictList, testStartWhileExpandedCollapsesTheBar, testStopRestoresTheNormalListIncludingNewApps
mirror trigger ignored testMirrorTriggerHoldsAndLifts
capture pause does not lift testCaptureStartLiftsTheRestrictionAtOnce, testResumesTwoAndAHalfSecondsAfterCaptureEnds, testStartWhileCaptureIsActiveNeverHolds
quiet period 0 s testAFlappingMicrophoneDoesNotFlapTheBar, testFlappingCaptureNeverHidesEarly, testResumesAfterTheQuietPeriod, testResumesTwoAndAHalfSecondsAfterCaptureEnds
reconcile computes the normal list from state alone (the old allowLaunchedAppsIfIdle) 7, among them testAppLaunchWhilePresentingKeepsTheStrictList, testExpandedWhilePresentingKeepsSensitiveAppsHidden, testOutOfOrderCompletionsNeverLeaveTheWrongListHeld
a refused activation keeps the hold (no fail open) testRefusedStrictListFailsOpen
quit does not release testQuitLiftsTheRestriction
stop does not reconcile testStopRestoresTheExactPreModeList, testStopRestoresTheNormalListIncludingNewApps, testOutOfOrderCompletionsNeverLeaveTheWrongListHeld, testMirrorTriggerHoldsAndLifts

The capture tests run with the 1.11.2 option off, so only the presentation pause can lift them.

Snapshots (offscreen, -settingsSnapshotDir, fixture data, no pref written)

direct-present-<state>-<light|dark>.png for pill (Light and Dark boards: capsule, panel with why, hidden apps, sensitive apps, Stop), paused (Edge board: Paused capsule and explanation), click (Edge board: the arrow note), failed (no board), and settings (Settings board: the General tab scrolled to the Presentation group). The scrolling General tab is in direct-general-<light|dark>.png. The Entry board's context menu is an NSMenu and cannot render offscreen; its title and shortcut are unit tested. Compared by eye with the boards; the panel, capsule, chips, copy and rows match, with the pause copy deliberately reworded (capsule, not light) and the slideshow row removed.

Live checks left for the wave verifier

Clock and battery system item ids; how two overlapping assertions combine during a swap; the real mirrored-display name (the mirroring display is often absent from NSScreen.screens, so the copy then says "a display"); the capsule's position among the status items.

@tieubao
tieubao force-pushed the feat/presentation-mode branch from b72f2d4 to 023e5d4 Compare November 15, 2026 20:25
Manual start (shortcut, arrow menu, capsule) and one automatic trigger, display
mirroring, hold a strict allow-list: every app hidden, or the hidden section
shown minus the sensitive apps. Every change to what is held goes through one
function in NativeVisibilityEngine. It lifts while a camera or microphone is on
(resumes 2.5 s after both are idle) and when the app quits.

General tab: Presentation mode group; the pane scrolls inside a 720 pt window.
@tieubao
tieubao force-pushed the feat/presentation-mode branch from 07c5df6 to 838348e Compare November 15, 2026 20:53
@tieubao
tieubao merged commit b507df0 into develop Nov 15, 2026
3 checks passed
@tieubao
tieubao deleted the feat/presentation-mode branch November 16, 2026 01:33
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