Skip to content

fix(native): do not read sections from an arrow macOS has not placed - #591

Merged
tieubao merged 4 commits into
developfrom
fix/unplaced-arrow-frame
Nov 23, 2026
Merged

tieubao merged 4 commits into
developfrom
fix/unplaced-arrow-frame

Conversation

@tieubao

@tieubao tieubao commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What and why

#584 logs show NativeVisibility: arrow at x=16.0 at every launch: AppKit reported the arrow's window at the display's left edge, before macOS placed it on a crowded 27.2.1 bar. The native engine had no placement check:

  • NativeVisibilityEngine did not override isArrangementKnown, so it inherited true (MenuBarEngine.swift:73). The launch collapse (StatusBarController.swift:280) did not wait.
  • withLayout read sections from that frame. Every icon was then right of the arrow (MenuBarLayout.swift:435): nothing hid and "Nothing to hide" showed.
  • The read went into section memory, and with pinned sections into the pinned table. A later good read then counted as a drag, so a pin set in Settings › Icons could be lost.
  • With the always-hidden section hidden, an expanded bar keeps a restriction. withLayout then reuses the cached read (line 443), so that one bad read applied to every collapse of the session. This matches the logs: no arrow at x= lines after launch.

Fix: an arrow frame within its own width of its display's left edge counts as not placed. The log proves only midX 16, and the arrow is variableLength, so the check does not assume a width. withLayout logs one line and returns no layout. The result is a silent .unavailable, with no hold, no memory or pin write, and no notice. isArrangementKnown uses the same check, so the launch collapse retries for up to 4 s, as the legacy engine already does. Not added: an Accessibility fallback for our own item. The inventory skips our own process, so this would need a new read path that I cannot check here.

Refs #584. This is not "Fixes": the code cannot show whether the reporter's later clicks used the cached launch read (fixed here) or got a fresh read with an arrow still unplaced. In that second case this PR only stops the false "Nothing to hide" notice. One log line decides it: the NativeVisibility: arrow at x= line after a click, once launch is over. If there is none, the cached read was the cause. If it says x=16 again, the arrow is never placed.

How it was tested

  • New UnplacedArrowTests (HiddenBarTests/MenuBarEngineTests.swift). Negative control against develop's engine: 4 of 5 behaviour tests fail. These are: no read or notice on an unplaced arrow, the always-hidden session stuck on the launch read, a pin lost after a bad then good read, and the launch wait. The bad-then-good case without the always-hidden section already passes on develop.
  • scripts/test.sh (both schemes) in the mac-ui VM: Hidden Bar 832 passed, 0 failed; Hidden Bar App Store 526 passed, 0 failed.
  • GUI check not attempted: no VM real-click run of this branch yet.

UI proof

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

No new text or view. The bar now stays expanded with no notice, instead of collapsing with nothing hidden and showing "Nothing to hide".

At launch on a crowded macOS 27.2 bar, AppKit reports the arrow's window at
the display's left edge (logged as "arrow at x=16.0"). Every icon then reads
as right of the arrow: the collapse hides nothing and shows "Nothing to hide",
the read is written into section memory and the pinned table, and while the
always-hidden section stays hidden the cached read stands in for every later
collapse of the session.

The native engine now treats an arrow at its display's left edge as not
placed: it reads nothing, holds nothing and remembers nothing (a silent
.unavailable), and reports the arrangement unknown so the launch collapse
waits for placement as the legacy engine already does.
The log proves only midX 16; the arrow is variableLength, so its width is not known to be 32. Tests cover widths 20, 24 and 32.
Real-click gate on macOS 27.2.1 (hb-macos2721) for the branch build at 6938b09. Checks 1 to 5 pass on screen and in the app stderr; check 6 (the not-placed line at launch) did not occur in five launches, so the retry path was not exercised. Notes in results.md.
Check 5 is reported in two halves, the expectation label is fixed, the one-icon limit is stated, and the released 1.13.4 control shows Sound stays visible there too.
@tieubao
tieubao merged commit a2f765d into develop Nov 23, 2026
2 checks passed
@tieubao
tieubao deleted the fix/unplaced-arrow-frame branch November 23, 2026 14:51
@tieubao tieubao mentioned this pull request Nov 24, 2026
1 of 2 tasks
tieubao added a commit that referenced this pull request Nov 24, 2026
Header and open section now say 1.13.4 (build 25). Items that shipped in 1.13.1 to 1.13.4 move to Shipped with their PRs. The 3 merges after the 1.13.4 tag (#588, #590, #591) are listed as merged, not yet released. Closed issues (#456, #386, #361, #469, #327, #107) and the open reports are reconciled against gh.
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