omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Updating a plugin reloads its bar widget but keeps its panel QML from the component cache

Open itsmoorgrove opened this issue 2 months ago • 6 comments

Updating a plugin reloads its bar widget but keeps its panel QML from the component cache

The README says:

Saving a file anywhere under ~/.config/omarchy/plugins/ reloads plugin code automatically; omarchy-shell shell rescanPlugins remains available to force a reload.

For a plugin's bar widget that holds. For the panel QML it does not: the shell logs Local plugin changed, reloading and rebuilds the widget, but the panel component stays in the QML engine's in-memory component cache and the old code goes on running until omarchy restart shell. omarchy plugin update, which calls rescanPlugins, has the same gap, so the documented update path leaves the user running the previous version with no indication that anything is stale.

Why it is more than cosmetic

The failure is silent and actively misleading. A user who updates a plugin specifically to pick up a fix sees the bug persist, and the shell log points at the new file with line numbers from the old one.

Concretely, from this machine earlier today. A plugin was updated from 0.4.1 to 0.4.2 at 12:29:15; the shell had been running since 10:22:33. The shell noticed the change:

DEBUG qml: Local plugin changed, reloading: io.github.itsmoorgrove.protoncalendar

and then logged this 20 times over the following minutes, while 0.4.2 was on disk:

WARN scene: file:///home/.../protoncalendar/Panel.qml[138:-1]: TypeError:
Cannot assign to read-only property "centerHoverRevealSuppressed"

Line 138 of the file on disk at that moment (0.4.2) is:

      root.bar.setCenterHoverRevealSuppressed(value)

a function call, which cannot raise that error. Line 138 of the previous version is:

      root.bar.centerHoverRevealSuppressed = value

So the engine was executing the old compiled unit while reporting positions against a file it was no longer running. Anyone debugging from that log is chasing a line that already contains the fix. omarchy restart shell cleared it immediately.

Reproduce

  1. Install any plugin that provides a panel, and open the panel once so the component is instantiated and cached.
  2. Change its panel QML — omarchy plugin update, or just edit the file in place.
  3. Open the panel again. The old behaviour is still there; the log shows Local plugin changed, reloading but the panel is unchanged.
  4. omarchy restart shell. The change appears.

Step 1 matters: the panel has to have been instantiated at least once for a stale copy of it to be held. I have reproduced the cached case reliably; I have not separately confirmed what happens when the panel was never opened before the change.

Suggestion

Either drop the cached component on rescanPlugins so the documented hot-reload covers panel QML as well as widgets, or, if that is not practical, have omarchy plugin update say that a shell restart is needed and soften the README claim. The current combination of a promise of automatic reload, a log line saying it reloaded, and stale code running is the part that costs people time.

Happy to test a patch.

Versions

  • omarchy 4.0.4-1 (/usr/share/omarchy/version reads 4.0.0.alpha)
  • quickshell 0.3.1-1
  • Hyprland v0.56.2
  • Arch

itsmoorgrove avatar Sep 21 '26 10:09 itsmoorgrove

Confirmed on Omarchy 4.0.4-1 while developing a local plugin cloned from omarchy.monitor. Symptom was subtle: I kept editing Panel.qml (added a new UI section, fixed a bug, added a plain test Button), the log dutifully printed Local plugin changed, reloading: <id> with no errors each time, but the already-open panel never reflected any of it — not even a brand-new, unconditionally-visible test button showed up. Console.log() calls added to the new code also never appeared in the shell log, which made it look like a completely different bug (I initially suspected event-delivery/input issues, not caching) until I closed the panel and ran a full omarchy restart shell — the new code (and the test button) appeared immediately.

Takeaway for anyone else debugging this: if you've had the panel open at all during your edit session, a clean omarchy restart shell is the reliable way to tell "is my code actually wrong" from "is this cache."

jarrodcolburn avatar Sep 22 '26 14:09 jarrodcolburn

On the open question in step 1, what happens when the panel was never opened before the change: the panel's own QML comes out new, but the plugin's service and any .js file the panel shares with it come out old. The new panel code then calls functions the old service and script don't have, so the panel throws TypeErrors instead of just showing the old behaviour.

We first saw this in a real session (Omarchy 4.0.4-1, quickshell 0.3.1-1, qt6-declarative 6.11.2-1). In our plugin, the service and an on-demand panel both import the same .js file. An update added a function to each, and the panel called both. On its first open after the reload, the panel threw these (function and plugin names replaced):

WARN qml: plugin <id> open() threw: TypeError: Property 'newServiceFn' of object Service_QMLTYPE_544(0x7a68aefbab20) is not a function
WARN scene: file://~/.config/omarchy/plugins/<id>/<Panel>.qml[272:-1]: TypeError: Property 'newSharedFn' of object [object Object] is not a function

[object Object] there is the panel's import qualifier for the shared .js. A later reload rebuilt the service at a new address with the same Service_QMLTYPE_544, and the errors kept coming until omarchy restart shell.

The script below reproduces it in plain qml6, with no shell and no plugin. It loads a service and leaves the panel unopened, rewrites all three files to v2, then reloads the way finishPluginReload() does (destroy, run the guarded cache clear, re-create). Finally it opens the panel for the first time:

REPRO 1 start:        service = service-v1 / shared-v1
REPRO 2 after reload: service = service-v1 / shared-v1 (typeof Qt.clearComponentCache: undefined)
REPRO 3 panel opened: panel-v2 | TypeError: Property 'newFeature' of object Service_QMLTYPE_3(0x5a7c58ef97d0) is not a function | TypeError: Property 'newFeature' of object [object Object] is not a function
REPRO 4 fresh engine: service = service-v2 / shared-v2

It was the same on 3 of 3 runs. The panel file has to exist before startup. A panel added after startup fails earlier, with File name case mismatch instead (#9772).

stale-mix-repro.sh
#!/bin/bash
# Omarchy plugin reload: a panel compiled for the first time after an update gets the NEW panel
# QML but the OLD service type and the OLD shared .js, so the new code calls functions that don't exist.
set -euo pipefail
dir=$(mktemp -d); trap 'rm -rf "$dir"' EXIT

# v1 of the plugin: a service, a panel (never opened before the update), a script both import.
printf 'function version() { return "shared-v1" }\n' > "$dir/Shared.js"
printf 'import QtQuick\nimport "Shared.js" as Shared\nItem { function version() { return "service-v1 / " + Shared.version() } }\n' > "$dir/Service.qml"
printf 'import QtQuick\nItem { property var service; function open() { return "panel-v1" } }\n' > "$dir/Panel.qml"

cat > "$dir/main.qml" <<'EOF'
import QtQuick
Item {
  id: root
  property var svc
  function make(f) {
    var c = Qt.createComponent(f, Component.PreferSynchronous)
    if (c.status !== Component.Ready) { console.log("ERR", c.errorString()); return null }
    return c.createObject(null)
  }
  Component.onCompleted: {
    svc = make("Service.qml")                      // shell start: service loaded, panel not opened
    console.log("REPRO 1 start:        service =", svc.version())
  }
  Timer {                                          // the files are rewritten (v2) while this waits
    interval: 2000; running: true
    onTriggered: {
      // The reload, as finishPluginReload() does it: destroy, (try to) clear the cache, re-create.
      root.svc.destroy()
      if (typeof Qt.clearComponentCache === "function") Qt.clearComponentCache()
      Qt.callLater(function () {
        var svc2 = root.make("Service.qml")
        console.log("REPRO 2 after reload: service =", svc2.version(),
                    "(typeof Qt.clearComponentCache:", typeof Qt.clearComponentCache + ")")
        var panel = root.make("Panel.qml")          // first open of the panel after the update
        panel.service = svc2
        console.log("REPRO 3 panel opened: " + panel.open())
        Qt.quit()
      })
    }
  }
}
EOF

QT_FORCE_STDERR_LOGGING=1 QT_QPA_PLATFORM=offscreen timeout 15 qml6 "$dir/main.qml" > "$dir/out.txt" 2>&1 &
sleep 1
# v2 of the plugin: the service, the script and the panel all gain newFeature().
printf 'function version() { return "shared-v2" }\nfunction newFeature() { return "ok" }\n' > "$dir/Shared.js"
printf 'import QtQuick\nimport "Shared.js" as Shared\nItem {\n  function version() { return "service-v2 / " + Shared.version() }\n  function newFeature() { return "ok" }\n}\n' > "$dir/Service.qml"
cat > "$dir/Panel.qml" <<'EOF'
import QtQuick
import "Shared.js" as Shared
Item {
  property var service
  function open() {
    var r = ["panel-v2"]
    try { r.push("service.newFeature() = " + service.newFeature()) } catch (e) { r.push(String(e)) }
    try { r.push("Shared.newFeature() = " + Shared.newFeature()) } catch (e) { r.push(String(e)) }
    return r.join(" | ")
  }
}
EOF
wait
sed -n 's/^qml: //p' "$dir/out.txt"

# Control: a fresh engine on the same files sees v2.
printf 'import QtQuick\nItem { Component.onCompleted: { var s = Qt.createComponent("Service.qml").createObject(null); console.log("REPRO 4 fresh engine: service =", s.version()); Qt.quit() } }\n' > "$dir/fresh.qml"
QT_FORCE_STDERR_LOGGING=1 QT_QPA_PLATFORM=offscreen timeout 15 qml6 "$dir/fresh.qml" 2>&1 | sed -n 's/^qml: //p'

For the fix, by the ?rev= measurements on #10568 and #10615, refreshing only the entry files leaves sibling imports cached, which is exactly this mix. The per-reload directory alias measured on #6981 also refreshed an imported Helper.js.

Until then, a plugin can protect itself: the panel checks the service for each member it calls, and when one is missing it asks the user to run omarchy restart shell instead of throwing.

Filed by Claude Opus 5.5 via Claude Code.

AsemHub avatar Oct 03 '26 11:10 AsemHub

Same here on Omarchy 4.0.4-1 / quickshell 0.3.1-1, with an overlay plugin that sets keepLoaded: true (io.github.houtvongsak.herdr-sessions).

Minimal repro: change a visible string in the plugin's overlay QML under ~/.config/omarchy/plugins/<id>/. The shell logs Local plugin changed, reloading (4 times here), but the overlay still shows the old string. It only shows the new one after omarchy-restart-shell.

The reverse direction breaks the plugin rather than just leaving it stale: removing a newer version and adding an older one (omarchy plugin remove then omarchy plugin add) kept the newer overlay QML running against the older files. That QML calls a helper script the older version doesn't ship, so the list came up empty with:

WARN: Process failed to start, likely because the binary could not be found. Command: QList(".../plugins/<id>/bin/herdr-sessions-data", "list")

Until this is fixed, our README tells users to run omarchy-restart-shell after omarchy plugin update.

houtvongsak avatar Oct 08 '26 04:10 houtvongsak

There's an open fix for this: #13911 ("Fix hot reload of local plugins by busting the component cache"). It would be great if one of the confirmers here could try it against their plugin, especially the case @AsemHub described (panel new, service/shared .js still old).

jandrusk avatar Oct 08 '26 13:10 jandrusk

Tried #13911 on Omarchy 4.0.4-1 / quickshell 0.3.1-1 (patch applied to a copy of /usr/share/omarchy/shell, shell launched from it).

Single-file overlay panel (keepLoaded: true, io.github.houtvongsak.herdr-sessions): ✅ fixed. Editing the entry QML updated the panel with no restart. Without the patch the same edit needs omarchy-restart-shell.

Panel importing a sibling .js (@AsemHub's case): throwaway overlay, Panel.qml with import "Lib.js" as Lib showing "panel-vN · " + Lib.marker():

  • edit both files → panel-v2 · js-v1: panel reloads, the .js stays old
  • then edit only Lib.js → still panel-v2 · js-v1

So that case is still stale, matching the limitation in the PR description. No errors in the journal during either reload.

Tested by Claude Opus 5.5.

houtvongsak avatar Oct 08 '26 13:10 houtvongsak

This is the same bug as #6981, so I'm closing it as a duplicate. Follow along there.

I checked it against current quattro (defbf90). Panels and overlays load through PluginRegistry.entryPointUrl() (shell/shell.qml:1332), the same way bar widgets (:1452) and services (:930) do. That function returns the same file:// URL however often the file changes. The only attempt to drop the compiled copy is if (typeof Qt.clearComponentCache === "function") Qt.clearComponentCache() in finishPluginReload() (shell/shell.qml:1527). That call never runs, because clearComponentCache exists only on the C++ QQmlEngine and not on the QML Qt object. So a rescan from the file watcher or from omarchy plugin update re-creates the panel from the copy it compiled before. #6981 reports the same dead guard and the same unchanged URL. There it shows up in bar widgets, services and overlays, and the panel here is one more place it shows.

The findings in this thread aren't lost, because #6981 already covers them. @AsemHub's mix of a new panel with an old service and old shared .js is the sibling-import case. @houtvongsak's test of #13911 showed that case still stale, and that matches the open-PR comparison in #6981. That comparison shows which fixes refresh entry points only and which also refresh sibling files. Choosing among those PRs is the maintainer's decision, and they are tracked there.

I read both reports and the reload path on quattro. Nothing ran on a worker, because nothing here needed reproducing. The bug is already confirmed on #6981 by several plugin authors. Codex Medium was asked separately, from the two reports alone, whether they are the same bug, and this issue is closed only because it agreed. If this turns out to be a different problem, it can be reopened.

omarchybot avatar Oct 12 '26 10:10 omarchybot