Skip to content

Fix macOS 27 menu-bar hiding across displays - #400

Closed
quaversgoose wants to merge 13 commits into
consolelabs:developfrom
quaversgoose:fix/macos27-calibrated-collapse
Closed

quaversgoose wants to merge 13 commits into
consolelabs:developfrom
quaversgoose:fix/macos27-calibrated-collapse

Conversation

@quaversgoose

@quaversgoose quaversgoose commented Sep 16, 2026 •

Copy link
Copy Markdown

Fixes #360.

macOS 27 rejects the old over-wide NSStatusItem separator and a single replacement width cannot behave correctly on mixed-size displays. This adds a macOS 27-only runtime policy backend using MenuBarClientCore assessment mode: it hides third-party menu-bar bundles directly, keeps system controls visible, and therefore does not allocate a fake menu-bar span. macOS 26 and earlier retain the existing implementation; the current status-item approach remains as a fallback if the runtime policy is unavailable.

Tested locally on macOS 27 with a 3456-point built-in display and a 2560-point Thunderbolt display: collapse, expand, repeated toggle, Control Centre/battery visibility, and no spacer gap or native overflow chevron.

Note: the macOS 27 backend uses an undocumented runtime interface and is unsuitable for App Store distribution.

Acknowledgement: FoldBar's public documentation identified the assessment-mode direction. This runtime bridge was implemented independently; no FoldBar source is included.

…lelabs#360)

Hiding inflated the separator to 2x the screen width and relied on the menu bar
reflowing around it. macOS 27 does not: an over-long status item is ejected from
the layout instead of laid out, and an ejected item pushes nothing, so collapsing
silently did nothing. Measured on 27.0 (26A428), 1800pt notched display: 300pt
and 600pt hide the whole hidden section into the OS overflow chevron, while 1000pt
and the app's own 3600pt request are ejected and hide nothing.

The cutoff is where the separator would grow past the left edge of the status
region, so it varies with the display and with how full the bar is, and cannot be
a constant. Calibrate it instead: binary search the largest length this OS/display
actually lays out, cached until the display configuration changes.

Ejection is detectable without private API. The separator sits beside the arrow,
so while laid out it can only grow away from it, pinning the edge nearest the
arrow; an ejected item's frame runs straight past the arrow and that edge jumps by
roughly the requested length. The window ORIGIN is NOT usable here: it moves in
both cases, which reads ejected items as laid out (measured, then corrected).

Verified end to end on 27.0 by compiling this controller against the real menu bar
with four icons in the hidden section: calibration settles on 629pt, collapse
hides all four, expand restores them, and a second collapse reuses the cached
length. macOS <= 26 is untouched, gated on the major version, since the pinned-edge
signal is unverified there.

Replaces the diagnostic-only instrument from 8fc6ac5, which could not distinguish
the two states, and supersedes the three review bugs the degrade path carried.
@alexkrz

alexkrz commented Sep 16, 2026

Copy link
Copy Markdown

It is working for me on macOS 27 with the Macbook screen, but it is not working correctly with a second external monitor

quaversgoose and others added 2 commits September 17, 2026 10:21
macOS 27 discards a status item whose length reaches half the display
width instead of clamping it, and the menu bar is now one window with a
native overflow. Inflating the separator to twice the widest screen
dropped the item outright, so nothing hid.

Size each collapse unit just under half the narrowest attached display,
and add spacer items between the separator and the arrow so the total
span still covers wide and mixed-width setups. Displaced icons go into
the system overflow menu. Suppress the separator glyph while collapsed
because that span is now on-screen. Retry the launch collapse until
item frames exist in the shared menu-bar window.

Verified on macOS 27.0 (26A428): collapse hides icons left of the
separator; expand restores them.

(cherry picked from commit d48c697)
m-samoylov added a commit to m-samoylov/hidden that referenced this pull request Sep 17, 2026
macOS27CollapseLength() derives the collapse length from the half-a-display
cliff measured in 8ac0828, but that cliff has only ever been measured on two
display widths. A formula that overshoots it on some other display fails the
way consolelabs#360 failed: the separator is ejected from the layout, displaces nothing,
and reports the full length it was given, so nothing in the app notices.

The first collapse on each display configuration now proves the length with a
canary -- a one-point transparent status item registered last, which lands
among the icons the collapse has to clear. If it does not travel, the request
drops by a quarter and the collapse is retried, up to six times. The canary is
removed as soon as the answer is in, so it is never in the bar while idle, and
a proven length is reused until the display configuration changes.

Two measurements shaped this, both on 27.0 build 26A428, 1728pt display, with
foreign status items as ground truth:

  - Travel is the signal, not position. A clamped separator grows out past the
    arrow, so its arrow-facing edge starts moving at 600pt on a bar that still
    hides correctly at 840pt; the real cliff is between 840 and 900. The
    edge-jump test proposed in PR consolelabs#400 therefore reads a working bar as broken,
    and wired up as published it drove the length from 824pt down to 140pt,
    which hides nothing. Position of the canary is no better: when the
    separator clamps, a live slot and a parked one rest within a few points of
    each other.
  - The canary must seat before the separator grows. A freshly registered item
    yields to the separator's claimed span whether or not that span is honored.
    At 0.35s the canary travelled on a 964pt request that hid nothing; at 1.0s
    and 2.0s it stayed put and the retry correctly settled on 723pt.

Verified on that machine, with the real bar as ground truth: the honest formula
is proven at 824pt on the first attempt and the icons leave the bar; a formula
forced 100pt over the cliff is rejected and 723pt proven in its place. macOS 26
and earlier never run any of this.

Credit to PR consolelabs#400 (@quaversgoose) for the idea of measuring rather than
trusting a constant.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
quaversgoose and others added 7 commits September 17, 2026 16:08
macOS 27 rebuilt the menu bar and broke length-inflation hiding in two
independent ways. Both are fixed behind `#available(macOS 27.0, *)`;
macOS 26 and earlier keep the original code path untouched.

1. An over-wide item is dropped. macOS 27 discards a status item whose
   backing window (length plus 16pt of chrome) reaches half the display
   width, where earlier versions clamped it. The pre-27 length of twice
   the widest screen is over that limit on every Mac, so the separator was
   ejected from the layout and displaced nothing. The collapse length now
   derives from the narrowest attached screen -- the inverse of the pre-27
   rule, because one length applies on every display's bar while the limit
   is per display.

2. A seated neighbour is never evicted. Assigning the collapsed length in
   one jump leaves every other icon exactly where it was, so only the first
   collapse after launch appeared to work: icons registered while already
   collapsed were placed out of the bar, but re-collapsing after an expand
   did nothing. Growth now ramps in 40pt steps, which does carry the
   neighbours along. Shrinking needs no ramp on any macOS.

Nothing in-process can observe either failure -- the item keeps reporting
whatever length it was given -- which is why the diagnostic instrument added
in 8fc6ac5 logged "honored" in the broken case. It is removed here: the fix
stays under the limit by construction rather than trying to detect the drop.

Measured on macOS 27.0 build 26A428, 1728pt notched display, by sweeping the
length while reading foreign status items over Accessibility:

  - 848pt hides, 849pt hides nothing (848 + 16 == 864 == 1728 / 2)
  - single-jump growth moved neighbours 0pt; 10pt and 40pt steps moved them
    out of the bar; 100pt steps were already too coarse

The same arithmetic fits the 3008pt-display report in PR consolelabs#392 (honored at
1480pt, dropped at 1500pt).

Verified end to end on that machine with a hit-test sweep of the visible bar:
icons left of the separator leave the bar on collapse, return on expand, and
leave again on a second collapse; repeated toggling and the 10s auto-collapse
timer behave as before.

Not verified on hardware: multi-display and non-notched layouts, and the
always-hidden section (it routes through the same ramped setLength). A wide
single display may need more push than one sub-limit item can deliver; see
docs/BACKLOG.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit 8ac0828)
macOS27CollapseLength() derives the collapse length from the half-a-display
cliff measured in 8ac0828, but that cliff has only ever been measured on two
display widths. A formula that overshoots it on some other display fails the
way consolelabs#360 failed: the separator is ejected from the layout, displaces nothing,
and reports the full length it was given, so nothing in the app notices.

The first collapse on each display configuration now proves the length with a
canary -- a one-point transparent status item registered last, which lands
among the icons the collapse has to clear. If it does not travel, the request
drops by a quarter and the collapse is retried, up to six times. The canary is
removed as soon as the answer is in, so it is never in the bar while idle, and
a proven length is reused until the display configuration changes.

Two measurements shaped this, both on 27.0 build 26A428, 1728pt display, with
foreign status items as ground truth:

  - Travel is the signal, not position. A clamped separator grows out past the
    arrow, so its arrow-facing edge starts moving at 600pt on a bar that still
    hides correctly at 840pt; the real cliff is between 840 and 900. The
    edge-jump test proposed in PR consolelabs#400 therefore reads a working bar as broken,
    and wired up as published it drove the length from 824pt down to 140pt,
    which hides nothing. Position of the canary is no better: when the
    separator clamps, a live slot and a parked one rest within a few points of
    each other.
  - The canary must seat before the separator grows. A freshly registered item
    yields to the separator's claimed span whether or not that span is honored.
    At 0.35s the canary travelled on a 964pt request that hid nothing; at 1.0s
    and 2.0s it stayed put and the retry correctly settled on 723pt.

Verified on that machine, with the real bar as ground truth: the honest formula
is proven at 824pt on the first attempt and the icons leave the bar; a formula
forced 100pt over the cliff is rejected and 723pt proven in its place. macOS 26
and earlier never run any of this.

Credit to PR consolelabs#400 (@quaversgoose) for the idea of measuring rather than
trusting a constant.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit f18ca04)
@quaversgoose quaversgoose changed the title Fix menu-bar hiding on macOS 27 Fix macOS 27 menu-bar hiding across displays Sep 17, 2026
@alexkrz

alexkrz commented Sep 17, 2026 •

Copy link
Copy Markdown

It is working for me on macOS 27 with the Macbook screen, but it is not working correctly with a second external monitor

I applied the latest changes and it looks like its working correctly now

@andrei-chernikov

Copy link
Copy Markdown
image

Lol, always hidden section is buggy. And the repair is buggy overall! Things are being hidden that shouldn't be, and it's actually showing things that ought to be hidden...

@tieubao

tieubao commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Heads-up: the hiding path this PR modifies was refactored and superseded by the native menu-bar engine that landed in #402/#403 and shipped in v1.11.1 (MenuBarEngine / NativeVisibilityEngine, direct build). The StatusBarController changes here conflict with that refactor and can't be merged as-is.

Recommend closing; remaining macOS 27 regressions are tracked in #409–#414 and belong in the new engine's code path, not the old length-based one.

@quaversgoose

Copy link
Copy Markdown
Author

Superseded by #422. This earlier branch changes the retired length-based path; #422 is rebased on current develop and fixes multi-display classification in NativeVisibilityEngine, with fail-open behavior and automated coverage.

@quaversgoose

Copy link
Copy Markdown
Author

Closing in favor of #422, which targets the current native engine.

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.

Osx 27 broken hidden bar

5 participants