Skip to content

fix(native): keep apps and ⌘-drags with the menu bar set to auto-hide - #607

Open
DragonNameLeo wants to merge 2 commits into
consolelabs:developfrom
DragonNameLeo:fix/autohide-menubar-read
Open

DragonNameLeo wants to merge 2 commits into
consolelabs:developfrom
DragonNameLeo:fix/autohide-menubar-read

Conversation

@DragonNameLeo

Copy link
Copy Markdown

What and why

With System Settings › Menu Bar › "Automatically hide and show the menu bar" on, macOS 27.2.1 parks every app's status items while the bar is hidden. They leave Accessibility, and Hidden Bar's own arrow goes with them. Two things broke because of this:

  1. Every app was lost (d4f6173). Hidden Bar sometimes read the bar while it was hidden: on the auto-collapse timer, at a launch, or at a relaunch before the icons were back. That read listed no app. It was cached, and every app fell out of the allow list. With the always-hidden section held on expand, no later read replaced it, so a click on the arrow showed nothing until Hidden Bar was relaunched.
    • The inventory now also checks whether Hidden Bar's own status items are in Accessibility. If they are not, and no app item was read, the read came from a hidden menu bar.
    • Such a read is not used. The last good read stays, and nothing is learned from it: no pinned-table edit, no section-memory edit, no catalog record, and it is not stored as lastCompleteLayout.
    • A running app that the read left out keeps the section Hidden Bar already knows for it (from the pinned table, or from section memory when pinned sections are off).
  2. A ⌘-drag never changed an app's section (e0d6453). With pinned sections on and the always-hidden section held on expand, a collapse used the cached read, so it never saw the drag.
    • CommandDragWatcher reports the end of a ⌘-drag in the menu bar, 0.5 s after mouse-up. By then macOS has moved the icon and the bar is on screen.
    • NativeVisibilityEngine.menuBarRearranged reads the bar then. When a restriction is held, it reads only the apps that restriction shows. The table is edited through PinnedSectionResolver, so "Ignore drags" is respected.

How it was tested

  • Tested on macOS 27.2.1 with the menu bar set to auto-hide.
    • A read taken while the bar was hidden logged own items listed false, menu bar hidden true, and the 8 hidden and 3 always-hidden apps stayed in their sections. The arrow showed the hidden icons afterwards.
    • Three ⌘-drags of an app across the arrow each logged a ⌘-drag moved … to hidden / visible / hidden, and the pinned table followed every drag.
  • New tests: ReadListsNoAppTests (6) and PinnedSectionsTests (4).
  • scripts/test.sh --scheme direct: 826 passed, 34 failed. The same 34 fail on develop without this change. They are UI text tests, and they fail because the test Mac is set to Japanese.

UI proof

Tick exactly one:

  • This PR changes something users see, and the proof is above
  • This PR changes nothing users see

🤖 Generated with Claude Code

DragonNameLeo and others added 2 commits November 26, 2026 12:08
With System Settings › Menu Bar › "Automatically hide and show the menu bar"
on, macOS 27.2.1 parks every app's status items while the bar is hidden, and
they leave Accessibility, Hidden Bar's own arrow included. A read taken then
(the auto-collapse timer, a launch, or a relaunch before the icons are back)
listed no app. It was cached, every app fell out of the allow list, and with
the always-hidden section held on expand no later read replaced it: a click on
the arrow showed nothing until Hidden Bar was relaunched.

Measured on a live bar: every read that listed no app happened while
MenuBarAgent logged "menu bar hidden", and every read taken while the bar
was revealed listed the apps.

- The inventory also asks whether Hidden Bar's own status items are in
  Accessibility. When they are not and no app item was read, the read is
  from a hidden menu bar (MenuBarHiddenRead). An unanswered own read never
  counts as hidden.
- The engine keeps the last read instead of such a read and learns nothing
  from it: no pinned-table or section-memory edit, no catalog record, and
  it does not become lastCompleteLayout.
- A running app the read did not list, but whose section Hidden Bar knows
  (pinned table, or section memory with pinned sections off), keeps that
  section. Apps not running, and apps never seen, are not filled in.

Verified on 27.2.1 with the menu bar set to auto-hide: a read with the bar
hidden logs "own items listed false, menu bar hidden true" and keeps 8 hidden
and 3 always-hidden apps from the table; a read with the bar revealed logs
"own items listed true, menu bar hidden false". The arrow shows the hidden
icons afterwards.

Tests: ReadListsNoAppTests (6). The direct scheme passes 822, fails 34; the
same 34 fail without this change (UI copy tests on a Japanese-language Mac).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With pinned sections on and an app in the always-hidden section, an expand
keeps a restriction that hides that section, so the next collapse uses the
cached read and never sees where the user dragged an icon. Only a bar with
nothing held (Option-click, or the camera or microphone lift) was read again,
and with the menu bar set to auto-hide even that read came when the
auto-collapse found the bar already gone, so it was discarded. A ⌘-drag
across the arrow therefore never changed an app's section.

- CommandDragWatcher (MenuBarClock.swift) watches left mouse-down with ⌘ in
  a menu bar, global and local, and reports the next mouse-up after 0.5 s,
  once macOS has moved the icon and reflowed the bar. The bar is on screen
  then, auto-hide or not.
- NativeVisibilityEngine.menuBarRearranged, pinned sections only:
  - nothing held and expanded: a full read, cached, so a collapse that finds
    the menu bar hidden keeps it;
  - a restriction held (collapsed, or expanded with the always-hidden
    section hidden): only the apps it shows are read, against the arrow,
    since hidden apps report stale frames. An app the palette lifted for now
    is left out. The table is edited through PinnedSectionResolver as on a
    collapse, so "Ignore drags" and relaunches are respected, and the hold
    follows at once.
  - Skipped while presenting, while an activation is in flight, and when the
    read finds the menu bar hidden.
- The engine posts .pinnedSectionsChanged so Settings › Icons and the catalog
  follow; the controller skips the engine's own post.

Verified on 27.2.1 with the menu bar set to auto-hide and the always-hidden
section held on expand: three ⌘-drags of WeChat across the arrow logged
"a ⌘-drag moved com.tencent.xinWeChat to hidden / visible / hidden", each
from a read with "menu bar hidden false", and the pinned table followed.

Tests: PinnedSectionsTests (4 new). The direct scheme passes 826, fails 34;
the same 34 UI copy tests fail on this Japanese-language Mac without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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