From df7aec7baa914fbdcad7244994a455f7ee276257 Mon Sep 17 00:00:00 2001 From: yogeshprasad098 Date: Thu, 26 Nov 2026 22:43:56 -0800 Subject: [PATCH] fix(test): close the measured window without quitting installed apps measure-cpu.sh closed the test build's window with an AppleScript quit. AppleScript finds apps by bundle identifier, so it also quit an installed Chargectl, which stops its helper and hands charging back to macOS. Close the window with a chargectl://dashboard/close link that only --background builds answer, opened with the measured app. --- App/Dashboard/DashboardView.swift | 5 +++++ scripts/measure-cpu.sh | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/App/Dashboard/DashboardView.swift b/App/Dashboard/DashboardView.swift index 3731ab6..45deb2e 100644 --- a/App/Dashboard/DashboardView.swift +++ b/App/Dashboard/DashboardView.swift @@ -67,6 +67,11 @@ struct DashboardView: View { } .onDisappear { Dashboard.didClose() } .onOpenURL { url in + // scripts/measure-cpu.sh closes the window of the build it measures this way. + if Setup.staysInBackground, url.lastPathComponent == "close" { + Dashboard.close() + return + } // chargectl://dashboard/ if let target = DashboardPage(rawValue: url.lastPathComponent) { page = target } // Measuring in the background: keep the window above whatever the user brought forward. diff --git a/scripts/measure-cpu.sh b/scripts/measure-cpu.sh index 7e97276..2a5fc51 100755 --- a/scripts/measure-cpu.sh +++ b/scripts/measure-cpu.sh @@ -92,9 +92,10 @@ show overview sleep 4 read -r app_cpu server_cpu < <(measure) row "overview, in background" "$app_cpu" "$server_cpu" -# Quitting from outside only closes the dashboard; the app stays in the menu bar. AppleScript -# reports that as a cancelled quit. -osascript -e "tell application \"$app\" to quit" >/dev/null 2>&1 || true +# Closes this app's window with a link only --background builds answer. Never quit it with +# AppleScript: that finds apps by bundle identifier and also quits an installed Chargectl, which +# stops its helper and hands charging back to macOS. +show close sleep 4 read -r app_cpu server_cpu < <(measure) row "window closed" "$app_cpu" "$server_cpu"