Skip to content

fix(monitor): fix display mirroring recovery and UI state - #6457

Merged
dhh merged 5 commits into
omacom:quattrofrom
setiapam:quattro
Aug 11, 2026
Merged

dhh merged 5 commits into
omacom:quattrofrom
setiapam:quattro

Conversation

@setiapam

@setiapam setiapam commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Why

In Omarchy 4 (quattro), toggling display mirroring on a laptop (via omarchy-hyprland-monitor-internal-mirror on, SUPER + CTRL + ALT + Delete, or the shell display panel) turned mirroring on for a split second before immediately reverting back to extended display mode. Additionally, the omarchy-shell display panel always rendered the Mirroring toggle as OFF.

Root Cause Details

  1. Auto-Recovery Race Condition:
    On Intel GPUs (and Aquamarine DRM), setting a display to mirror mode merges CRTC rendering streams in Hyprland, causing the mirrored display to be omitted from the standard hyprctl monitors -j output (it is only returned by hyprctl monitors all -j).
    This caused omarchy-hyprland-monitor-external-active to return exit code 4 (false) while mirroring was active. When hyprctl reload fired, the omarchy-hyprland-monitor-watch daemon invoked omarchy-hyprland-monitor-clamshell -> internal-mirror recover, which falsely treated the external monitor as disconnected and immediately deleted the internal-monitor-mirror.lua toggle flag.

  2. UI State Resolution Mismatch:
    In bin/omarchy-monitor-state, line 15 specifically checked .mirrorOf on the internal display (eDP-1). When the external monitor (HDMI-A-1) mirrored the internal display, .mirrorOf was populated on the external monitor instead of the internal display, causing omarchy-monitor-state to return an empty string and Panel.qml to evaluate mirrorEnabled = false.

What

Two targeted fixes:

  1. bin/omarchy-hyprland-monitor-external-active: Switched hyprctl monitors -j to hyprctl monitors all -j so mirrored external monitors are correctly recognized as active, preventing the false disconnect recovery loop.
  2. bin/omarchy-monitor-state: Updated the .mirrorOf jq extraction to evaluate any active mirror target regardless of mirror direction, returning the external display name when mirroring is active so omarchy-shell renders mirrorEnabled = true.

Verification

  • Tested on an Intel Iris Xe laptop running Omarchy 4 (quattro branch) with an external HDMI display.
  • Verified omarchy-hyprland-monitor-internal-mirror toggle stays active continuously without being deleted by recovery.
  • Verified omarchy-monitor-state correctly reports the active mirror output to omarchy-shell.
  • Ran test suite (./test/cli and ./test/shell) with clean passes.

Copilot AI balanced review requested due to automatic review settings July 31, 2026 04:30

Copilot AI 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.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings August 1, 2026 03:32

Copilot AI 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.

Copilot wasn't able to review any files in this pull request.

@setiapam setiapam changed the title fix(monitor): prevent mirror toggle deletion during recovery and fix UI state fix(monitor): fix display mirroring recovery and UI state Aug 3, 2026
The helper now asks `hyprctl monitors all -j`, so the test that pinned it
to plain `monitors` failed. A mirrored external is absent from plain
`monitors`, which reads as a disconnect and hands the mirror toggle to
recovery.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 11, 2026 16:04

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 3 changed files in this pull request and generated no new comments.

Piping the first mirroring monitor into the branch fed jq's test() a null
whenever no output mirrored, and jq aborts there rather than falling back
to "". The panel reads this output by line, so the missing line shifted
the focused monitor, the scale, and the display list up one, and left
mirroring reading as on whenever the external display had focus.

Select first and branch inside the pipeline, so the branch only ever sees
a monitor and the empty case falls to "" as the lines around it do.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 11, 2026 16:13

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 3 changed files in this pull request and generated no new comments.

Nothing exercised omarchy-monitor-state, so both the mirror direction it
reported and the jq that reported it went unguarded. The panel reads the
output by line index, where a helper dying mid-script costs a line and
shifts every field below it into the wrong property without failing.

Assert the line count alongside the fields, over extended, mirrored both
directions, and clamshelled displays.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 11, 2026 16:24
@dhh
dhh merged commit f4b832e into omacom:quattro Aug 11, 2026

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (1)

test/shell.d/monitor-state-test.sh:53

  • The repository shell style requires variables to remain unquoted inside [[ ]]; only string literals are quoted. Use $expected unquoted here to follow that convention.
  [[ ${state_lines[index]-} == "$expected" ]] ||

nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
* fix(monitor): prevent mirror toggle deletion during recovery and fix UI state

* Assert the external monitor helper counts mirrors as active

The helper now asks `hyprctl monitors all -j`, so the test that pinned it
to plain `monitors` failed. A mirrored external is absent from plain
`monitors`, which reads as a disconnect and hands the mirror toggle to
recovery.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Keep the mirror state line when nothing is mirrored

Piping the first mirroring monitor into the branch fed jq's test() a null
whenever no output mirrored, and jq aborts there rather than falling back
to "". The panel reads this output by line, so the missing line shifted
the focused monitor, the scale, and the display list up one, and left
mirroring reading as on whenever the external display had focus.

Select first and branch inside the pipeline, so the branch only ever sees
a monitor and the empty case falls to "" as the lines around it do.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Cover the monitor panel state the shell reads by line

Nothing exercised omarchy-monitor-state, so both the mirror direction it
reported and the jq that reported it went unguarded. The panel reads the
output by line index, where a helper dying mid-script costs a line and
shifts every field below it into the wrong property without failing.

Assert the line count alongside the fields, over extended, mirrored both
directions, and clamshelled displays.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: David Heinemeier Hansson <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

3 participants