From 1243a683abcbaed451ea7b74a2dd08971c84c125 Mon Sep 17 00:00:00 2001 From: Alex Iwaniuk Date: Wed, 11 Nov 2026 11:36:43 +0100 Subject: [PATCH 1/2] Close the launch OSD only after its show call finishes The launch OSD shows with no duration, and show and close each ran as a detached omarchy-shell call. When the app's window appeared just after the 2s delay, close could reach the OSD before show did and leave it open for good; the 15s timeout could not help because the OSD already counted as closed. Co-Authored-By: Claude Opus 5.5 --- shell/services/AppLibrary.qml | 18 ++++++- .../fixtures/launch-osd-order/shell.qml | 48 +++++++++++++++++++ test/shell.d/launch-osd-order-test.sh | 24 ++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 test/shell.d/fixtures/launch-osd-order/shell.qml create mode 100755 test/shell.d/launch-osd-order-test.sh diff --git a/shell/services/AppLibrary.qml b/shell/services/AppLibrary.qml index 97b3ed6caa60..190bdddf4fb4 100644 --- a/shell/services/AppLibrary.qml +++ b/shell/services/AppLibrary.qml @@ -30,6 +30,7 @@ Item { // it: the OSD shows with duration 0, so only closeLaunchFeedback() takes it // down. property bool launchOsdOpen: false + property bool launchOsdCloseQueued: false property string launchOsdMessage: "" // Emitted whenever the visible application set may have changed: desktop @@ -189,7 +190,8 @@ Item { launchDelay.stop() launchTimeout.stop() if (root.launchOsdOpen) { - Quickshell.execDetached(["omarchy-shell", "osd", "close"]) + if (launchOsdShow.running) root.launchOsdCloseQueued = true + else Quickshell.execDetached(["omarchy-shell", "osd", "close"]) root.launchOsdOpen = false } } @@ -260,7 +262,8 @@ Item { onTriggered: { if (root.toplevelCount() > root.launchToplevelCount || ToplevelManager.activeToplevel !== root.launchActiveToplevel) return root.launchOsdOpen = true - Quickshell.execDetached(["omarchy-shell", "osd", "show", JSON.stringify({ icon: "󱓞", message: root.launchOsdMessage, duration: 0 })]) + launchOsdShow.command = ["omarchy-shell", "osd", "show", JSON.stringify({ icon: "󱓞", message: root.launchOsdMessage, duration: 0 })] + launchOsdShow.running = true } } @@ -270,6 +273,17 @@ Item { onTriggered: root.closeLaunchFeedback(root.launchSerial) } + // Show and close are separate omarchy-shell calls. Close waits for show to + // finish, so a close cannot reach the OSD first and leave it open forever. + Process { + id: launchOsdShow + onExited: { + if (!root.launchOsdCloseQueued) return + root.launchOsdCloseQueued = false + Quickshell.execDetached(["omarchy-shell", "osd", "close"]) + } + } + Connections { target: DesktopEntries.applications function onValuesChanged() { diff --git a/test/shell.d/fixtures/launch-osd-order/shell.qml b/test/shell.d/fixtures/launch-osd-order/shell.qml new file mode 100644 index 000000000000..eead41499d13 --- /dev/null +++ b/test/shell.d/fixtures/launch-osd-order/shell.qml @@ -0,0 +1,48 @@ +import QtQuick +import Quickshell +import Quickshell.Io +import "services" + +// Closes the launch OSD the moment it opens, while the stubbed +// `omarchy-shell osd show` is still running. The test then checks that the +// close reached omarchy-shell after the show. +ShellRoot { + id: root + + AppLibrary { id: appLibrary } + + FileView { + id: resultFile + path: Quickshell.env("OMARCHY_QML_TEST_RESULT") + atomicWrites: true + } + + Timer { + id: waitForOpen + interval: 20 + repeat: true + onTriggered: { + if (!appLibrary.launchOsdOpen) return + stop() + appLibrary.closeLaunchFeedback(appLibrary.launchSerial) + settle.start() + } + } + + Timer { + id: settle + interval: 1500 + onTriggered: resultFile.setText(JSON.stringify({ ok: true })) + } + + // Let the toplevel list finish loading first: a count that grows after the + // launch reads as the app's window appearing. + Timer { + running: true + interval: 1000 + onTriggered: { + appLibrary.beginLaunchFeedback("Test") + waitForOpen.start() + } + } +} diff --git a/test/shell.d/launch-osd-order-test.sh b/test/shell.d/launch-osd-order-test.sh new file mode 100755 index 000000000000..d7ee2240f1c7 --- /dev/null +++ b/test/shell.d/launch-osd-order-test.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +require_quickshell "launch OSD order test" + +# A slow `osd show` must not let the following `osd close` overtake it: the +# launch OSD has no duration, so a close that lands first leaves it open. +qml_fixture_scratch +osd_log="$QML_FIXTURE_TMP/osd.log" +cat >"$QML_FIXTURE_TMP/bin/omarchy-shell" <<'SH' +#!/bin/bash +[[ $2 == "show" ]] && sleep 0.5 +echo "$2" >>"$OSD_LOG" +SH +chmod +x "$QML_FIXTURE_TMP/bin/omarchy-shell" + +OSD_LOG="$osd_log" run_qml_fixture launch-osd-order "launch OSD fixture runs" services Commons + +[[ $(cat "$osd_log" 2>/dev/null | tr '\n' ' ') == "show close " ]] || + fail "launch OSD close waits for show" "omarchy-shell calls: $(cat "$osd_log" 2>/dev/null | tr '\n' ' ')" +pass "launch OSD close waits for show" From 62f3aa5da2181b609355ac052547d1329156ad4c Mon Sep 17 00:00:00 2001 From: Alex Iwaniuk Date: Wed, 11 Nov 2026 11:44:01 +0100 Subject: [PATCH 2/2] Track the pending launch OSD show without relying on running A Process does not report running until it has started, so a close in the same turn as the show still went out first. Track the pending show with a flag of our own, and move the show into showLaunchOsd() so the test can show and close in one turn, without real desktop window changes cancelling the launch first. Co-Authored-By: Claude Opus 5.5 --- shell/services/AppLibrary.qml | 16 ++++++--- .../fixtures/launch-osd-order/shell.qml | 33 +++++-------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/shell/services/AppLibrary.qml b/shell/services/AppLibrary.qml index 190bdddf4fb4..a195acea5d96 100644 --- a/shell/services/AppLibrary.qml +++ b/shell/services/AppLibrary.qml @@ -30,6 +30,7 @@ Item { // it: the OSD shows with duration 0, so only closeLaunchFeedback() takes it // down. property bool launchOsdOpen: false + property bool launchOsdShowPending: false property bool launchOsdCloseQueued: false property string launchOsdMessage: "" @@ -185,12 +186,19 @@ Item { launchTimeout.restart() } + function showLaunchOsd() { + root.launchOsdOpen = true + root.launchOsdShowPending = true + launchOsdShow.command = ["omarchy-shell", "osd", "show", JSON.stringify({ icon: "󱓞", message: root.launchOsdMessage, duration: 0 })] + launchOsdShow.running = true + } + function closeLaunchFeedback(serial) { if (serial !== root.launchSerial) return launchDelay.stop() launchTimeout.stop() if (root.launchOsdOpen) { - if (launchOsdShow.running) root.launchOsdCloseQueued = true + if (root.launchOsdShowPending) root.launchOsdCloseQueued = true else Quickshell.execDetached(["omarchy-shell", "osd", "close"]) root.launchOsdOpen = false } @@ -261,9 +269,7 @@ Item { interval: 2000 onTriggered: { if (root.toplevelCount() > root.launchToplevelCount || ToplevelManager.activeToplevel !== root.launchActiveToplevel) return - root.launchOsdOpen = true - launchOsdShow.command = ["omarchy-shell", "osd", "show", JSON.stringify({ icon: "󱓞", message: root.launchOsdMessage, duration: 0 })] - launchOsdShow.running = true + root.showLaunchOsd() } } @@ -275,9 +281,11 @@ Item { // Show and close are separate omarchy-shell calls. Close waits for show to // finish, so a close cannot reach the OSD first and leave it open forever. + // launchOsdShowPending covers the gap before `running` turns true. Process { id: launchOsdShow onExited: { + root.launchOsdShowPending = false if (!root.launchOsdCloseQueued) return root.launchOsdCloseQueued = false Quickshell.execDetached(["omarchy-shell", "osd", "close"]) diff --git a/test/shell.d/fixtures/launch-osd-order/shell.qml b/test/shell.d/fixtures/launch-osd-order/shell.qml index eead41499d13..fd2f16f92003 100644 --- a/test/shell.d/fixtures/launch-osd-order/shell.qml +++ b/test/shell.d/fixtures/launch-osd-order/shell.qml @@ -3,9 +3,10 @@ import Quickshell import Quickshell.Io import "services" -// Closes the launch OSD the moment it opens, while the stubbed -// `omarchy-shell osd show` is still running. The test then checks that the -// close reached omarchy-shell after the show. +// Shows the launch OSD and closes it in the same turn, while the stubbed +// `omarchy-shell osd show` is still running. Nothing runs in between, so window +// changes on the desktop cannot cancel the launch first. The test then checks +// that the close reached omarchy-shell after the show. ShellRoot { id: root @@ -17,32 +18,16 @@ ShellRoot { atomicWrites: true } - Timer { - id: waitForOpen - interval: 20 - repeat: true - onTriggered: { - if (!appLibrary.launchOsdOpen) return - stop() - appLibrary.closeLaunchFeedback(appLibrary.launchSerial) - settle.start() - } - } - Timer { id: settle interval: 1500 onTriggered: resultFile.setText(JSON.stringify({ ok: true })) } - // Let the toplevel list finish loading first: a count that grows after the - // launch reads as the app's window appearing. - Timer { - running: true - interval: 1000 - onTriggered: { - appLibrary.beginLaunchFeedback("Test") - waitForOpen.start() - } + Component.onCompleted: { + appLibrary.beginLaunchFeedback("Test") + appLibrary.showLaunchOsd() + appLibrary.closeLaunchFeedback(appLibrary.launchSerial) + settle.start() } }