Let bar put place a widget on a bar it does not recognize (#6687)

* Place a bar widget on a bar without the widget it names

'omarchy bar put X --after Y' refused outright when Y was not on the bar, so
migration 1786279107 failed for every user whose clock is their own clone of
omarchy.clock rather than the built-in, and took the rest of the migration
chain down with it. put is the verb a migration or an install reaches for
precisely because it cannot know what the bar it places into looks like, so it
now falls back to the widget's usual spot instead of failing. 'plugin enable',
which someone types, still says when it cannot find the target.

A clone also answers as a placement target now, whether it is the widget the
placement named or the anchor the fallback lands against: cloning the clock
leaves a bar carrying your id where omarchy.clock used to be, and a caller
naming the source means the clone that took its place, the way resolveEnabledId
already routes calls to it. So the widget sits next to that clock rather than
at the end of the section.

Fixes #6678

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Keep asking a shell that is still starting

An 'omarchy update' landing while the shell restarts failed migration
1786279107 twice over. Quickshell answers a call made before it finishes
loading with "Not ready to accept queries yet." on stdout and exits 0, so a
caller polling with a ping read a starting shell as up and then took that
sentence for the answer to its real call; report it as unreachable, which every
caller already knows how to handle, and omarchy-restart-shell stops cutting its
readiness loop short on it too.

Reading the plugin manifests is a subprocess behind that, so IPC starts
answering before the registry knows the widget it is being asked to place, and
put refused it as unknown. Say which of the two it is and let put keep asking.

Only a shell that was never there is nothing to fail over. One that never
finishes starting, one that stops responding, one too old to know the call at
all: each has to fail, since omarchy-migrate records a migration that returns 0
as done, and the widget is then never placed and never asked for again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Fall back for the shell an update has not restarted yet

omarchy-update runs its migrations before omarchy-update-restart, so the shell
answering migration 1786279107 on the update that carries this fix is still the
one that shipped without it, and it refuses the placement exactly as before.
The users this is for would have watched one more update go wrong. put owns the
fallback it documents, so let the command carry it: asked again without the
neighbour the shell says it cannot find, that shell places the widget.

A restarted shell never answers this way — it falls back itself, and knows to
look for a clone of the widget the placement named, which the command cannot.

Having answered once is now remembered across both asks. A shell that speaks
and is then gone has stopped mid-request, and reading that as a machine that
never had one would leave the migration recorded as done.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Wait for a shell that has not appeared yet

A shell being spawned has no socket to answer on, and nothing tells the command
a launch is under way, so a put landing in that window read the silence as a
machine without a shell and carried on — leaving the migration recorded as done
with nothing placed. Give one three seconds to turn up first. A machine that
genuinely has no shell still carries on, three seconds later.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Leave a clone of the widget being put where it is

A clone is the widget it was cloned from wearing its owner's name, so a bar
carrying one already has what put is being asked to place. put only saw the
literal id, and enabling a first-party source whose clone is active is how you
switch back to the built-in — so a migration placing omarchy.keyboard-layout
would have handed a user's own copy back for the shipped one, and called it
done. Targeting learned to read a clone as its source; presence had not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Trim the comments on the bar put path

Roughly a line of comment per line of code, most of it restating what the code
and the assertion messages already say.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-08-11 11:07:14 +02:00
committed by GitHub
co-authored by Claude Opus 5
parent 0d45f0979b
commit 3d1914a8cd
7 changed files with 347 additions and 18 deletions
+47 -13
View File
@@ -35,8 +35,9 @@ Placement:
Enable and disable widgets with 'omarchy plugin enable' and Enable and disable widgets with 'omarchy plugin enable' and
'omarchy plugin disable'. 'omarchy plugin disable'.
'put' looks for --before / --after within the section it is adding to, and 'put' places a widget the way 'plugin enable' does, but leaves one that is
falls back to the end of that section when the named widget is not there. already on the bar where it is, and falls back to the widget's usual spot when
--before / --after names a widget the bar does not carry.
Examples: Examples:
omarchy bar use local.neon-bar omarchy bar use local.neon-bar
@@ -229,6 +230,38 @@ bar_widget_default_section() {
' <<<"$catalog" ' <<<"$catalog"
} }
# Asks the shell to place a widget, waiting out one still coming up. Answers 0
# with the reply in PUT_RESULT, 1 when there was no shell to ask. Only an
# absent shell is carried on from: omarchy-migrate marks a 0 return as done.
PUT_RESULT=""
SHELL_ANSWERED=0
ask_to_put() {
local id="$1" placement="$2" attempt absent=0
for (( attempt = 0; attempt < ${OMARCHY_SHELL_READY_ATTEMPTS:-50}; attempt++ )); do
if PUT_RESULT=$(omarchy-shell shell putBarWidget "$id" "$placement" 2>&1); then
SHELL_ANSWERED=1
[[ $PUT_RESULT == "not ready" ]] || return 0
elif [[ $PUT_RESULT == *"not ready"* ]]; then
SHELL_ANSWERED=1
elif [[ $PUT_RESULT == *"is not running"* ]]; then
# Answered once and now gone: it stopped mid-request.
if (( SHELL_ANSWERED )); then
fail "omarchy-shell did not become ready; $id was not put on the bar"
fi
# A shell being spawned has no socket yet, and nothing says a launch is
# under way, so give one a few seconds to turn up.
if (( ++absent >= ${OMARCHY_SHELL_ABSENT_ATTEMPTS:-30} )); then
echo "omarchy-shell is not running; $id was not put on the bar" >&2
return 1
fi
else
fail "could not put $id on the bar: $PUT_RESULT"
fi
sleep 0.1
done
fail "omarchy-shell did not become ready; $id was not put on the bar"
}
# Placement lives in the shell, which owns the config it has in memory. Putting # Placement lives in the shell, which owns the config it has in memory. Putting
# a widget therefore asks the shell rather than editing the file behind it. # a widget therefore asks the shell rather than editing the file behind it.
cmd_put() { cmd_put() {
@@ -250,19 +283,20 @@ cmd_put() {
[[ -z $PLACEMENT_FROM_SECTION && -z $PLACEMENT_FROM_INDEX ]] || [[ -z $PLACEMENT_FROM_SECTION && -z $PLACEMENT_FROM_INDEX ]] ||
fail "put does not accept --from-section or --from-index" fail "put does not accept --from-section or --from-index"
# Nothing to place into with no shell to place it, and a caller that runs local placement
# unattended should say so and carry on rather than fail. A shell that is placement=$(placement_json)
# there and refuses is a real error. ask_to_put "$id" "$placement" || return 0
if ! omarchy-shell shell ping >/dev/null 2>&1; then
echo "omarchy-shell is not running; $id was not put on the bar" >&2 # An update runs migrations before it restarts the shell, so this one can
return 0 # predate the fallback. Ask it again without the neighbour it cannot find.
if [[ $PUT_RESULT == "could not find target widget"* ]]; then
PLACEMENT_BEFORE=""
PLACEMENT_AFTER=""
ask_to_put "$id" "$(placement_json)" || return 0
fi fi
local result [[ $PUT_RESULT != "unknown" ]] || fail "$id is not a known widget; run 'omarchy plugin list'"
result=$(omarchy-shell shell putBarWidget "$id" "$(placement_json)") || [[ $PUT_RESULT == "ok" ]] || fail "$PUT_RESULT"
fail "could not put $id on the bar"
[[ $result != "unknown" ]] || fail "$id is not a known widget; run 'omarchy plugin list'"
[[ $result == "ok" ]] || fail "$result"
# Says nothing about whether it had to be placed: a widget already on the bar # Says nothing about whether it had to be placed: a widget already on the bar
# is left where it is, and both outcomes are the same answer to the caller. # is left where it is, and both outcomes are the same answer to the caller.
echo "$id is on the bar" echo "$id is on the bar"
+5
View File
@@ -69,6 +69,11 @@ case $output in
"Target not found." | "Function not found." | "Too few arguments provided"* | "Too many arguments provided"*) "Target not found." | "Function not found." | "Too few arguments provided"* | "Too many arguments provided"*)
fail "$output" fail "$output"
;; ;;
# A starting shell answers on stdout and exits 0, so a ping reads it as up
# and the next call's answer as a result. It is as unreachable as none.
"Not ready to accept queries yet"*)
fail "omarchy-shell is not ready"
;;
esac esac
if (( !QUIET )) && [[ -n $output ]]; then if (( !QUIET )) && [[ -n $output ]]; then
+36 -3
View File
@@ -193,6 +193,16 @@ QtObject {
return { found: false } return { found: false }
} }
// A caller naming a widget that has been cloned means the clone that took
// its place, the way resolveEnabledId routes calls to it.
function findRelativeBarLocation(config, id, section) {
var location = findBarLocation(config, id, section)
if (location.found) return location
if (!Util.isPlainObject(config) || !Util.isPlainObject(config.bar)) return { found: false }
var clone = activeCloneFor(config, Util.canonicalWidgetId(String(id)))
return clone ? findBarLocation(config, clone, section) : { found: false }
}
function findEntryLocation(config, id) { function findEntryLocation(config, id) {
if (!Util.isPlainObject(config)) return { found: false } if (!Util.isPlainObject(config)) return { found: false }
var key = Util.canonicalWidgetId(String(id)) var key = Util.canonicalWidgetId(String(id))
@@ -218,7 +228,7 @@ QtObject {
? String(target.section) : fallbackSection ? String(target.section) : fallbackSection
var relativeId = String(target.before || target.after || "") var relativeId = String(target.before || target.after || "")
if (relativeId) { if (relativeId) {
var relative = findBarLocation(config, relativeId, section && target.section ? section : "") var relative = findRelativeBarLocation(config, relativeId, section && target.section ? section : "")
if (!relative.found) return { error: "could not find target widget " + relativeId } if (!relative.found) return { error: "could not find target widget " + relativeId }
return { return {
section: relative.section, section: relative.section,
@@ -233,7 +243,7 @@ QtObject {
} }
var anchors = { left: "omarchy.workspaces", center: "omarchy.weather", right: "omarchy.tray" } var anchors = { left: "omarchy.workspaces", center: "omarchy.weather", right: "omarchy.tray" }
var anchor = findBarLocation(config, anchors[section], section) var anchor = findRelativeBarLocation(config, anchors[section], section)
return { return {
section: section, section: section,
index: anchor.found ? anchor.index + 1 : config.bar.layout[section].length index: anchor.found ? anchor.index + 1 : config.bar.layout[section].length
@@ -281,6 +291,29 @@ QtObject {
return "" return ""
} }
// put is the unattended verb: where enable errors, it falls back, and it
// leaves a widget that is already on the bar where its owner put it.
function putBarWidget(id, placement) {
if (inBar(id)) return ""
var config = shellConfigProvider ? shellConfigProvider() : null
// Enabling a source whose clone is active switches back to the built-in,
// which is the owner's call, not an unattended caller's.
if (findRelativeBarLocation(config, id, "").found) return ""
// The manifest scan is a subprocess and IPC answers before it returns, so
// an id it has not reached yet is not one that does not exist.
if (scanning && !installedPlugins[Util.canonicalWidgetId(String(id))]) return "not ready"
var target = Util.isPlainObject(placement) ? Util.cloneJson(placement) : {}
var relativeId = String(target.before || target.after || "")
if (relativeId) {
if (!findRelativeBarLocation(config, relativeId, String(target.section || "")).found) {
delete target.before
delete target.after
}
}
if (setEnabled(id, true, target)) return ""
return lastEnableError || "unknown"
}
function setBarWidget(id, key, value, selector) { function setBarWidget(id, key, value, selector) {
var error = "" var error = ""
shellConfigMutator(function(config) { shellConfigMutator(function(config) {
@@ -436,7 +469,7 @@ QtObject {
if (value && placement && (placement.before || placement.after)) { if (value && placement && (placement.before || placement.after)) {
var relativeId = String(placement.before || placement.after) var relativeId = String(placement.before || placement.after)
if (!findBarLocation(config, relativeId, String(placement.section || "")).found) { if (!findRelativeBarLocation(config, relativeId, String(placement.section || "")).found) {
lastEnableError = "could not find target widget " + relativeId lastEnableError = "could not find target widget " + relativeId
return return
} }
+6 -2
View File
@@ -921,8 +921,12 @@ ShellRoot {
// Enable, but only where the widget is not on the bar already, so a caller // Enable, but only where the widget is not on the bar already, so a caller
// that cannot know whether it ran before leaves a placed widget alone. // that cannot know whether it ran before leaves a placed widget alone.
function putBarWidget(id: string, placementJson: string): string { function putBarWidget(id: string, placementJson: string): string {
if (shell.pluginRegistry.inBar(id)) return "ok" try {
return enablePlugin(id, placementJson) var error = shell.pluginRegistry.putBarWidget(id, JSON.parse(placementJson || "{}"))
return error ? error : "ok"
} catch (e) {
return "invalid placement: " + e
}
} }
function moveBarWidget(id: string, placementJson: string): string { function moveBarWidget(id: string, placementJson: string): string {
+137
View File
@@ -22,6 +22,13 @@ const shellSource = fs.readFileSync(root + '/shell/shell.qml', 'utf8')
assert(/function toggleBarTransparency\(\): string \{[\s\S]*?shell\.bar\.toggleTransparency\(\)/.test(shellSource), 'shell exposes the bar transparency toggle over IPC') assert(/function toggleBarTransparency\(\): string \{[\s\S]*?shell\.bar\.toggleTransparency\(\)/.test(shellSource), 'shell exposes the bar transparency toggle over IPC')
// put tolerates a placement target the bar does not carry, so the IPC call
// must reach the registry's put rather than route back through enable.
assert(
/function putBarWidget\(id: string, placementJson: string\): string \{[\s\S]*?shell\.pluginRegistry\.putBarWidget\(/.test(shellSource),
'putting a bar widget over IPC goes through the registry put'
)
// Hiding must not unmap the bar. An unmapped layer surface has to be rebuilt on // Hiding must not unmap the bar. An unmapped layer surface has to be rebuilt on
// every reveal, which measured ~150ms against ~20ms to tear it down; parking it // every reveal, which measured ~150ms against ~20ms to tear it down; parking it
// past the screen edge keeps show and hide symmetric at ~12ms. // past the screen edge keeps show and hide symmetric at ~12ms.
@@ -315,3 +322,133 @@ assertEqual(
'bar builds default custom module paths' 'bar builds default custom module paths'
) )
JS JS
put_tmp=$(mktemp -d)
trap 'rm -rf "$put_tmp"' EXIT
mkdir -p "$put_tmp/bin"
ln -s "$ROOT/bin/omarchy-shell-config" "$put_tmp/bin/omarchy-shell-config"
cat >"$put_tmp/bin/omarchy-shell" <<'STUB'
#!/bin/bash
case ${OMARCHY_TEST_SHELL_STATE:-ready} in
missing)
echo "omarchy-shell is not running" >&2
exit 1
;;
starting)
echo "omarchy-shell is not ready" >&2
exit 1
;;
crashing)
# Seen coming up, then gone.
if [[ -e $OMARCHY_TEST_SHELL_MARKER ]]; then
echo "omarchy-shell is not running" >&2
else
touch "$OMARCHY_TEST_SHELL_MARKER"
echo "omarchy-shell is not ready" >&2
fi
exit 1
;;
oldshell)
# A shell from before put learned to fall back.
if [[ $4 == *"after"* ]]; then
echo "could not find target widget omarchy.clock"
else
echo "ok"
fi
exit 0
;;
spawning)
# Launched, but with no socket to answer on yet.
if [[ ! -e $OMARCHY_TEST_SHELL_MARKER ]]; then
touch "$OMARCHY_TEST_SHELL_MARKER"
echo "omarchy-shell is not running" >&2
exit 1
fi
;;
vanishing)
# Answers the first ask, then is gone before the fallback lands.
if [[ ! -e $OMARCHY_TEST_SHELL_MARKER ]]; then
touch "$OMARCHY_TEST_SHELL_MARKER"
echo "could not find target widget omarchy.clock"
exit 0
fi
echo "omarchy-shell is not running" >&2
exit 1
;;
unsupported)
# An older shell that predates this call.
echo "Function not found." >&2
exit 1
;;
scanning)
# Answering IPC, but has not read the plugins yet.
if [[ ! -e $OMARCHY_TEST_SHELL_MARKER ]]; then
touch "$OMARCHY_TEST_SHELL_MARKER"
echo "not ready"
exit 0
fi
;;
esac
echo "ok"
STUB
chmod +x "$put_tmp/bin/omarchy-shell"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=missing \
OMARCHY_SHELL_ABSENT_ATTEMPTS=2 \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) ||
fail "put carries on when no shell is running" "$put_output"
[[ $put_output == *"is not running"* ]] || fail "put says why it placed nothing" "$put_output"
pass "put carries on when no shell is running"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=spawning \
OMARCHY_TEST_SHELL_MARKER="$put_tmp/spawned" \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) ||
fail "put waits for a shell that is being spawned" "$put_output"
[[ $put_output == "omarchy.keyboard-layout is on the bar" ]] || fail "put places once the shell answers" "$put_output"
pass "put waits for a shell that is being spawned"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=starting OMARCHY_SHELL_READY_ATTEMPTS=2 \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) &&
fail "put fails when the shell never becomes ready" "$put_output"
[[ $put_output == *"did not become ready"* ]] || fail "put says the shell never became ready" "$put_output"
pass "put fails when the shell never becomes ready"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=crashing \
OMARCHY_TEST_SHELL_MARKER="$put_tmp/started" \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) &&
fail "put fails when a starting shell disappears" "$put_output"
[[ $put_output == *"did not become ready"* ]] || fail "put keeps a lost shell retryable" "$put_output"
pass "put fails when a starting shell disappears"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=oldshell \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) ||
fail "put falls back against a shell that has not restarted yet" "$put_output"
[[ $put_output == "omarchy.keyboard-layout is on the bar" ]] || fail "put places without the missing neighbour" "$put_output"
pass "put falls back against a shell that has not restarted yet"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=vanishing \
OMARCHY_TEST_SHELL_MARKER="$put_tmp/vanished" \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) &&
fail "put fails when the shell goes away mid-fallback" "$put_output"
[[ $put_output == *"did not become ready"* ]] || fail "put remembers the shell answered once" "$put_output"
pass "put fails when the shell goes away mid-fallback"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=unsupported \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) &&
fail "put fails when the shell cannot answer the call" "$put_output"
[[ $put_output == *"Function not found"* ]] || fail "put passes on what the shell said" "$put_output"
pass "put fails when the shell cannot answer the call"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" OMARCHY_TEST_SHELL_STATE=scanning \
OMARCHY_TEST_SHELL_MARKER="$put_tmp/scanned" \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) ||
fail "put asks again while the shell is still reading its plugins" "$put_output"
[[ $put_output == "omarchy.keyboard-layout is on the bar" ]] || fail "put places once the plugins are read" "$put_output"
pass "put asks again while the shell is still reading its plugins"
put_output=$(PATH="$put_tmp/bin:$ROOT/bin:$PATH" \
"$ROOT/bin/omarchy-bar" put omarchy.keyboard-layout --after omarchy.clock 2>&1) ||
fail "put places a widget through a ready shell" "$put_output"
[[ $put_output == "omarchy.keyboard-layout is on the bar" ]] || fail "put reports the placed widget" "$put_output"
pass "put places a widget through a ready shell"
@@ -90,6 +90,9 @@ ShellRoot {
var localWidget = manifest("local.first-widget", ["bar-widget"], { barWidget: "Widget.qml" }) var localWidget = manifest("local.first-widget", ["bar-widget"], { barWidget: "Widget.qml" })
localWidget.omarchy = { clonedFrom: "omarchy.first-widget" } localWidget.omarchy = { clonedFrom: "omarchy.first-widget" }
scan += block("thirdparty", "/third/local-widget", localWidget) scan += block("thirdparty", "/third/local-widget", localWidget)
var localWeather = manifest("local.weather", ["bar-widget"], { barWidget: "Widget.qml" })
localWeather.omarchy = { clonedFrom: "omarchy.weather" }
scan += block("thirdparty", "/third/local-weather", localWeather)
var localHybrid = manifest("local.hybrid", ["menu", "bar-widget"], { menu: "Menu.qml", barWidget: "Widget.qml" }) var localHybrid = manifest("local.hybrid", ["menu", "bar-widget"], { menu: "Menu.qml", barWidget: "Widget.qml" })
localHybrid.omarchy = { clonedFrom: "omarchy.hybrid" } localHybrid.omarchy = { clonedFrom: "omarchy.hybrid" }
scan += block("thirdparty", "/third/local-hybrid", localHybrid) scan += block("thirdparty", "/third/local-hybrid", localHybrid)
@@ -115,6 +118,7 @@ ShellRoot {
"local.first-widget", "local.first-widget",
"local.grouped-panel", "local.grouped-panel",
"local.hybrid", "local.hybrid",
"local.weather",
"omarchy.bar", "omarchy.bar",
"omarchy.first-widget", "omarchy.first-widget",
"omarchy.grouped-panel", "omarchy.grouped-panel",
@@ -212,6 +216,101 @@ ShellRoot {
registry.setEnabled("third.widget", true, { section: "right", index: 0 }) registry.setEnabled("third.widget", true, { section: "right", index: 0 })
root.assertDeepEqual(root.config.bar.layout.right, [{ id: "third.widget" }], "enabling with placement is one registry transition") root.assertDeepEqual(root.config.bar.layout.right, [{ id: "third.widget" }], "enabling with placement is one registry transition")
// A bar the placement's neighbour is not on still gets the widget.
root.config = {
version: 1,
bar: { layout: { left: [], center: [{ id: "omarchy.weather" }], right: [] } },
plugins: []
}
root.assertTrue(
!registry.setEnabled("third.center-widget", true, { after: "omarchy.first-widget" }),
"enabling against a widget the bar does not carry is refused"
)
root.assertEqual(
registry.lastEnableError,
"could not find target widget omarchy.first-widget",
"a refused enable names the target it could not find"
)
root.assertDeepEqual(root.config.bar.layout.center, [{ id: "omarchy.weather" }], "a refused enable places nothing")
root.assertEqual(
registry.putBarWidget("third.center-widget", { after: "omarchy.first-widget" }),
"",
"put accepts a placement target the bar does not carry"
)
root.assertDeepEqual(
root.config.bar.layout.center,
[{ id: "omarchy.weather" }, { id: "third.center-widget" }],
"put falls back to the section anchor when its target is missing"
)
// The anchor sits after the clone, so a fallback would land elsewhere.
root.config = {
version: 1,
bar: { layout: { left: [], center: [{ id: "local.first-widget" }, { id: "omarchy.weather" }], right: [] } },
plugins: []
}
root.assertEqual(
registry.putBarWidget("third.center-widget", { after: "omarchy.first-widget" }),
"",
"put places against a target that has been cloned"
)
root.assertDeepEqual(
root.config.bar.layout.center,
[{ id: "local.first-widget" }, { id: "third.center-widget" }, { id: "omarchy.weather" }],
"a clone stands in for the widget it was cloned from as a placement target"
)
// The anchor a fallback lands against is as clonable as the target.
root.config = {
version: 1,
bar: { layout: { left: [], center: [{ id: "local.weather" }, { id: "omarchy.clock" }], right: [] } },
plugins: []
}
root.assertEqual(
registry.putBarWidget("third.center-widget", { after: "omarchy.first-widget" }),
"",
"put falls back past a cloned anchor"
)
root.assertDeepEqual(
root.config.bar.layout.center,
[{ id: "local.weather" }, { id: "third.center-widget" }, { id: "omarchy.clock" }],
"a cloned anchor still anchors the section it was cloned into"
)
root.config = {
version: 1,
bar: { layout: { left: [{ id: "third.center-widget", size: 2 }], center: [], right: [] } },
plugins: []
}
root.assertEqual(registry.putBarWidget("third.center-widget", { section: "right" }), "", "put accepts a widget that is already on the bar")
root.assertDeepEqual(
root.config.bar.layout.left,
[{ id: "third.center-widget", size: 2 }],
"put leaves a widget that is already on the bar where its owner put it"
)
root.assertDeepEqual(root.config.bar.layout.right, [], "put adds no second entry for a widget already on the bar")
root.assertEqual(registry.putBarWidget("third.absent", {}), "unknown", "put reports a widget it does not know")
root.config = {
version: 1,
bar: { layout: { left: [], center: [{ id: "local.first-widget", size: 5 }], right: [] } },
plugins: []
}
root.assertEqual(registry.putBarWidget("omarchy.first-widget", {}), "", "put accepts a widget whose clone is on the bar")
root.assertDeepEqual(
root.config.bar.layout.center,
[{ id: "local.first-widget", size: 5 }],
"put leaves a clone of the widget it was asked to place alone"
)
// Refusing an id the scan has not reached would fail the migration.
root.config = { version: 1, bar: { layout: { left: [], center: [], right: [] } }, plugins: [] }
registry.scanning = true
root.assertEqual(registry.putBarWidget("third.absent", {}), "not ready", "put waits for a scan that has not reached its widget")
root.assertDeepEqual(root.config.bar.layout.center, [], "put places nothing while it is still waiting")
root.assertEqual(registry.putBarWidget("third.center-widget", {}), "", "put places a widget the scan has already read")
registry.scanning = false
root.config = { root.config = {
version: 1, version: 1,
bar: { layout: { left: [], center: [{ id: "omarchy.first-widget", size: 4 }], right: [] } }, bar: { layout: { left: [], center: [{ id: "omarchy.first-widget", size: 4 }], right: [] } },
+17
View File
@@ -27,6 +27,8 @@ cat >"$wrapper_bin/qs" <<'SH'
if [[ ${OMARCHY_TEST_QS_HANG:-0} == 1 ]]; then if [[ ${OMARCHY_TEST_QS_HANG:-0} == 1 ]]; then
sleep 5 sleep 5
elif [[ ${OMARCHY_TEST_QS_STARTING:-0} == 1 ]]; then
printf 'Not ready to accept queries yet.\n'
else else
printf 'ok\n' printf 'ok\n'
fi fi
@@ -41,6 +43,21 @@ wrapper_error=$(PATH="$wrapper_bin:$PATH" \
[[ $wrapper_error == "omarchy-shell is not responding" ]] || fail "hung shell IPC reports that the shell is unresponsive" "$wrapper_error" [[ $wrapper_error == "omarchy-shell is not responding" ]] || fail "hung shell IPC reports that the shell is unresponsive" "$wrapper_error"
pass "shell IPC calls time out when Quickshell is unresponsive" pass "shell IPC calls time out when Quickshell is unresponsive"
# A starting shell answers on stdout and exits 0, so a ping reads it as up.
wrapper_error=$(PATH="$wrapper_bin:$PATH" \
OMARCHY_PATH="$wrapper_root" \
OMARCHY_TEST_QS_STARTING=1 \
"$ROOT/bin/omarchy-shell" shell ping 2>&1) && fail "a starting shell answers IPC calls with a failure"
[[ $wrapper_error == "omarchy-shell is not ready" ]] || fail "a starting shell reports that it is not ready" "$wrapper_error"
pass "shell IPC calls fail while Quickshell is still starting"
PATH="$wrapper_bin:$PATH" \
OMARCHY_PATH="$wrapper_root" \
OMARCHY_TEST_QS_STARTING=1 \
"$ROOT/bin/omarchy-shell" -q shell ping >/dev/null 2>&1 ||
fail "quiet best-effort IPC calls tolerate a starting shell"
pass "quiet best-effort IPC calls tolerate a starting shell"
wrapper_args="$test_tmp/wrapper-args" wrapper_args="$test_tmp/wrapper-args"
PATH="$wrapper_bin:$PATH" \ PATH="$wrapper_bin:$PATH" \
OMARCHY_PATH="$wrapper_root" \ OMARCHY_PATH="$wrapper_root" \