Scale the IPC handler check to the number of screens

The bar is instantiated once per screen, so each widget registers its IPC
handler once per screen and Quickshell reports a collision for every screen
past the first. Failing on any collision would have failed the suite on
multi-monitor desktops for behaviour that is correct; allow one per screen
and fail only beyond that, which is still what duplicate component loads
produce.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-07-26 22:29:48 -07:00
co-authored by Claude Opus 5
parent 64810d815b
commit 7a6e34f153
+15 -10
View File
@@ -230,18 +230,23 @@ for panel_id in omarchy.audio omarchy.bluetooth omarchy.monitor omarchy.network
done
pass "direct panel IPC opens and closes default panels"
# Each widget registers its IPC handler once while the shell starts. A second
# registration for the same target means two instances of that widget were
# live at once, which is what duplicate component loads produced: every sync
# pass that ran while a widget's asynchronous load was still in flight started
# a second load, and swapping a slot's component builds the replacement before
# dropping the original. Checked before the reload below, which rebuilds
# widgets by design.
if grep -q "another handler is registered for target" "$log"; then
# Each widget registers its IPC handler once per bar, and the bar is
# instantiated once per screen, so Quickshell reports one collision per screen
# past the first. Anything beyond that is two instances on the same screen —
# the shape duplicate component loads produced, where a sync pass that ran
# while a widget's asynchronous load was still in flight started a second one.
# Checked before the reload below, which rebuilds widgets by design.
screens=$(hyprctl -j monitors 2>/dev/null | jq 'length' 2>/dev/null || true)
[[ $screens =~ ^[0-9]+$ ]] && (( screens > 0 )) || screens=1
# No matches is the good case, and pipefail would otherwise abort the run.
worst=$(grep -oE "another handler is registered for target [a-z.-]+" "$log" |
sort | uniq -c | sort -rn | head -1 | awk '{print $1}' || true)
worst=${worst:-0}
if (( worst > screens - 1 )); then
grep "another handler is registered for target" "$log" | sed 's/^/ /' | head -20 >&2
fail_with_log "each widget registers its IPC handler once while starting"
fail_with_log "each widget registers its IPC handler once per screen (saw $worst for $screens screen(s))"
fi
pass "each widget registers its IPC handler once while starting"
pass "each widget registers its IPC handler once per screen"
HOME="$test_home" OMARCHY_PATH="$test_root" PATH="$ROOT/bin:$PATH" "$ROOT/bin/omarchy-bar-plugin" remove omarchy.audio