Skip to content

feat: add refresh displays tray context menu option - #34

Merged
stabldev merged 3 commits into
mainfrom
feat/refresh-displays-menu
Jul 14, 2026
Merged

feat: add refresh displays tray context menu option#34
stabldev merged 3 commits into
mainfrom
feat/refresh-displays-menu

Conversation

@stabldev

@stabldev stabldev commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Removes automatic monitor refreshing on tray open to ensure instant UI rendering. Adds a manual 'Refresh displays' context menu option to resync with hardware when needed.

Summary by CodeRabbit

  • New Features

    • Added a “Refresh displays” option to the system tray menu.
    • Selecting it refreshes connected display information and brings the app window to the foreground when applicable.
  • Bug Fixes

    • Removed refresh behavior tied to window visibility changes, preventing redundant monitor updates.
    • Updated tray and click behavior to consistently bring the window forward and trigger refresh when needed.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 00d3d39d-c069-4fb4-b9b4-16a7330348c2

📥 Commits

Reviewing files that changed from the base of the PR and between ede10ff and ff0a9d1.

📒 Files selected for processing (1)
  • Services/TrayService.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • Services/TrayService.cs

📝 Walkthrough

Walkthrough

Monitor refreshes are no longer triggered by window visibility changes. A new tray command explicitly shows the main window and invokes MainWindow.ForceRefreshMonitors().

Changes

Display refresh control

Layer / File(s) Summary
MainWindow refresh entry point
MainWindow.xaml.cs
Visibility changes no longer refresh monitors automatically, and ForceRefreshMonitors() explicitly refreshes MainPage monitors when available.
Tray refresh command
Services/TrayService.cs
Adds the “Refresh displays” menu item, centralizes window foregrounding, and handles the command by showing, foregrounding, and refreshing the main window.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TrayService
  participant MainWindow
  participant MainPage
  User->>TrayService: Select Refresh displays
  TrayService->>MainWindow: Show and foreground window
  TrayService->>MainWindow: ForceRefreshMonitors()
  MainWindow->>MainPage: RefreshMonitors()
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 matches the main change: adding a Refresh displays tray context menu option.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/refresh-displays-menu

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
MainWindow.xaml.cs (1)

74-81: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the now-empty visibility handler.

After removing the refresh call, this handler only evaluates conditions and enters an empty block. Remove it and its AppWindow.Changed subscription unless another visibility behavior is intended. As per coding guidelines, prefer readable code and keep methods small and focused.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@MainWindow.xaml.cs` around lines 74 - 81, Remove the now-empty
AppWindow_Changed handler and its AppWindow.Changed subscription; also remove
any related unused wiring or references, preserving other window behavior
unchanged.

Source: Coding guidelines

Services/TrayService.cs (1)

94-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the existing show/foreground flow.

The refresh command duplicates the same AppWindow.Show() and SetForegroundWindow() logic used by “Show Window.” Extract a small helper and call it from both commands, then perform the monitor refresh only in the 1004 branch. As per coding guidelines, avoid duplicate logic and preserve the existing architecture.

Proposed refactor
+private void ShowWindow()
+{
+  _window.AppWindow.Show();
+  Win32.SetForegroundWindow(_hWnd);
+}

 if (selectedId == 1001)
 {
-  _window.AppWindow.Show();
-  Win32.SetForegroundWindow(_hWnd);
+  ShowWindow();
 }
 else if (selectedId == 1004)
 {
   if (_window is MainWindow mainWindow)
   {
-    _window.AppWindow.Show();
-    Win32.SetForegroundWindow(_hWnd);
+    ShowWindow();
     mainWindow.ForceRefreshMonitors();
   }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Services/TrayService.cs` around lines 94 - 102, Extract the shared window
display and foreground logic from the “Show Window” and selectedId 1004 branches
into a small helper, then call that helper from both commands. Keep
mainWindow.ForceRefreshMonitors() exclusively in the 1004 refresh branch.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@MainWindow.xaml.cs`:
- Around line 74-81: Remove the now-empty AppWindow_Changed handler and its
AppWindow.Changed subscription; also remove any related unused wiring or
references, preserving other window behavior unchanged.

In `@Services/TrayService.cs`:
- Around line 94-102: Extract the shared window display and foreground logic
from the “Show Window” and selectedId 1004 branches into a small helper, then
call that helper from both commands. Keep mainWindow.ForceRefreshMonitors()
exclusively in the 1004 refresh branch.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ac841715-6f6a-4912-b808-b35239d66682

📥 Commits

Reviewing files that changed from the base of the PR and between af3a9d3 and 335fa35.

📒 Files selected for processing (2)
  • MainWindow.xaml.cs
  • Services/TrayService.cs

@stabldev
stabldev merged commit 9ddebf6 into main Jul 14, 2026
1 check passed
@stabldev
stabldev deleted the feat/refresh-displays-menu branch July 14, 2026 01:53
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