Skip to content

fix(desktop): clean up lingering menu popup windows#7593

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
aryaminus:fix/desktop-menu-popup-cleanup
Jun 3, 2026
Merged

fix(desktop): clean up lingering menu popup windows#7593
kodjima33 merged 2 commits into
BasedHardware:mainfrom
aryaminus:fix/desktop-menu-popup-cleanup

Conversation

@aryaminus
Copy link
Copy Markdown
Contributor

@aryaminus aryaminus commented Jun 2, 2026

Summary

  • Add an NSMenuDelegate.menuDidClose(_:) cleanup pass for status-bar menu popup windows
  • After the menu closes, order out any visible macOS menu popup windows titled Item-*
  • Fix transparent menu windows that can remain above other apps and block clicks on external displays

Closes #7516

Why

Issue #7516 reports a transparent Omi-owned popup-layer window left behind after dismissing the macOS status-bar menu on an external display. The window is invisible but still intercepts clicks in a rectangular area under the menu-bar icon.

Omi already filters these menu popup windows in revealMainWindowIfAvailable() by checking window.title.hasPrefix("Item-"), but there was no matching close-time cleanup.

Implementation details

  • Implements menuDidClose(_:) in the existing AppDelegate: NSMenuDelegate
  • Waits 0.1s before cleanup so AppKit has a chance to remove its own menu window first
  • Targets only visible NSApp.windows whose title starts with Item-
  • Uses orderOut(nil) instead of closing unrelated app windows

The fix is intentionally narrow: it only touches AppKit menu popup windows created for the status-bar menu and leaves the main app, floating bar, and agent windows alone.

Verification

  • xcrun swift build -c debug --package-path Desktop

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 2, 2026

Greptile Summary

This PR adds an NSMenuDelegate.menuDidClose implementation to AppDelegate that, 100 ms after the status-bar menu closes, scans all NSApp.windows and calls orderOut(nil) on any visible window whose title starts with \"Item-\" — matching macOS's internal popup-menu window naming — to fix transparent orphan windows that block clicks on external displays.

  • The cleanup correctly dispatches on the main queue and only acts on visible windows, and the delegate is wired only to the status-bar menu, so cross-menu interference is not a concern in the current codebase.
  • The \"Item-\" prefix is an undocumented AppKit internal convention; a naming change in a future macOS release would silently break the fix, and the broad NSApp.windows scan could cause unintended dismissals if any other window is ever named with that prefix.

Confidence Score: 4/5

The change is a targeted, isolated workaround for a known macOS rendering bug; it touches only one new delegate method and has no effect on the rest of the app's lifecycle.

The fix works correctly for its stated purpose today, but it relies on an undocumented AppKit window-title prefix and scans all process windows without scoping to the status-bar menu — both are fragile points that could silently break or cause unintended side effects in future macOS versions or if the codebase grows.

desktop/Desktop/Sources/OmiApp.swift — specifically the menuDidClose implementation and its window-title matching logic.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/OmiApp.swift Adds NSMenuDelegate menuDidClose to dismiss orphaned "Item-" popup windows after status-bar menu closes; relies on an undocumented AppKit window-title prefix and broadly scopes the search to all app windows.

Sequence Diagram

sequenceDiagram
    participant User
    participant StatusBarMenu as NSMenu (status bar)
    participant AppDelegate as AppDelegate (NSMenuDelegate)
    participant MainQueue as DispatchQueue.main
    participant AppWindows as NSApp.windows

    User->>StatusBarMenu: Clicks away / dismisses menu
    StatusBarMenu->>AppDelegate: menuDidClose(_:)
    AppDelegate->>MainQueue: asyncAfter(deadline: .now() + 0.1)
    Note over MainQueue: 100 ms delay
    MainQueue->>AppWindows: Iterate all windows
    loop For each window
        AppWindows-->>MainQueue: window
        alt "title.hasPrefix(Item-) && isVisible"
            MainQueue->>AppWindows: window.orderOut(nil)
            Note over AppWindows: Lingering popup dismissed
        end
    end
Loading

Reviews (1): Last reviewed commit: "fix(desktop): clean up lingering menu po..." | Re-trigger Greptile

Comment thread desktop/Desktop/Sources/OmiApp.swift Outdated
Comment thread desktop/Desktop/Sources/OmiApp.swift
@aryaminus
Copy link
Copy Markdown
Contributor Author

Addressed Greptile's menu cleanup comments in follow-up commit cac1ecc8f:\n\n- added isMenuPopupWindow(_:) so cleanup requires both the Item-* title prefix and an AppKit popup-menu class name\n- documented that these are private AppKit menu popup window conventions\n- cleanup now avoids dismissing arbitrary app windows that happen to start with Item-

@aryaminus aryaminus force-pushed the fix/desktop-menu-popup-cleanup branch from cac1ecc to 681b8dd Compare June 2, 2026 22:26
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown
Collaborator

@kodjima33 kodjima33 left a comment

Choose a reason for hiding this comment

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

Owner-override merge: desktop bug fix (menu popup cleanup), small surgical Swift change, no abuse signals

@kodjima33 kodjima33 merged commit 434874a into BasedHardware:main Jun 3, 2026
1 check 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.

Invisible Omi menu-bar window blocks clicks on external display

2 participants