Skip to content

fix(native): recover hiding on overflowing menu bars and retry auto-collapse - #549

Merged
tieubao merged 6 commits into
consolelabs:developfrom
hongdongjian:codex/fix-overflow-auto-hide
Nov 19, 2026
Merged

tieubao merged 6 commits into
consolelabs:developfrom
hongdongjian:codex/fix-overflow-auto-hide

Conversation

@hongdongjian

@hongdongjian hongdongjian commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

On macOS 27, launching Hidden Bar while the menu bar is already overflowing can leave every collapse attempt unavailable because no complete layout has been cached in that process. A failed auto-collapse also consumes its one-shot timer without scheduling another attempt. This PR allows hiding from the partial read and limits automatic recovery to three requests per expansion, with an explicit off/on toggle starting a fresh allowance.

  • Resolve listed icons as before; fill in omitted running apps from pinned or remembered sections. Unlisted apps inferred only from the running-process list stay visible without becoming icon-catalog arrivals or observed drag positions.
  • Popup-owner detection keeps observed owners and apps reported by launch notifications, so a newly launched app's popup is guarded before its first inventory read. Other unlisted running apps remain excluded.
  • Recognize both closed and expanded system overflow indicators, and retain the fake item provider so first-read regressions exercise the inventory path.
  • Allow at most three automatic requests, including the first. Expansion, a successful hide, or switching auto-hide from disabled to enabled resets the count; other preference refreshes do not. A failed manual request does not start retries, reset the count, or postpone an existing timer. Manual hiding remains available after the limit.
  • Native timeouts use the normal completion and the same limit. Interaction deferrals and waiting for an in-flight request do not consume attempts.
  • Explicitly type the Debug snapshot wallpaper color array to avoid a local Swift type-check timeout, and document the fixes under Unreleased in CHANGELOG.

Validation

  • 69 targeted tests passed, including 13 virtual-clock tests of the real StatusBarController and a real popup-guard/engine integration regression for an app launching before its first read. Coverage includes toggling after exhaustion, re-enabling during a pending request, and unrelated preference changes preserving the cap.
  • Full scripts/test.sh --serial run after merging develop e36ea8e (including fix(log): readable auto-hide and hide-failure lines in Console #554): Direct 743 passed, 3 failed; App Store 491 passed, 0 failed. Both schemes build.
  • The three Direct failures are the same localization and Menu Bar Apps row-height assertions previously reproduced on base f76070b (with only the Debug snapshot type annotation required to compile locally). No test expectations were relaxed.
  • Earlier macOS 27.2.1 smoke verification of the core overflow/retry fix successfully hid eight hidden-section apps and recovered from a forced temporary layout-read failure. The current retry-limit and toggle behavior is covered by the virtual-clock tests above.

@tieubao tieubao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Hiding from a partial read and the menuBarItemOwners intersection both look right, and the second one should also cut false holds in the popup guard.

One ask before merge, on the re-arm in didFailToCollapseMenuBar:

  • autoCollapseIfNeeded() now runs after every failed collapse, so a collapse that keeps failing retries at the user's interval with no limit (every 5 s at the shortest setting).
  • Failures that exit early are cheap, but any failure after the read runs an Accessibility snapshot on each retry.
  • A failed collapse from the user's own click now starts the auto timer too. Is that intended?

Could you cap it, for example 3 attempts per expansion with a reset on the next expand or on success, or back off between attempts? A test for the cap next to the new regression tests would be enough.

hongdongjian added 2 commits November 18, 2026 23:13
@hongdongjian

Copy link
Copy Markdown
Contributor Author

@tieubao Thanks for catching this. Starting a new retry sequence after a failed manual click was not intentional; the previous re-arm was too broad.

Addressed in 27d6fed, and merged the latest develop changes in 9717867.

  • Each expansion now permits three automatic hide requests in total, including the first. Expansion or a successful hide resets the counter.
  • Failed manual requests do not arm retries, replenish the budget, or postpone an already scheduled automatic request. Manual hiding remains available after the automatic limit is exhausted.
  • Removed the separate onCollapseTimedOut re-arm. Native timeouts report .unavailable through the same completion path, so they cannot bypass the cap.
  • Interaction deferrals and waiting for an in-flight request do not consume attempts.

Added 11 tests against the real StatusBarController with a virtual clock, covering those cases and disabling auto-hide during a pending request. All passed; the targeted controller/native-timeout run passed 51 tests.

After syncing with develop, the full local run reports Direct: 723 passed, 3 failed; App Store: 473 passed, 0 failed. The three Direct failures are the same previously baseline-reproduced localization/row-height assertions documented in the PR description; there are no new failures.

@tieubao tieubao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix. The cap does what I asked: three automatic requests per expansion, manual clicks still work after the cap, and timeouts share the same budget. The tests cover it well.

Please merge develop once more. #554 landed after your last merge and there is one conflict, in StatusBarController.swift in startTimerToAutoHide. Keep your shouldDefer wrapper and use develop's call, holdsCollapse("AutoCollapse: holding for the pointer in the menu bar", if:). I merged it locally that way: both schemes build, and the 473 tests of the direct scheme pass, your 11 retry tests included.

Two small things, neither blocking:

  1. menuBarItemOwners now needs section memory, so a popup from an app that just launched is not guarded until the next read. Could you keep launched apps in the set?
  2. Please add a CHANGELOG line under ## Unreleased.

Optional: reset the retry budget when auto-hide is switched off and on.

hongdongjian added 2 commits November 19, 2026 14:32
@hongdongjian

Copy link
Copy Markdown
Contributor Author

@tieubao Thanks, all follow-ups are addressed in 7011109.

  • Merged develop through e36ea8e (including fix(log): readable auto-hide and hide-failure lines in Console #554) in a99d826. The conflict keeps the shouldDefer wrapper and uses develop's holdsCollapse call as suggested.
  • menuBarItemOwners now also includes launchedSinceRead. Unlisted apps inferred only from the initial running-process list still do not become popup owners. A new integration regression checks that a newly launched app's popup holds auto-hide before any inventory read, and that termination releases the pending owner.
  • Added a CHANGELOG entry under ## Unreleased.
  • Included the optional reset: only switching auto-hide from disabled to enabled replenishes the three-request allowance. Other preference refreshes do not reset it. New regressions cover exhaustion followed by off/on, re-enabling while an old request is pending, and changing the interval without replenishing attempts.

Validation: 69 targeted tests passed, including all 13 controller retry tests. Both schemes build; the full local run reports Direct: 743 passed, 3 failed; App Store: 491 passed, 0 failed. The three Direct failures are the same previously baseline-reproduced localization/row-height assertions documented in the PR; there are no new failures.

@tieubao tieubao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful follow-up. All three asks are in, CI is green, and it merges cleanly into the current develop. I ran the full direct-scheme suite on the merged tree in our macOS 27.2.1 VM: 750 passed, none failed. Merging.

@tieubao
tieubao merged commit 8ccdfc9 into consolelabs:develop Nov 19, 2026
3 checks passed
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.

2 participants