Skip to content

[codex] Recover status item after display changes#998

Closed
Llldmiao wants to merge 1 commit into
steipete:mainfrom
Llldmiao:codexbar-recover-status-item-after-display-change
Closed

[codex] Recover status item after display changes#998
Llldmiao wants to merge 1 commit into
steipete:mainfrom
Llldmiao:codexbar-recover-status-item-after-display-change

Conversation

@Llldmiao
Copy link
Copy Markdown
Contributor

@Llldmiao Llldmiao commented May 16, 2026

Fixes #997.

Summary

  • Detect status items whose backing window is attached to a detached/non-current screen.
  • Observe NSApplication.didChangeScreenParametersNotification and debounce display-change recovery.
  • Recreate status items when a display is removed while a visible item exists, or when a visible item snapshot is blocked.
  • Add focused coverage for detached-screen snapshots and display-removal recovery decisions.

Root Cause

The startup recovery added in a75d276f catches status items that fail to materialize shortly after launch, but CodexBar did not observe runtime display topology changes. If the external display hosting the NSStatusItem is unplugged, AppKit can leave the app process alive while the status item is still associated with a removed screen/menu bar.

Validation

  • git diff --check passes.
  • swift test --filter MenuBarVisibilityWatcherTests passes with Xcode 26.5 / Apple Swift 6.3.2.

Notes

This PR intentionally targets the runtime hot-unplug case. It is complementary to the startup recovery in #988, the Tahoe allow-list guidance in #945, and the earlier macOS 26.4 visibility fix in #849.

@steipete
Copy link
Copy Markdown
Owner

Thanks for the focused fix. I landed this on main with a small follow-up for the debounce cancellation path so stale display-change checks cannot run after a newer notification cancels them.

Landed as fcbd46f.

Verified with:

  • swift test --filter MenuBarVisibilityWatcherTests
  • swift test --filter StatusItemControllerSplitLifecycleTests
  • make check
  • codex-review --mode auto

@steipete steipete closed this May 16, 2026
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.

Menu bar icon does not recover after unplugging the external display that hosts it

2 participants