Skip to content

fix(native): keep always-hidden apps when the separator is misread - #599

Merged
tieubao merged 12 commits into
developfrom
fix/always-hidden-boundary
Nov 25, 2026
Merged

tieubao merged 12 commits into
developfrom
fix/always-hidden-boundary

Conversation

@tieubao

@tieubao tieubao commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Refs #593 (not "Fixes": the cause of the wrong separator frame is not proven, see below).

With pinned sections on and the always-hidden section on, withLayout took the always-hidden boundary from the separator item's frame with no check, as #591 did for the arrow. A frame with nothing left of it makes every always-hidden app read as hidden (MenuBarLayoutResolver.section), and PinnedSectionResolver.resolve counts that as a drag, so the table is rewritten from Always hidden to Hidden. A later good read counts as a drag back. The reporter's log matches: arrow placed, always hidden [] with every app under hidden, no pinned sections changed line.

Proven by code, the log signature and the tests: a bad frame produces the flip. Not proven: why AppKit reports a bad frame. The log never printed it, and the wrong state lasted four reads over two minutes, so it is not a one-off transient. Two engine paths do read the bar with the separator out of it, where its frame means nothing: a collapse during a clock lift (the restriction is released, and collapse skips setSeparatorsVisible(true) while the section is hidden), and a collapse whose activation fails (the restriction is released, the state returns to expanded, the separator stays out). Whether the reporter hit either is unknown. A plausible but wrong frame would still pass the check, which is why every read now logs the frame.

Change:

  • The separator frame counts as a boundary only when the item is in the bar, the frame is on the arrow's display, placed like the arrow, and on the hidden side of the arrow. "In the bar" is the engine's own record (setSeparatorsVisible sets it); the real isVisible and length are logged beside it.
  • Otherwise the read has no always-hidden boundary, apps last read always hidden keep that section, and a move across the arrow still counts. It does not return a nil layout (as fix(native): do not read sections from an arrow macOS has not placed #591 does), so a persistent misread cannot keep the bar from collapsing.
  • Every read with the section on ends its arrow at x= line with the verdict (trusted or NOT trusted: <reason>), the separator frame, the item state, the arrow frame and whether the read was incomplete.
  • Not covered: the launch collapse does not wait for the separator as it does for the arrow, so a first launch with nothing remembered reads as before and the next good read corrects it (tested).

Files: NativeVisibilityEngine.swift, MenuBarLayout.swift, MenuBarEngineTests.swift, an implementation note and docs/verification/always-hidden-boundary/results.md. No file overlap with the unmerged fix/unplaced-arrow-frame (it differs from develop only under docs/verification/) or open PR #594.

How it was tested

CI on GitHub's runners, both schemes (run links and failing test names in results.md):

  • First head 6d35cd8 (45526581286): 5 existing tests failed. The fix read NSStatusItem.isVisible, which the tests' fake items do not report as visible, so a fresh read distrusted a good frame. Fixed at the cause: the engine now records when it takes the separator out; the getter is only logged.
  • Fix at 8557e6f (45529170913): Direct 843 passed, 0 failed; App Store 537 passed, 0 failed. 12 tests in AlwaysHiddenBoundaryTests, including a separator out of the bar, a drag during a misread, a first launch with nothing remembered, and a separator on another display.
  • Negative control (45529950255): same tests with the distrust handling switched off, the engine as develop's: 5 of the new tests fail, in both schemes. That commit is reverted.
  • 7432add (45531126369), develop merged: Direct 849, App Store 539 passed, 0 failed.
  • 7bdc8ca (45531871858): adds the case where the controller has removed the separator item (section turned off) before the engine hears of it; with no item the read is a normal disabled-section read, not a distrusted one, so remembered always-hidden apps return to the hidden section. 12 tests in AlwaysHiddenBoundaryTests. Direct 850 passed, 0 failed; App Store 540 passed, 0 failed. Later commits are docs only.

VM gate (guest on macOS 27.2.1, head 7432add)

Evidence: gate-pr599-2721-2026-11-25 on the maintainer test host; two frames and the full record are in docs/verification/always-hidden-boundary/results.md. Verdict: guarded, no regression. Not fixed. Release builds have no Debug hooks, so a misread could not be forced.

  1. 14 trusted lines and 0 NOT trusted lines on the guard build, all from launch reads.
  2. Ten arrow cycles kept the app in always hidden on both builds; the control showed no misread either, so the run cannot tell the guard from the old build by behavior.
  3. Plain arrow clicks log no arrow at x= line (expand keeps the restriction), and Option-click could not be delivered, so the guard ran only at launch.
  4. No drag across the always-hidden separator was tested; a drag across the arrow worked.
  5. Open observation: an iStat Menus table value moved twice at launch reads marked trusted, with no pinned sections changed line. iStat is the app macOS hides; the control had it at a different start value. Not a result.
  6. The gate build was 7432add, one commit before the nil-item change (7bdc8ca), which CI covers.

UI proof

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

No new text or view. Always-hidden apps stay hidden when the separator is misread, instead of showing on the next click.

The always-hidden boundary came from the separator item's frame with no check. A frame with nothing left of it read every always-hidden app as hidden, and with pinned sections that counted as a drag. The frame now counts only when the item is in the bar, on a display, placed like the arrow and on the hidden side of it; otherwise apps last read always hidden keep that section, and the log says why.

Refs #593
The separator-in-bar input read NSStatusItem.isVisible, which the engine tests' fake items do not report as visible, so a fresh read distrusted a good frame and five existing tests failed. The engine now records when its own setSeparatorsVisible took the item out, which is the state it needs, and logs the item's real isVisible and length beside it. A separator on another display than the arrow is not a boundary. Every read with the section on logs the separator frame, the arrow frame and the verdict.

Refs #593
Skips the distrust handling so the engine behaves as develop's; the new tests must fail.
@tieubao
tieubao marked this pull request as ready for review November 25, 2026 03:14
@tieubao
tieubao merged commit 7023354 into develop Nov 25, 2026
4 of 6 checks passed
@tieubao
tieubao deleted the fix/always-hidden-boundary branch November 25, 2026 06: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