From 632660a069da66cf8d323d90f046905beb8b69d8 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:53:22 -0643 Subject: [PATCH 1/4] omamobile-shell 0.2.57: a reboot while widgets load is not a crash The crash guard records each user widget in widget-guard.json while it loads, and an entry still there at the next start marked the widget as having crashed the shell. A reboot, a shutdown or a dead battery during the first seconds of the home screen left those entries behind too, so after a few kernel pushes on the Pixel 9a three widgets were switched off with "This widget crashed the shell" although their code was fine. The guard file now carries the boot id it was written in. At start, entries still loading from another boot are dropped with their own log line; entries from the same boot are still a shell death and are held back as before. The package test checks the three pieces, and the interop plan's crash-guard section says so. --- docs/WIDGET-INTEROP-PLAN.md | 2 +- .../plugins/omamobile.home/Home.qml | 22 +++++++++++++++---- packages/omamobile-shell/test/all | 7 ++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/WIDGET-INTEROP-PLAN.md b/docs/WIDGET-INTEROP-PLAN.md index cb5aaa4bd..a344b2a87 100644 --- a/docs/WIDGET-INTEROP-PLAN.md +++ b/docs/WIDGET-INTEROP-PLAN.md @@ -209,7 +209,7 @@ We ship at **level 7 minus `Terminal`**, which covers 102 of the 105 store widge * **Compile errors** turn that cell into the error card, with the caret message and "Tap to fix with AI", and write `.errors/.txt`. * **Run-time errors** (a cap that was hit, a bad value) show `…` in place and are appended to `.errors/` (deduplicated, the last 20 kept), as the guide describes. -* **Renderer faults** that could still take the shell down (a QML binding loop in our node code, a huge image, a Canvas that stalls the scene graph) are covered by the **existing crash guard**: `OwlCell` calls `guardBegin(id, hash)` before the first render and `guardEnd` after it has run for 3 s, as `UserWidgetCell` does. A widget whose load crashed the shell is held back at the next start. Every crash we find this way becomes a conformance test and a fix in our runtime. +* **Renderer faults** that could still take the shell down (a QML binding loop in our node code, a huge image, a Canvas that stalls the scene graph) are covered by the **existing crash guard**: `OwlCell` calls `guardBegin(id, hash)` before the first render and `guardEnd` after it has run for 3 s, as `UserWidgetCell` does. A widget whose load crashed the shell is held back at the next start. The guard file carries the boot id it was written in, so a widget still loading when the system itself went down (a reboot, a shutdown, a dead battery) is not counted as a crash: only a shell death inside the same boot is (omamobile-shell 0.2.57). Every crash we find this way becomes a conformance test and a fix in our runtime. * **Instances outlive cells.** Layout edits rebuild Home's cells. The OWL instance (state, source values, history) lives in a per-placement registry in `Home.qml`, so a rebuild reattaches without re-running sources, which is what `host.cached` does for QML. --- diff --git a/packages/omamobile-shell/plugins/omamobile.home/Home.qml b/packages/omamobile-shell/plugins/omamobile.home/Home.qml index c798aae34..0808be58d 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/Home.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/Home.qml @@ -242,9 +242,19 @@ Item { // (written synchronously) while it loads and for its first seconds; an // entry still there at the next start was running when the shell died, // and that widget stays off until its files change (a new hash). + // The file also carries the boot id it was written in: a widget still + // "loading" from another boot was cut off by a reboot or a dead battery, + // not by its own code, so it is not marked crashed. readonly property string guardPath: configDir + "/widget-guard.json" property var guardLoading: ({}) property var guardCrashed: ({}) + FileView { + id: bootIdFile + path: "/proc/sys/kernel/random/boot_id" + blockLoading: true + printErrors: false + } + readonly property string bootId: String(bootIdFile.text() || "").trim() FileView { id: guardFile path: root.guardPath @@ -255,16 +265,20 @@ Item { onLoaded: { var data = {} try { data = JSON.parse(text() || "{}") || {} } catch (e) { data = {} } - root.guardCrashed = Object.assign({}, data.crashed || {}, data.loading || {}) + var loading = data.loading || {} + var sameBoot = !root.bootId || !data.boot || data.boot === root.bootId + root.guardCrashed = Object.assign({}, data.crashed || {}, sameBoot ? loading : {}) root.guardLoading = ({}) - Object.keys(data.loading || {}).forEach(function(id) { - console.warn("omamobile.home: widget " + id + " was loading when the shell stopped; it stays off until it changes") + Object.keys(loading).forEach(function(id) { + console.warn(sameBoot + ? "omamobile.home: widget " + id + " was loading when the shell stopped; it stays off until it changes" + : "omamobile.home: widget " + id + " was loading when the system went down last boot; not a crash, so it loads again") }) root.guardWrite() } } function guardWrite() { - guardFile.setText(JSON.stringify({ loading: guardLoading, crashed: guardCrashed }) + "\n") + guardFile.setText(JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed }) + "\n") } function guardBegin(widgetId, hash) { var next = Object.assign({}, guardLoading); next[widgetId] = hash diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index b7c7c0376..1eca456ea 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -925,6 +925,13 @@ pass "session environment" bash -n bin/omamobile-setup-user || fail "omamobile-setup-user parses" bash test/setup-user.sh || fail "omamobile-setup-user against a scratch home" bash -n bin/omamobile-osk-guard || fail "omamobile-osk-guard parses" +# The widget crash guard counts only a shell death inside the same boot: a +# widget still "loading" from another boot (reboot, shutdown, dead battery) +# is not marked crashed. +h=plugins/omamobile.home/Home.qml +grep -c 'path: "/proc/sys/kernel/random/boot_id"' $h >/dev/null || fail "the crash guard reads the boot id" +grep -c 'JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed })' $h >/dev/null || fail "the crash guard records the boot id" +grep -c 'sameBoot ? loading : {}' $h >/dev/null || fail "a widget loading in another boot is not a crash" bash test/osk-guard.sh || fail "omamobile-osk-guard" bash -n bin/omamobile-sleepd || fail "omamobile-sleepd parses" bash test/sleepd.sh || fail "omamobile-sleepd" From 06bfb03678ff1078d7e85200b7f4a1275e6f37b5 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 19:55:59 -0647 Subject: [PATCH 2/4] omamobile-shell 0.2.57: a deliberate quit clears the widget guard's loading list omarchy-restart-shell stops the shell with quickshell kill, a clean quit, and widgets still loading at that moment were marked as having crashed the shell at the next start: on the Pixel 9a, two restarts in a row switched off all four user widgets. A clean quit emits aboutToQuit and a crash never does, so the guard now clears what was loading on its way out. --- docs/WIDGET-INTEROP-PLAN.md | 2 +- .../omamobile-shell/plugins/omamobile.home/Home.qml | 12 ++++++++++++ packages/omamobile-shell/test/all | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/WIDGET-INTEROP-PLAN.md b/docs/WIDGET-INTEROP-PLAN.md index a344b2a87..2afe4911e 100644 --- a/docs/WIDGET-INTEROP-PLAN.md +++ b/docs/WIDGET-INTEROP-PLAN.md @@ -209,7 +209,7 @@ We ship at **level 7 minus `Terminal`**, which covers 102 of the 105 store widge * **Compile errors** turn that cell into the error card, with the caret message and "Tap to fix with AI", and write `.errors/.txt`. * **Run-time errors** (a cap that was hit, a bad value) show `…` in place and are appended to `.errors/` (deduplicated, the last 20 kept), as the guide describes. -* **Renderer faults** that could still take the shell down (a QML binding loop in our node code, a huge image, a Canvas that stalls the scene graph) are covered by the **existing crash guard**: `OwlCell` calls `guardBegin(id, hash)` before the first render and `guardEnd` after it has run for 3 s, as `UserWidgetCell` does. A widget whose load crashed the shell is held back at the next start. The guard file carries the boot id it was written in, so a widget still loading when the system itself went down (a reboot, a shutdown, a dead battery) is not counted as a crash: only a shell death inside the same boot is (omamobile-shell 0.2.57). Every crash we find this way becomes a conformance test and a fix in our runtime. +* **Renderer faults** that could still take the shell down (a QML binding loop in our node code, a huge image, a Canvas that stalls the scene graph) are covered by the **existing crash guard**: `OwlCell` calls `guardBegin(id, hash)` before the first render and `guardEnd` after it has run for 3 s, as `UserWidgetCell` does. A widget whose load crashed the shell is held back at the next start. The guard file carries the boot id it was written in, so a widget still loading when the system itself went down (a reboot, a shutdown, a dead battery) is not counted as a crash: only a shell death inside the same boot is, and a deliberate quit (a shell restart, a logout) clears what was still loading on its way out (omamobile-shell 0.2.57). Every crash we find this way becomes a conformance test and a fix in our runtime. * **Instances outlive cells.** Layout edits rebuild Home's cells. The OWL instance (state, source values, history) lives in a per-placement registry in `Home.qml`, so a rebuild reattaches without re-running sources, which is what `host.cached` does for QML. --- diff --git a/packages/omamobile-shell/plugins/omamobile.home/Home.qml b/packages/omamobile-shell/plugins/omamobile.home/Home.qml index 0808be58d..1b8170592 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/Home.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/Home.qml @@ -277,6 +277,18 @@ Item { root.guardWrite() } } + // A deliberate quit (omarchy-restart-shell's `quickshell kill`, a logout) + // goes through the application's aboutToQuit; a crash never does. So a + // quit clears what was still loading, and only a shell that died leaves + // entries behind for the next start. + Connections { + target: Qt.application + function onAboutToQuit() { + if (Object.keys(root.guardLoading).length === 0) return + root.guardLoading = ({}) + root.guardWrite() + } + } function guardWrite() { guardFile.setText(JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed }) + "\n") } diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 1eca456ea..54414061d 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -932,6 +932,7 @@ h=plugins/omamobile.home/Home.qml grep -c 'path: "/proc/sys/kernel/random/boot_id"' $h >/dev/null || fail "the crash guard reads the boot id" grep -c 'JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed })' $h >/dev/null || fail "the crash guard records the boot id" grep -c 'sameBoot ? loading : {}' $h >/dev/null || fail "a widget loading in another boot is not a crash" +grep -c 'function onAboutToQuit()' $h >/dev/null || fail "a deliberate quit clears what was still loading" bash test/osk-guard.sh || fail "omamobile-osk-guard" bash -n bin/omamobile-sleepd || fail "omamobile-sleepd parses" bash test/sleepd.sh || fail "omamobile-sleepd" From 59a4f90dbc8f5658ce4b8f38355e32e57eeb4b47 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 01:41:48 -0647 Subject: [PATCH 3/4] omamobile-shell 0.2.64: a widget loading when the system went down gets one retry, and the quit hook that runs Review of #217. A widget still loading from another boot now loads once more as a suspect and is held back if it is still loading at the next start, so a widget that takes the whole system down is still stopped after its second reset. Quickshell 0.3 never delivers Qt.application's aboutToQuit to QML and dies on SIGTERM without tearing down, so the deliberate-quit hook is Home's Component.onDestruction, which quickshell kill runs. test/widget-guard runs the real guard block in Quickshell across starts and boots. --- docs/WIDGET-INTEROP-PLAN.md | 2 +- .../plugins/omamobile.home/Home.qml | 59 +++++++++------ packages/omamobile-shell/test/all | 24 ++++-- packages/omamobile-shell/test/widget-guard | 73 +++++++++++++++++++ 4 files changed, 130 insertions(+), 28 deletions(-) create mode 100755 packages/omamobile-shell/test/widget-guard diff --git a/docs/WIDGET-INTEROP-PLAN.md b/docs/WIDGET-INTEROP-PLAN.md index 2afe4911e..3e72ee210 100644 --- a/docs/WIDGET-INTEROP-PLAN.md +++ b/docs/WIDGET-INTEROP-PLAN.md @@ -209,7 +209,7 @@ We ship at **level 7 minus `Terminal`**, which covers 102 of the 105 store widge * **Compile errors** turn that cell into the error card, with the caret message and "Tap to fix with AI", and write `.errors/.txt`. * **Run-time errors** (a cap that was hit, a bad value) show `…` in place and are appended to `.errors/` (deduplicated, the last 20 kept), as the guide describes. -* **Renderer faults** that could still take the shell down (a QML binding loop in our node code, a huge image, a Canvas that stalls the scene graph) are covered by the **existing crash guard**: `OwlCell` calls `guardBegin(id, hash)` before the first render and `guardEnd` after it has run for 3 s, as `UserWidgetCell` does. A widget whose load crashed the shell is held back at the next start. The guard file carries the boot id it was written in, so a widget still loading when the system itself went down (a reboot, a shutdown, a dead battery) is not counted as a crash: only a shell death inside the same boot is, and a deliberate quit (a shell restart, a logout) clears what was still loading on its way out (omamobile-shell 0.2.57). Every crash we find this way becomes a conformance test and a fix in our runtime. +* **Renderer faults** that could still take the shell down (a QML binding loop in our node code, a huge image, a Canvas that stalls the scene graph) are covered by the **existing crash guard**: `OwlCell` calls `guardBegin(id, hash)` before the first render and `guardEnd` after it has run for 3 s, as `UserWidgetCell` does. A widget whose load crashed the shell is held back at the next start. The guard file carries the boot id it was written in. A shell death inside the same boot is a crash. A widget still loading when the system itself went down (a reboot, a shutdown, a dead battery, or a system crash it caused) gets one retry: it loads again as a suspect, and is held back if it is still loading at the next start; a clean run clears it. Quickshell dies on the session's SIGTERM without tearing anything down, so ordinary reboots look like this. A deliberate quit (a shell restart, a logout) clears what was still loading from Home's `Component.onDestruction` (omamobile-shell 0.2.64). Every crash we find this way becomes a conformance test and a fix in our runtime. * **Instances outlive cells.** Layout edits rebuild Home's cells. The OWL instance (state, source values, history) lives in a per-placement registry in `Home.qml`, so a rebuild reattaches without re-running sources, which is what `host.cached` does for QML. --- diff --git a/packages/omamobile-shell/plugins/omamobile.home/Home.qml b/packages/omamobile-shell/plugins/omamobile.home/Home.qml index 1b8170592..1eda58941 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/Home.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/Home.qml @@ -242,12 +242,17 @@ Item { // (written synchronously) while it loads and for its first seconds; an // entry still there at the next start was running when the shell died, // and that widget stays off until its files change (a new hash). - // The file also carries the boot id it was written in: a widget still - // "loading" from another boot was cut off by a reboot or a dead battery, - // not by its own code, so it is not marked crashed. + // The file also carries the boot id it was written in. A widget still + // "loading" from another boot was most likely cut off by a reboot or a + // dead battery (Quickshell dies on the session's SIGTERM without tearing + // anything down), but it could also have brought the whole system down. + // So it gets one retry: it loads again and is kept as a suspect, and if + // it is still loading when the next start finds it (a second unclean + // end in a row), it is held back as a crash. A clean run clears it. readonly property string guardPath: configDir + "/widget-guard.json" property var guardLoading: ({}) property var guardCrashed: ({}) + property var guardSuspect: ({}) FileView { id: bootIdFile path: "/proc/sys/kernel/random/boot_id" @@ -267,30 +272,40 @@ Item { try { data = JSON.parse(text() || "{}") || {} } catch (e) { data = {} } var loading = data.loading || {} var sameBoot = !root.bootId || !data.boot || data.boot === root.bootId - root.guardCrashed = Object.assign({}, data.crashed || {}, sameBoot ? loading : {}) - root.guardLoading = ({}) + var crashed = Object.assign({}, data.crashed || {}) + var suspect = Object.assign({}, data.suspect || {}) Object.keys(loading).forEach(function(id) { - console.warn(sameBoot - ? "omamobile.home: widget " + id + " was loading when the shell stopped; it stays off until it changes" - : "omamobile.home: widget " + id + " was loading when the system went down last boot; not a crash, so it loads again") + if (sameBoot || suspect[id] === loading[id]) { + crashed[id] = loading[id] + delete suspect[id] + console.warn("omamobile.home: widget " + id + (sameBoot + ? " was loading when the shell stopped" + : " was loading when the system went down twice in a row") + + "; it stays off until it changes") + } else { + suspect[id] = loading[id] + console.warn("omamobile.home: widget " + id + " was loading when the system went down last boot; it loads once more as a suspect") + } }) - root.guardWrite() - } - } - // A deliberate quit (omarchy-restart-shell's `quickshell kill`, a logout) - // goes through the application's aboutToQuit; a crash never does. So a - // quit clears what was still loading, and only a shell that died leaves - // entries behind for the next start. - Connections { - target: Qt.application - function onAboutToQuit() { - if (Object.keys(root.guardLoading).length === 0) return + root.guardCrashed = crashed + root.guardSuspect = suspect root.guardLoading = ({}) root.guardWrite() } } + // A deliberate quit (omarchy-restart-shell's `quickshell kill`, a logout + // through Omarchy) tears the QML tree down, and Home's onDestruction runs; + // a crash or a signal never gets there. Quickshell 0.3 doesn't deliver + // Qt.application's aboutToQuit to QML, so this is the hook. A quit clears + // what was still loading, and only a shell that died leaves entries + // behind for the next start. + Component.onDestruction: { + if (Object.keys(root.guardLoading).length === 0) return + root.guardLoading = ({}) + root.guardWrite() + } function guardWrite() { - guardFile.setText(JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed }) + "\n") + guardFile.setText(JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed, suspect: guardSuspect }) + "\n") } function guardBegin(widgetId, hash) { var next = Object.assign({}, guardLoading); next[widgetId] = hash @@ -299,10 +314,12 @@ Item { // `ran`: the widget has now run cleanly, so an older crash of it is forgotten. function guardEnd(widgetId, ran) { var crashed = ran && (widgetId in guardCrashed) - if (!(widgetId in guardLoading) && !crashed) return + var suspect = ran && (widgetId in guardSuspect) + if (!(widgetId in guardLoading) && !crashed && !suspect) return var next = Object.assign({}, guardLoading); delete next[widgetId] guardLoading = next if (crashed) { var c = Object.assign({}, guardCrashed); delete c[widgetId]; guardCrashed = c } + if (suspect) { var x = Object.assign({}, guardSuspect); delete x[widgetId]; guardSuspect = x } guardWrite() } diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 54414061d..5925626cc 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -925,14 +925,26 @@ pass "session environment" bash -n bin/omamobile-setup-user || fail "omamobile-setup-user parses" bash test/setup-user.sh || fail "omamobile-setup-user against a scratch home" bash -n bin/omamobile-osk-guard || fail "omamobile-osk-guard parses" -# The widget crash guard counts only a shell death inside the same boot: a -# widget still "loading" from another boot (reboot, shutdown, dead battery) -# is not marked crashed. +# The widget crash guard counts a shell death inside the same boot as a +# crash. A widget still "loading" from another boot (reboot, shutdown, dead +# battery, or a system crash it caused) gets one retry as a suspect, and is +# held back if it is still loading at the next start; a clean run clears it. h=plugins/omamobile.home/Home.qml grep -c 'path: "/proc/sys/kernel/random/boot_id"' $h >/dev/null || fail "the crash guard reads the boot id" -grep -c 'JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed })' $h >/dev/null || fail "the crash guard records the boot id" -grep -c 'sameBoot ? loading : {}' $h >/dev/null || fail "a widget loading in another boot is not a crash" -grep -c 'function onAboutToQuit()' $h >/dev/null || fail "a deliberate quit clears what was still loading" +grep -c 'JSON.stringify({ boot: bootId, loading: guardLoading, crashed: guardCrashed, suspect: guardSuspect })' $h >/dev/null || fail "the crash guard records the boot id and the suspects" +grep -c 'if (sameBoot || suspect\[id\] === loading\[id\]) {' $h >/dev/null || fail "a same-boot death or a second unclean end in a row is a crash" +grep -c 'suspect\[id\] = loading\[id\]' $h >/dev/null || fail "a widget loading in another boot is a suspect, not a crash" +grep -c 'var suspect = ran && (widgetId in guardSuspect)' $h >/dev/null || fail "a clean run clears a suspect" +grep -c 'Component.onDestruction: {' $h >/dev/null || fail "a deliberate quit clears what was still loading" +grep -c 'target: Qt.application' $h >/dev/null && fail "Quickshell 0.3 never delivers aboutToQuit to QML" +rc=0; out=$(bash test/widget-guard 2>&1) || rc=$? +if [[ $rc == 77 ]]; then + pass "widget crash guard across starts and boots # SKIP no quickshell" +elif [[ $rc != 0 ]]; then + printf '%s\n' "$out" | grep -v '^ok' >&2; fail "widget crash guard (test/widget-guard)" +else + pass "widget crash guard: same-boot death held back, one retry after a system going down, clean run and quit clear" +fi bash test/osk-guard.sh || fail "omamobile-osk-guard" bash -n bin/omamobile-sleepd || fail "omamobile-sleepd parses" bash test/sleepd.sh || fail "omamobile-sleepd" diff --git a/packages/omamobile-shell/test/widget-guard b/packages/omamobile-shell/test/widget-guard new file mode 100755 index 000000000..cc537b7e3 --- /dev/null +++ b/packages/omamobile-shell/test/widget-guard @@ -0,0 +1,73 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# The home screen's widget crash guard, run for real: the guard block cut +# out of Home.qml into a bare Quickshell scope, driven start by start with a +# scratch config directory. A shell that dies in the same boot holds the +# widget back; a widget still loading when the system went down loads once +# more as a suspect and is held back after a second unclean end in a row; a +# clean run clears a suspect; a new hash starts over; a guard file from +# before the boot id keeps the strict rule; `quickshell kill` (a deliberate +# quit) clears what was still loading. Offscreen. Exits 77 without +# quickshell. +set -euo pipefail +here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) +command -v quickshell >/dev/null || { echo "widget-guard: no quickshell" >&2; exit 77; } + +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT +python3 - "$here/../plugins/omamobile.home/Home.qml" "$work/shell.qml" <<'PY' +import sys +s = open(sys.argv[1]).read() +a = s.index(' // Crash guard.') +b = s.index('\n }\n', s.index(' function guardEnd(')) + 4 +open(sys.argv[2], 'w').write('''import QtQuick +import Quickshell +import Quickshell.Io +Scope { + id: root + readonly property string configDir: Quickshell.env("GUARD_DIR") +''' + s[a:b] + ''' + Timer { + running: true; interval: 500 + onTriggered: (Quickshell.env("GUARD_ACT") || "").split(",").forEach(function(a) { + var p = a.split(":") + if (p[0] === "begin") root.guardBegin(p[1], p[2]) + if (p[0] === "end") root.guardEnd(p[1], true) + }) + } +} +''') +PY + +export QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software QML_DISABLE_DISK_CACHE=1 +n=0 rc=0 +dir= +fresh() { n=$((n + 1)); dir=$work/c$n; mkdir -p "$dir"; } +start() { GUARD_DIR=$dir GUARD_ACT=${1:-} timeout 2.5 quickshell -n -p "$work/shell.qml" >/dev/null 2>&1 || true; } +reboot() { python3 -c 'import json,sys; p=sys.argv[1]; d=json.load(open(p)); d["boot"]="another-boot"; json.dump(d, open(p, "w"))' "$dir/widget-guard.json"; } +expect() { + local got + got=$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(json.dumps([d.get("loading"), d.get("crashed"), d.get("suspect")], sort_keys=True))' "$dir/widget-guard.json") + [[ $got == "$2" ]] && echo "ok - $1" || { echo "not ok - $1: [loading, crashed, suspect] $got, want $2" >&2; rc=1; } +} + +fresh; start begin:w:h1; start +expect "a shell death in the same boot holds the widget back" '[{}, {"w": "h1"}, {}]' +fresh; start begin:w:h1; reboot; start +expect "loading when the system went down: a suspect, not a crash" '[{}, {}, {"w": "h1"}]' +start begin:w:h1; reboot; start +expect "a suspect still loading after a second unclean end is held back" '[{}, {"w": "h1"}, {}]' +fresh; start begin:w:h1; reboot; start begin:w:h1,end:w +expect "a clean run clears a suspect" '[{}, {}, {}]' +fresh; start begin:w:h1; reboot; start begin:w:h2; reboot; start +expect "a widget with new files starts over as a suspect" '[{}, {}, {"w": "h2"}]' +fresh; echo '{"loading": {"w": "h1"}, "crashed": {}}' > "$dir/widget-guard.json"; start +expect "a guard file without a boot id keeps the strict rule" '[{}, {"w": "h1"}, {}]' +fresh +GUARD_DIR=$dir GUARD_ACT=begin:w:h1 quickshell -n -p "$work/shell.qml" >/dev/null 2>&1 & +qs=$! +for _ in $(seq 1 40); do grep -c '"w"' "$dir/widget-guard.json" >/dev/null 2>&1 && break; sleep 0.1; done +quickshell kill --pid "$qs" >/dev/null 2>&1 || kill "$qs" +wait "$qs" 2>/dev/null || true +expect "a deliberate quit clears what was still loading" '[{}, {}, {}]' +exit $rc From ad914f3a8650a812cfefebabee0a5c31aac65a76 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 07:32:24 -0647 Subject: [PATCH 4/4] omamobile-shell test/widget-guard: give Quickshell a runtime directory when there is none Over an SSH login on the palmtop there was no XDG_RUNTIME_DIR, and Quickshell crashed at start because it could not create its instance directory. --- packages/omamobile-shell/test/widget-guard | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/omamobile-shell/test/widget-guard b/packages/omamobile-shell/test/widget-guard index cc537b7e3..abd01f7b9 100755 --- a/packages/omamobile-shell/test/widget-guard +++ b/packages/omamobile-shell/test/widget-guard @@ -40,6 +40,12 @@ Scope { PY export QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software QML_DISABLE_DISK_CACHE=1 +# Quickshell needs a runtime directory (for its instance files); a CI job +# or an SSH login may have none. +if [[ -z ${XDG_RUNTIME_DIR:-} || ! -w ${XDG_RUNTIME_DIR:-/nonexistent} ]]; then + export XDG_RUNTIME_DIR=$work/run + mkdir -m 700 -p "$XDG_RUNTIME_DIR" +fi n=0 rc=0 dir= fresh() { n=$((n + 1)); dir=$work/c$n; mkdir -p "$dir"; }