From dd8d93c387541e6ec8ffff2b66867cb8ba7ae55c Mon Sep 17 00:00:00 2001 From: Gabriel Brown Date: Tue, 18 Aug 2026 13:05:25 -0400 Subject: [PATCH] Ignore transient Quickshell clients in Health --- config/dot/quickshell/scripts/panama-doctor | 18 ++++++++++++++++-- tests/quickshell/fixtures/doctor/bin/qs | 7 +++++++ tests/quickshell/panama-doctor-contract.sh | 5 ++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/config/dot/quickshell/scripts/panama-doctor b/config/dot/quickshell/scripts/panama-doctor index 9025015..74850e7 100755 --- a/config/dot/quickshell/scripts/panama-doctor +++ b/config/dot/quickshell/scripts/panama-doctor @@ -130,7 +130,7 @@ RUNTIME_LINK_TARGETS = ( ("vicinae", Path("config/dot/vicinae")), ) REPAIR_IDS = frozenset((*REPAIR_COMMANDS.keys(), "panama.runtime-links", "panama.vicinae-commands", "panama.caffeine")) -PROCESS_NAMES = ("quickshell", "vicinae", "hyprpaper", "hypridle") +PROCESS_NAMES = ("vicinae", "hyprpaper", "hypridle") VERSION_PATTERN = re.compile(r"\b\d+(?:\.\d+){0,3}(?:[-+._][A-Za-z0-9._-]+)?\b") REVISION_PATTERN = re.compile(r"\b[0-9a-f]{7,40}\b", re.IGNORECASE) PROBE_ENVIRONMENT_KEYS = ( @@ -436,7 +436,21 @@ def executable_check(check_id: str, title: str, executable: str, config: DoctorC def check_processes(config: DoctorConfig) -> Check: - counts: list[int] = [] + # `qs` is both the long-running shell and every short-lived IPC client. + # Counting it with pgrep races the other parallel health probes and reports + # duplicates whenever one of them happens to call `qs ipc`. The instance + # list is the authoritative view and contains only actual shells. + quickshell = run_command(("qs", "list"), config) + if quickshell.state == "ok": + quickshell_count = sum( + line.startswith("Instance ") for line in quickshell.stdout.splitlines() + ) + elif quickshell.state == "failed": + quickshell_count = 0 + else: + return Check("panama.processes", "panama-tools", "Panama processes", "warning", "Process probe is unavailable.") + + counts: list[int] = [quickshell_count] for name in PROCESS_NAMES: result = run_command(("pgrep", "-u", str(os.getuid()), "-x", name), config) if result.state == "ok": diff --git a/tests/quickshell/fixtures/doctor/bin/qs b/tests/quickshell/fixtures/doctor/bin/qs index d429301..7494757 100755 --- a/tests/quickshell/fixtures/doctor/bin/qs +++ b/tests/quickshell/fixtures/doctor/bin/qs @@ -4,6 +4,13 @@ set -euo pipefail case "${1:-}" in --version) printf '%s\n' "${PANAMA_DOCTOR_FIXTURE_QS_VERSION:-Quickshell 0.2.0}" ;; + list) + case ",${PANAMA_DOCTOR_FIXTURE_PROCESSES:-}," in + *,qs:duplicate,*) printf '%s\n' 'Instance fixture-one:' 'Instance fixture-two:' ;; + *,qs:missing,*) ;; + *) printf '%s\n' 'Instance fixture-one:' ;; + esac + ;; ipc) if [[ "${PANAMA_DOCTOR_FIXTURE_QS:-ready}" == "malformed" ]]; then printf 'fixture-secret-token AA:BB:CC:DD:EE:FF\n' diff --git a/tests/quickshell/panama-doctor-contract.sh b/tests/quickshell/panama-doctor-contract.sh index 33c8f0a..b0dfccd 100755 --- a/tests/quickshell/panama-doctor-contract.sh +++ b/tests/quickshell/panama-doctor-contract.sh @@ -216,11 +216,14 @@ jq -e '.checks[] | select(.id == "panama.caffeine") || fail 'Caffeine detail exposed inhibitor PIDs' # Process counts use only exact authored names and never expose command lines or PIDs. -duplicated_processes="$(PANAMA_DOCTOR_FIXTURE_PROCESSES=quickshell:duplicate run_doctor --json)" +duplicated_processes="$(PANAMA_DOCTOR_FIXTURE_PROCESSES=qs:duplicate run_doctor --json)" check_status "$duplicated_processes" panama.processes warning ! jq -r '.checks[] | select(.id == "panama.processes") | .detail' <<<"$duplicated_processes" | grep -Eq '[0-9]{3,}' \ || fail 'process detail exposed a PID' +missing_quickshell_process="$(PANAMA_DOCTOR_FIXTURE_PROCESSES=qs:missing run_doctor --json)" +check_status "$missing_quickshell_process" panama.processes error + # Invalid output for a non-Quickshell authored process is not a normal zero # count that can be hidden by the running Quickshell process. malformed_processes="$(PANAMA_DOCTOR_FIXTURE_PROCESSES=hyprpaper:malformed run_doctor --json)"