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:
co-authored by
Claude Opus 5
parent
0d45f0979b
commit
3d1914a8cd
@@ -193,6 +193,16 @@ QtObject {
|
||||
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) {
|
||||
if (!Util.isPlainObject(config)) return { found: false }
|
||||
var key = Util.canonicalWidgetId(String(id))
|
||||
@@ -218,7 +228,7 @@ QtObject {
|
||||
? String(target.section) : fallbackSection
|
||||
var relativeId = String(target.before || target.after || "")
|
||||
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 }
|
||||
return {
|
||||
section: relative.section,
|
||||
@@ -233,7 +243,7 @@ QtObject {
|
||||
}
|
||||
|
||||
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 {
|
||||
section: section,
|
||||
index: anchor.found ? anchor.index + 1 : config.bar.layout[section].length
|
||||
@@ -281,6 +291,29 @@ QtObject {
|
||||
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) {
|
||||
var error = ""
|
||||
shellConfigMutator(function(config) {
|
||||
@@ -436,7 +469,7 @@ QtObject {
|
||||
|
||||
if (value && placement && (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
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user