omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Plugin code under ~/.config/omarchy/plugins/ never hot-reloads: neither on save nor via rescanPlugins

Open kidskript3 opened this issue 2 months ago • 3 comments

What happened

shell/README.md documents two ways for plugin code under ~/.config/omarchy/plugins/ to take effect in the running shell:

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

Neither works here. The panel keeps rendering the previous code until omarchy restart shell.

The file watcher itself is fine — saving the file logs the reload:

DEBUG qml: Local plugin changed, reloading: <user>.monitor

…and the plugin registry rescans afterwards (the usual service-ready and handler-registration lines follow). The QML that is actually rendered does not change.

Steps to reproduce

  1. omarchy plugin clone omarchy.monitor
  2. In ~/.config/omarchy/plugins/<user>.monitor/Panel.qml, change the panel heading (line 611) from text: "Display" to text: "Display MARKER-A" and save.
  3. Open the panel (SUPER + CTRL + D) — heading still reads Display.
  4. omarchy-shell shell rescanPlugins, reopen — still Display.
  5. omarchy restart shell, reopen — now reads Display MARKER-A.

Steps 3 and 4 are the bug; step 5 is the workaround.

Why this one bites harder than a stale heading

The same staleness applies to omarchy plugin clone itself. After cloning, every tool reports the clone as the active plugin:

$ omarchy plugin list
omarchy.monitor      disabled  first-party  bar-widget  Display
<user>.monitor       enabled   third-party  bar-widget  My Display

…while the shell goes on executing the built-in component. Editing the clone appears to have no effect, and there is nothing in the UI or the CLI output pointing at a restart. I spent a while re-checking a patch that had been correct all along before a marker string showed me which copy was live.

Possible cause

Worth checking rather than a diagnosis — finishPluginReload() in shell/shell.qml:752 clears the component cache behind a feature test:

if (typeof Qt.clearComponentCache === "function") Qt.clearComponentCache()

If Qt.clearComponentCache is not exposed in Quickshell's QML environment, that test fails silently and pluginRegistry.rescan() re-instantiates the components from cache — which matches the symptom exactly: the reload runs end to end, and the old code survives it. ~/.cache/quickshell/qmlcache/ may be worth a look in the same breath.

System

  • Omarchy 4.0.2-1
  • Hyprland 0.56.2
  • Intel Core i7-12700H / NVIDIA RTX 3070 Ti Laptop GPU

Related

Found while patching the display panel locally for #10086.

kidskript3 avatar Sep 03 '26 23:09 kidskript3

Reproduced on a disposable Omarchy 4.0.2 worker (quickshell 0.3.1, quattro @ f99d33a8). Your "possible cause" is right, and it is measured rather than suspected now: Qt.clearComponentCache does not exist in QML, so the guard at shell/shell.qml:780 is always false and the one line in finishPluginReload() that exists to make the reload work never runs.

Two measurements from a standalone quickshell config on that worker:

  • typeof Qt.clearComponentCache is "undefined", and ("clearComponentCache" in Qt) is false.
  • With a QML file kept outside the quickshell config directory, so quickshell's own config watcher could not reload the engine, Qt.createComponent(url) returned MARKER-A; the file was then rewritten on disk to MARKER-B; four seconds later the same URL still returned MARKER-A.

And in the live shell, with a cloned bar-widget plugin carrying a probe object that logs on Component.onCompleted and on Component.onDestruction, saving an edit produced:

Local plugin changed, reloading: tester.monitor    (x4, one per inotify event)
HOTMARK v1 destroyed
HOTMARK v1 instantiated

while the file on disk read v2 throughout. omarchy-shell shell rescanPlugins produced the same pair. omarchy restart shell then logged HOTMARK v2 instantiated.

So everything except the cache is working. The widget is unregistered, the live instance really is destroyed, the registry rescans, Qt.createComponent runs again, and a new instance is built — it is just built from the compiled unit the engine cached the first time that URL was loaded. Nothing wedges and nothing reports a failure, because from the shell's point of view the reload succeeded.

One correction to the report: the shell is not running the built-in component after you clone. A brand-new third-party plugin directory dropped in while the shell was running instantiated its code immediately with no restart, because its URL had no cache entry yet. What is live after omarchy plugin clone is the clone's first compiled version, which is a byte-for-byte copy of the built-in, so a marker added after the clone cannot tell the two apart. omarchy plugin list was telling you the truth; what you were seeing was this same staleness from the first edit onwards.

This is the same defect as #6981, the oldest report of it, and #9772 states the Qt.clearComponentCache mechanism precisely. #10103, #9251, #8555 and the second half of #8202 share the root cause. #9999 is adjacent but carries a second blocker of its own: a service whose manifest sets keepLoaded: true is skipped entirely by unloadPluginServices() (shell/shell.qml:366-377) and is never rebuilt, which the same worker confirmed — the service probe logged neither a destruction nor an instantiation across a save or a rescanPlugins. #10023 is not a reload bug at all; it is clone-id resolution in serviceFor().

Four open PRs already work on this path — #7259, #7771, #8766, #9606 — and #10070 proposes deleting the dead guard and documenting the limitation instead. Which of those is the right answer turns on reload semantics the maintainer owns, so no competing fix has been filed from here; the comparison goes to them.

Reviewed twice: by Claude Opus 5 in Claude Code, and independently by Codex at xhigh reasoning. Where Codex agreed that the component cache is the cause here it was agreeing with a conclusion already written down, and its independence is not guaranteed. It contributed two things that were not: that registryRevision advances on every scan rather than only when a plugin changes, which matters to any fix based on versioned URLs, and that shell/plugins/notifications/Service.qml:933 already sets keepOnReload: false, so that service was built to be rebuilt.

omarchybot avatar Sep 04 '26 13:09 omarchybot

Same symptom here on 4.0.2-1 (quickshell 0.3.1-1), with one detail neither this issue nor #10103 mentions: it worked first, then stopped.

Building a third-party plugin (service + bar-widget, in ~/.config/omarchy/plugins/), the first several saves reloaded correctly — I could see it, because the service keeps an incrementing session id that resets when the object is recreated, and a behaviour change (an expiry that went from landing within 5 s to landing within 1 s) took effect on save. Then, part way through the session, saves stopped taking effect and never resumed. omarchy-shell shell rescanPlugins did nothing. omarchy-restart-shell applied everything, every time.

That transition is hard to square with the Qt.clearComponentCache theory above: a cache that is never cleared would keep the first version alive from the first edit, not swap in four or five of them and then freeze. It reads more like a latch in the reload path that gets set and never cleared.

Two candidates, both in the same path:

// shell.qml
function reloadPlugins() {
  if (shell.pluginReloading || shell.pluginRegistry.scanning) {
    shell.pluginReloadPending = true
    return
  }
  ...
}

// PluginRegistry.qml
function rescan() {
  if (scanning) return
  scanning = true
  ...
}

pluginReloading is only ever cleared in onScanFinished, and scanning is only cleared when the scan process finishes. So a scan that never emits scanFinished leaves both rescan() and every later reloadPlugins() as silent no-ops — which would also explain why the documented escape hatch is dead, since rescanPlugins IPC routes straight into reloadPlugins(). Nothing times out or retries, so the shell stays in that state until it is restarted.

I did not capture either flag at the time (no IPC exposes them), so this is a hypothesis that fits the transition rather than a confirmed cause. A marker logged at the top of reloadPlugins() and rescan() would separate it from the cache theory quickly: if the stuck state logs the entry but never reaches Qt.clearComponentCache(), it is the latch.

One corroboration for #10103's note about a Process that never spawned: I hit that too — a Process { running: true } added to the service never ran across several saves, and ran on the first restart. I spent a while treating it as a declarative-running problem before a marker string showed me the code was simply stale, which is the same trap this issue describes.

Two things that would have saved the time regardless of the cause: a timeout on scanning, and rescanPlugins returning something other than silence when it declines to do anything.

chadmandoo avatar Sep 04 '26 13:09 chadmandoo

Automated duplication check: this issue looks similar to #6981, which covers the same plugin hot reload ignores QML edits. I keep that one open and close this one to keep the discussion in one place.

If you feel this is the wrong decision, please open the issue again with a note on the difference.

bjarneo avatar Sep 20 '26 20:09 bjarneo