Let the Elsewhen migration carry on without a shell to ask

A bare `omarchy-shell shell rescanPlugins` exits 1 when no shell answers on the caller's tree, and omarchy-migrate runs migrations under `set -e`, so an update run from a TTY or over ssh, or one whose shell had gone down while the package replaced its QML, died at "omarchy-shell is not running" before its post-update hooks, shell restart and reboot prompt, and re-failed the same way every time until a shell could be asked. The rescan is now best-effort, like `omarchy-bar put` already is and like #11117 makes the plugin commands' closing rescan: the update restarts the shell once the migrations are through, and a session without one has no bar to place on. An unknown widget on a live shell still leaves the migration pending.
This commit is contained in:
Spencer Bull committed 2026-09-21 19:33:42 -05:00
1 parent b8c382da9e
commit 3208fe09ae
3 files changed
+36 -11

No files matched your search

@@ -18,7 +18,17 @@ SH
cat >"$test_dir/bin/omarchy-shell" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$CALL_LOG"
[[ $2 != "rescanPlugins" ]] || exit "${SCAN_STATUS:-0}"
quiet=0
if [[ $1 == "-q" ]]; then
quiet=1
shift
fi
if [[ ${SHELL_ABSENT:-0} == 1 ]]; then
(( quiet )) && exit 0
echo "omarchy-shell is not running" >&2
exit 1
fi
[[ $2 != "rescanPlugins" ]] || exit 0
printf '%s\n' "${TEST_PUT_RESULT:-ok}"
SH
cat >"$test_dir/bin/omarchy-restart-shell" <<'SH'
@@ -50,7 +60,7 @@ run_migration
[[ ! -e $ROOT/config/omarchy/plugins/omacom.elsewhen && ! -L $ROOT/config/omarchy/plugins/omacom.elsewhen ]] || fail "fresh installs do not ship a user plugin link"
pass "migration and fresh installs rely on the packaged plugin directory"
expected=$'package elsewhen\nshell rescanPlugins\nshell putBarWidget omacom.elsewhen {"before":"omarchy.clock"}'
expected=$'package elsewhen\n-q shell rescanPlugins\nshell putBarWidget omacom.elsewhen {"before":"omarchy.clock"}'
[[ $(cat "$CALL_LOG") == "$expected" ]] || fail "install, scan and placement run in order" "$(cat "$CALL_LOG")"
pass "real bar helper enables and places before the clock without restarting during reload"
@@ -80,10 +90,23 @@ run_migration "$ROOT"
[[ $(readlink "$plugin") == "$test_dir/custom-plugin" ]] || fail "existing symlink is preserved"
pass "existing symlink is preserved, including a missing target"
for failure in 'SCAN_STATUS=1' 'TEST_PUT_RESULT=unknown'; do
if env "$failure" HOME="$test_dir/home" OMARCHY_PATH="$ROOT" PATH="$test_dir/bin:$ROOT/bin:$PATH" \
bash -euo pipefail "$test_dir/migration.sh" >"$test_dir/output" 2>&1; then
fail "$failure must leave the migration pending"
fi
pass "$failure leaves the migration pending"
done
if env TEST_PUT_RESULT=unknown HOME="$test_dir/home" OMARCHY_PATH="$ROOT" PATH="$test_dir/bin:$ROOT/bin:$PATH" \
bash -euo pipefail "$test_dir/migration.sh" >"$test_dir/output" 2>&1; then
fail "an unknown widget must leave the migration pending"
fi
pass "an unknown widget leaves the migration pending"
# An update with no shell to ask, from a TTY or with the shell down, still
# finishes: the package and link land, the placement is skipped, and the update
# restarts the shell afterwards.
rm "$plugin"
: >"$CALL_LOG"
if ! env SHELL_ABSENT=1 OMARCHY_SHELL_ABSENT_ATTEMPTS=1 HOME="$test_dir/home" OMARCHY_PATH="$ROOT" PATH="$test_dir/bin:$ROOT/bin:$PATH" \
bash -euo pipefail "$test_dir/migration.sh" >"$test_dir/output" 2>&1; then
fail "an absent shell must not fail the migration" "$(cat "$test_dir/output")"
fi
grep -q "omacom.elsewhen was not put on the bar" "$test_dir/output" || fail "an absent shell is reported" "$(cat "$test_dir/output")"
[[ $(readlink "$plugin") == "$test_dir/packaged/shell/plugins/omacom.elsewhen" ]] || fail "the package and plugin link land without a shell"
[[ $(cat "$CALL_LOG") == "$expected" ]] || fail "the rescan is best-effort and the put is still asked" "$(cat "$CALL_LOG")"
pass "an absent shell leaves the update running with the package and link in place"