Repository navigation
feat(foundation): shortcut recorder, hotkey registry, app catalog - #497
Merged
Merged
Conversation
tieubao
force-pushed
the
feat/next-features-foundation
branch
from
November 15, 2026 19:09
a937c46 to
eb72644
Compare
Shared pieces the next-features work builds on. - ShortcutRecorderRow: the inline recorder in General, extracted into one control bound to a Data pref key, with a clash warning against the other Hidden Bar shortcuts. A bare letter is refused, Escape cancels, releasing every modifier cancels without clearing the stored shortcut. - HotKeyRegistry: AppDelegate's single hotKey becomes a registry keyed by pref key; register(key:title:handler:) and it rebinds on prefsChanged. - MenuBarItemCatalog (direct build): menu-bar apps from the engine's unrestricted reads plus the pinned-sections table, with first-seen times persisted so only apps new since then are arrivals. Pure merge logic is MenuBarCatalogState. - dump-inventory debug hook, scripts/hb-cmd sender, RUNBOOK section. - .gitattributes: merge=union for the Localizable.strings files.
The engine handed the catalog its layout after filling in apps that only started, so ordinary apps with no menu-bar icon became entries and arrivals. The hook now runs before that fill-in. menuBarCatalogFirstSeen is declared in UserDefaults.Key (internal, not importable). HotKeyRegistry removes its observer from the injected center.
tieubao
force-pushed
the
feat/next-features-foundation
branch
from
November 15, 2026 19:16
eb72644 to
b0ae2d1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The shared foundation for the next-features work (SG-01): three pieces other features plug into, plus the debug sender and a merge setting.
ShortcutRecorderRow(hidden/Features/Settings/): the inline recorder inPreferencesViewController(btnShortcut, btnClear, register/unregister, updateGlobalShortcut, updateModiferFlags, and the keyDown/flagsChanged forwarding inPreferencesWindowController) is now one control bound to aDatapref key. The "Keyboard shortcut" row uses it. A small orange triangle (tooltip "Also used by ...") appears when the chosen combination equals another Hidden Bar shortcut; with no clash the row is unchanged.HotKeyRegistry(hidden/Models/): AppDelegate's singlehotKeyis a registry keyed by pref key.register(key:title:handler:), rebinds when the stored shortcut changes (it re-reads on.prefsChanged),unregister(key:),reload(),clashingTitle(for:excluding:). The type never imports the hot key library;HotKeyRegistry.shared(inAppDelegate.swift) supplies the Carbon binding.MenuBarItemCatalog(direct build only,#if HIDDENBAR_NATIVE_VISIBILITY): menu-bar apps from the engine's reads of an unrestricted bar plus the pinned-sections table. Entry: bundle id, name, icon, section,firstSeen,isRunning. Posts.menuBarCatalogChangedand exposesarrivals. No new read, timer, permission or entitlement. The pure merge and diff logic isMenuBarCatalogState(compiled intoHiddenBarTests).dump-inventorydebug hook andscripts/hb-cmd, documented indocs/RUNBOOK.md(Behavioral verification)..gitattributes:hidden/*.lproj/Localizable.strings merge=union.Why
F1, F2, F3 and F4 each need a shortcut recorder, a way to register a global shortcut, or a list of menu-bar apps, and the contract forbids copying the inline recorder. Building these once keeps every feature on one code path and gives the wave verifier a scripted way to drive Debug builds.
Decisions
.prefsChanged; the registry rebinds. So an imported preference set, a clear and a record all take one path, andAppDelegate.applyImportedPreferencesjust callshotKeys.reload().NSEventlocal monitor (this app's events only, no Input Monitoring) and swallows the keys, soPreferencesWindowControllerloses itskeyDown/flagsChangedoverrides.performKeyEquivalentkeeps its "do not close on Cmd+W while recording" guard throughShortcutRecorderRow.isRecording. Any pane can host a recorder.removeObject) instead of writing the JSONnullthe old setter wrote.Preferences.globalKeyreads nil either way.register(key:title:); the expand/collapse shortcut registers as "Show or hide icons". Two new strings ("Also used by %@", "Show or hide icons") are in all 13Localizable.stringswith English text.firstSeen = nowand reports no arrivals, so upgrading never announces the apps the user already has. After that, an app read for the first time is an arrival. Table-only apps are recorded without being arrivals.firstSeenlives inmenuBarCatalogFirstSeen(internal key, not in the import whitelist, per the contract).com.apple.controlcenter) are not cataloged: not an app to list, search or announce. The Menu Bar Apps tab still shows them as "macOS extras".arrivalsis the diff of the latest read (empty after a read that finds none). A listener that needs every arrival reads it from the.menuBarCatalogChangeduserInfo (MenuBarItemCatalog.arrivalsKey).NativeVisibilityEngine.onUnrestrictedRead, called only from the read path, never from a held restriction) and onNSWorkspaceandAgentLaunchNotificationslaunches and quits (these only changeisRunning). No timer.hb-cmdextras:--timeout(default 15 s) and--dry-run(post nothing, still run the wait, to test parsing and the timeout path without an app). The wait counts only a file newer than the call, so a stale answer does not pass.dump-inventoryanswersoutwith the catalog JSON instead of the state dump; on the App Store build it writes{"available": false, ...}so a caller does not hang.Tests
bash scripts/test.sh --dd ~/.cache/hidden-bar/dd-foundation: exit 0.Hidden Bar, Debug-Direct)Hidden Bar App Store, Debug)New tests:
HotKeyRegistryTests(13),GlobalKeybindPreferencesTests(2),MenuBarCatalogStateTests(10),UnrestrictedReadHookTests(2),ShortcutRecorderRowTests(11, direct),MenuBarItemCatalogTests(12, direct).SettingsWindowTests.test_shortcutRecorder_readsAndClearsGlobalKeynow clears through the recorder.plutil -lint hidden/*.lproj/*.stringspasses.Hosted tests flake under heavy load: on a Mac with a load average of 50 to 90, two full runs ended with "Hidden Bar (pid) encountered an error (The test runner exited with code 0 before establishing connection)" for seven extra runners (every test that ran passed). The app's single-instance guard makes extra parallel host clones quit. The same command passed on the next try, and the unchanged develop passed 4 of 4 here. Not caused by this change; CI has no such load.
Negative control
origin/develop, new production files moved aside (scripts/test.sh --scheme direct): exit 1,BUILD FAILED(Build input files cannot be foundfor the new files in the project). Nothing the new tests cover exists on develop..prefsChangedHotKeyRegistryTests.test_changedShortcutReplacesTheOldBinding,test_clearedShortcutIsUnbound,test_prefsChangedBindsAShortcutSetLater;ShortcutRecorderRowTests.test_typedCombinationIsStoredAndGoesLiveGlobalKeybindPreferencesTests.test_isAcceptableNeedsAModifierOrAFunctionKey;ShortcutRecorderRowTests.test_bareLetterIsRefusedShortcutRecorderRowTests.test_clashWithAnotherShortcutShowsAWarningSettingsWindowTests.test_shortcutRecorder_readsAndClearsGlobalKey;ShortcutRecorderRowTests.test_clearRemovesTheStoredShortcutMenuBarCatalogStateTests.test_firstRunSeedsEveryAppWithoutArrivals;MenuBarItemCatalogTests.test_firstReadListsEveryAppAndAnnouncesNone,test_upgradeDoesNotAnnounceExistingApps,test_launchesAndQuitsUpdateIsRunning,test_pinnedTableFeedsSectionsAndEditsfirstSeenMenuBarItemCatalogTests.test_firstSeenIsPersistedAcrossLaunchesUnrestrictedReadHookTests.testACollapseReadReachesTheHook,testAHeldRestrictionReportsNoReadMenuBarCatalogStateTests.test_systemExtrasAreLeftOut;MenuBarItemCatalogTests.test_systemExtrasAreNotListedEach mutant was restored with
git checkout -- <file>; the working tree was clean afterwards.Snapshots
Debug-Direct binary run with
-settingsSnapshotDir, 26 PNGs (13 states, light and dark), compared pixel by pixel with a build oforigin/develop:direct-about,direct-advanced,direct-appearance,direct-menubarapps-empty,direct-menubarapps-off(light and dark each).direct-general-<light|dark>: 1931 / 1923 pixels differ, all inside x 343-932, y 316-418, the menu-bar preview strip (its live clock "Mon 01:33" against "01:38"); the Keyboard shortcut row (y about 780) is pixel-identical, the layout is the same.direct-status-*(four states),direct-preview-macos26/27-alwayshidden.direct-menubarapps-ondiffers in 9 (dark) and 1214 (light) pixels in a small box at the left of the first rows (x 64-99, where the app icons sit); this change does not touch that pane.No Screen Recording, Input Monitoring or new entitlement; the app was not launched live and no key or pointer input was sent.