Skip to content

fix: close window hides to tray instead of exiting & settings opens independently#5

Merged
Finesssee merged 2 commits intoFinesssee:mainfrom
junlin-233:main
Mar 1, 2026
Merged

fix: close window hides to tray instead of exiting & settings opens independently#5
Finesssee merged 2 commits intoFinesssee:mainfrom
junlin-233:main

Conversation

@junlin-233
Copy link
Copy Markdown

Hi there!
First off, thanks for building CodexBar — it's a really nice tool and I've been enjoying using it on Windows. While using the tray app I ran into a couple of UX issues, so I took a stab at fixing them. Hope this is helpful.
What this PR fixes
1. Closing a window used to kill the entire app
As a tray application, I'd expect closing the window to just hide it — not exit. Now it hides to tray and keeps running, which feels much more natural.
2. "Settings" in tray menu was also showing the main window
Clicking "Settings" would pop up both the settings window and the main usage window. Now it only opens the settings window as expected.
What changed
All changes are in rust/src/native_ui/app.rs (1 file, +33 −7):

  • Close intercept: Catches the close_requested event → cancels the close → hides window with Visible(false). The app stays alive in the tray.
  • New show_main_window_no_focus() helper: Uses Win32 ShowWindow(SW_SHOWNOACTIVATE) to wake the egui event loop without stealing focus from the settings window.
  • Tray menu action split:
    • Open / Refreshrestore_main_window() (brings main window to front)
    • Settingsshow_main_window_no_focus() + moves main window off-screen, then opens only the preferences viewport
      Known issue (not fixed here)
      Worth flagging: Quit from the tray menu doesn't work when all windows are hidden. This is because TrayMenuAction::Quit → std::process::exit(0) is handled inside the egui update() loop — when windows are hidden, the loop pauses so tray events don't get processed. The user has to open a window first, then quit.
      A possible fix would be handling Quit directly in the tray callback thread before sending to the egui channel, or calling std::process::exit(0) in the tray event closure itself.
      Let me know if there's anything you'd like me to change. Thanks for reviewing!

@Finesssee Finesssee merged commit ef38cd1 into Finesssee:main Mar 1, 2026
@Finesssee
Copy link
Copy Markdown
Owner

Thanks for the PR! Hide-to-tray on close and independent settings window are solid UX improvements for a tray app. Merged.

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