Skip to content

Really close the window to the tray on Linux - #3

Merged
SusieeTheLinuxUser merged 1 commit into
mainfrom
fix/close-to-tray-linux
Oct 29, 2026
Merged

SusieeTheLinuxUser merged 1 commit into
mainfrom
fix/close-to-tray-linux

Conversation

@SusieeTheLinuxUser

@SusieeTheLinuxUser SusieeTheLinuxUser commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

With "Keep running in the tray when closed" on, closing the window only minimized it, so Rig Hub stayed in the taskbar. On Wayland, winit can't hide a window (set_visible is unsupported), so minimizing was the fallback.

On Linux the window is now destroyed on close:

  • The App, its device workers and the tray outlive the window. main() reruns eframe::run_native when the window is reopened, through a small Shell wrapper around a shared App.
  • While the window is closed, the tray menu (battery, liquid temp, DPI) keeps refreshing every second.
  • Tray left-click, "Open Rig Hub", or a second launch opens a fresh window on the same state. Fonts, theme and textures are set up again for the new window.
  • Workers repaint through a swappable workers::Context, so their updates reach whichever window is open.
  • With the setting off, closing quits as before.

Windows and macOS keep minimizing. Their tray needs the event loop running, so destroying the window there would freeze the tray.

Validation

  • cargo clippy --all-targets -- -D warnings: clean
  • cargo test: pass (6 tests)
  • Tested by hand on KDE Plasma 6.8 (Wayland): close removes the window from the taskbar. It reopens from tray click, "Open Rig Hub" and a second launch. Tray "Quit" exits.
  • Not tested on X11, Windows or macOS (CI builds Windows and macOS).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • On Linux, closing the app window now leaves the tray available, and you can reopen the window from the tray.
    • Background updates continue to refresh the currently open window, including after closing and reopening it.

Wayland can't hide a window, so 'close to tray' only minimized it and
Rig Hub stayed in the taskbar. On Linux the window is now destroyed;
the App, workers and tray outlive it, the tray menu keeps refreshing,
and 'Open Rig Hub' opens a fresh window on the same state.
Windows and macOS keep minimizing: their tray needs the event loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T01:16:43.832710Z c42903a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between c814159 and c42903a.

Files selected for processing: 2
  • src/main.rs
  • src/workers.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The app now shares repaint access with workers and the tray. On Linux, it retains the app across window runs and can recreate the window after a tray request. Non-Linux platforms continue to use a single window run and cancel close events when close-to-tray is enabled.

Changes: Tray window lifecycle

Layer / File(s) Summary
Shared repaint context
src/workers.rs, src/main.rs
A cloneable workers::Context stores an egui context and requests repaints through it. App setup passes the shared context to workers and the tray.
Linux tray and window lifecycle
src/main.rs
Linux attaches the retained app to each new egui context. It waits for a tray request after the window run ends, then can start another run. Non-Linux close-to-tray handling remains in the app logic.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant MainLoop
  participant Eframe
  participant Shell
  participant App
  participant Tray
  MainLoop->>App: Attach to the new egui context
  MainLoop->>Eframe: Start window run
  Eframe->>Shell: Delegate app logic and UI
  Shell->>App: Run app logic and UI
  Eframe-->>MainLoop: Return when the window closes
  MainLoop->>App: Wait in tray when close-to-tray is enabled
  App->>Tray: Refresh status and wait for a show request
  Tray-->>App: Deliver show request
  MainLoop->>Eframe: Start a new window run
Loading
Merge Risk: Minimal · up to c4290

The Linux close-to-tray and reopen paths show no identified merge-blocking defect. Normal platform checks can proceed.

Security architecture risk: Low · up to c4290

The change remains within the desktop application and preserves the existing device-control authority. No introduced security violation was established. The main remaining uncertainty is platform-specific behavior when closing, reopening, or failing to recreate the window.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated affected scope is the running desktop application and the local peripherals its existing workers control. The new window lifecycle does not itself grant additional device authority or provide activation clients with a device-command interface.

Security Findings and Attack Paths

  • inferred — No introduced sensitive-command path was established from the inspected activation source: socket connections request Show only. Tray menu identifiers separately select opening the window, opening the existing bug-report URL, or quitting; the socket does not supply those identifiers.

Trust Boundaries and Controls

  • observed — The Unix activation socket retains its existing runtime-directory location with a temporary-directory fallback. The inspected listener does not check peer identity before producing Show. That behavior predates this PR, and activation already remained available while the previous close-to-tray implementation kept the application minimized.

Resilience and Maintainability Implications

  • inferred — Repaint rebinding is separate from authoritative device state and command ownership. A repaint racing window replacement may miss the departing renderer, but replacement does not reset shared device state or replay queued device commands through a new worker instance.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: Linux now closes the window to the tray instead of minimizing it.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 7 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@SusieeTheLinuxUser
SusieeTheLinuxUser merged commit e45e8a3 into main Oct 29, 2026
4 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.

1 participant