Skip to content

fix(tauri): reposition when tray dims outside of monitor#270

Merged
iparaskev merged 1 commit intomainfrom
hide_bug
Mar 9, 2026
Merged

fix(tauri): reposition when tray dims outside of monitor#270
iparaskev merged 1 commit intomainfrom
hide_bug

Conversation

@iparaskev
Copy link
Contributor

@iparaskev iparaskev commented Mar 9, 2026

Our tray reposition logic was trying to center the tray even when it's location was outside the monitor. See the logs from a run

center_window_on_tray: tray_rect: Rect { position: { x: 2362, y: -66 }
center_window_on_tray: tray_rect: Rect { position: { x: 2362, y: 0 }

Also our reposition loop when the window is shown was calling center_window_on_tray with show = true, which was sending a focused event to tauri while our main window was open, which is not needed.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced tray window centering to validate monitor availability before repositioning, preventing centering attempts when no monitor is found.
    • Modified tray click interaction to prevent automatic window focus after repositioning.

Our tray reposition logic was trying to center the tray even when it's
location was outside the monitor. See the logs from a run

center_window_on_tray: tray_rect: Rect { position: { x: 2362, y: -66 }
center_window_on_tray: tray_rect: Rect { position: { x: 2362, y: 0 }

Also our reposition loop when the window is shown was calling
center_window_on_tray with show = true, which was sending a focused
event to tauri while our main window was open, which is not needed.
@netlify
Copy link

netlify bot commented Mar 9, 2026

Deploy Preview for hoppdocs ready!

Name Link
🔨 Latest commit 5327287
🔍 Latest deploy log https://app.netlify.com/projects/hoppdocs/deploys/69ae98aaf34f32000855bc01
😎 Deploy Preview https://deploy-preview-270--hoppdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b6276856-f8ee-46f7-ae57-d0bd6e79fd08

📥 Commits

Reviewing files that changed from the base of the PR and between e9db0a1 and 5327287.

📒 Files selected for processing (1)
  • tauri/src-tauri/src/lib.rs

📝 Walkthrough

Walkthrough

The pull request adds monitor validation to the center_window_on_tray function by introducing a found_monitor flag. If no valid monitor is detected, the function logs a warning and exits early. Additionally, all function calls are updated to set show_window to false, preventing explicit window display after centering.

Changes

Cohort / File(s) Summary
Window Centering Logic
tauri/src-tauri/src/lib.rs
Added found_monitor flag to track monitor detection; function now returns early with a warning if no monitor containing the tray is found. All center_window_on_tray calls updated from show_window = true to show_window = false.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • fix: tray position #216: Reworks center_window_on_tray to use async polling/monitoring with enhanced error handling, complementing this PR's monitor validation logic.

Poem

🐰 A rabbit hops through window frames,
Monitor guards now catch the strays,
Early exits, warnings bright,
No ghost windows left in sight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding logic to detect when the tray is outside a monitor and skip centering in those cases, which is the core issue being fixed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hide_bug

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@konsalex konsalex left a comment

Choose a reason for hiding this comment

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

❤️

@iparaskev iparaskev merged commit 1cd0894 into main Mar 9, 2026
19 checks passed
@iparaskev iparaskev deleted the hide_bug branch March 9, 2026 12:07
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