omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Bar widget plugin QML changes don't hot-reload (requires full shell restart)

Open vlaktaks opened this issue 3 months ago • 4 comments

Summary

Editing a bar-widget plugin's .qml under ~/.config/omarchy/plugins/<id>/ is detected (the watcher fires and the shell re-registers the plugin), but the widget keeps rendering the OLD compiled QML until a full omarchy restart shell. The saved changes never take effect without restarting the whole shell.

Expected

Saving a file under ~/.config/omarchy/plugins/ reloads plugin code automatically (per the docs), so the bar widget reflects the change immediately.

Actual

Each edit requires omarchy restart shell to become active.

Root cause

shell.qml relies on Qt.clearComponentCache before rebuilding plugins:

// shell.qml:757
if (typeof Qt.clearComponentCache === "function") Qt.clearComponentCache()

In the Arch quickshell 0.3.1 package, Qt.clearComponentCache is not exposed to QML, so the guard is false and the component cache is never cleared. The plugin is re-registered, but the cached, compiled QML is re-used → old widget stays until a full restart naturally drops the cache.

Evidence

  • qt6 quickshell 0.3.1-1 (packager: [email protected])
  • strings /usr/bin/quickshell | grep clearComponentCache -> no match
  • /usr/lib/qt6/qml/Quickshell/quickshell-core.qmltypes contains no clearComponentCache (grep = 0 hits); the exported types (Quickshell, QuickshellSettings, ...) expose no cache-clear method
  • inotifywait watcher IS running and fires: shell log shows Local plugin changed, reloading: <id> on every save
  • After the reload only a full process restart applies QML content changes

Steps to reproduce

  1. Add any bar-widget plugin under ~/.config/omarchy/plugins/ (e.g. jp.taxiprijs/BarWidget.qml).
  2. Edit a label/color in the .qml and save.
  3. Observe the bar still shows the old content until you run omarchy restart shell.

Suggested fix

Expose/clear the QML component cache so plugin content is re-read from disk on reload — e.g. surface Qt.clearComponentCache (or recreate the QML engine per generation, as Quickshell's own native watchFiles/reload path does) and call it in finishPluginReload(). Alternatively, enable Quickshell's native watchFiles-based engine recreation for plugin directories.

System

  • Omarchy: 4.0.1-1
  • Quickshell: 0.3.1-1 (Arch Linux package)

vlaktaks avatar Aug 27 '26 09:08 vlaktaks

Ran into this independently and can confirm the Qt.clearComponentCache finding.

  • quickshell 0.3.1-1 package
  • strings /usr/bin/quickshell | grep clearComponentCache -> no match

I spent some tokes to find out that there is a compounding issue worth checking alongside it though:

shell.qml's syncPluginWidgets() (around line 669) has

// If the component URL is unchanged, just refresh the metadata in
// place. We can't skip this even when the URL matches: manifests can
// change schema, defaults, or sourceDir between rescans, and the
// settings panel reads metadata from the registry.
if (existing && existing.url === url && shell.barWidgetRegistry.has(registryKey)) {
  shell.barWidgetRegistry.register(registryKey, existing.component, meta)
  continue
}
loadPluginWidget(registryKey, url, meta)

existing.component is the Component object from an earlier Qt.createComponent(url, Component.Asynchronous) call, cached in shell.qml's own pluginWidgetComponents map. This seems to be separate from the engine's URL-keyed component cache. Editing a plugin's BarWidget.qml in place never changes its url, so existing.url === url is always true and it will reuse the already-compiled Component instead of calling loadPluginWidget() (and therefore Qt.createComponent()) again.

So even a Quickshell build where Qt.clearComponentCache() works as intended, wouldn't fix reload for an already-loaded bar-widget: syncPluginWidgets() never asks for a new component in the first place when the URL is unchanged, so the cache never gets a chance to matter. Fixing the missing binding and fixing this feel like two separate patches.

Repro matched exactly: edited an already-enabled third-party bar-widget's QML, tried rescanPlugins and a disable/enable cycle, no change either way; only a full omarchy restart shell picked it up.

battisti avatar Aug 29 '26 16:08 battisti

Two notes from reproducing this on 4.0.1-1 / quickshell 0.3.1-1.

Qt.clearComponentCache isn't missing from the Arch build — it has never existed in QML. clearComponentCache() is a public C++ method on QQmlEngine, and is not among the methods the QML global Qt object exposes (those come from QtObject in qqmlbuiltinfunctions.cpp — createComponent, createQmlObject, binding, callLater, resolvedUrl and so on), in Qt 5 or Qt 6. So the strings and .qmltypes misses above aren't a packaging gap, and no quickshell release will expose it. #6981 reaches the same conclusion.

Evidence for @battisti's syncPluginWidgets() point. The plugin I hit this with reports a repaint counter over IPC, so I can tell whether the widget object is a new one or the same one still running. On an in-place QML edit that counter resets to zero and climbs again — a genuinely new instance — while still reporting the old value of a constant I had just changed on disk. So the widget really is torn down and rebuilt, and rebuilt from the already-compiled Component. That separates "the instance was not recreated" from "recreated from a stale component", and it's the second.

For triage: #6981 is the earliest and most complete report, and #9251 the same symptom. PR #8766 proposes a fix via Quickshell.reload(false), with an open question there about teardown safety on quickshell 0.3.1.

rishwanth-th avatar Aug 31 '26 00:08 rishwanth-th

Confirming this on Omarchy 4.0.1-1 / Quickshell 0.3.1 (Arch), ThinkPad X1 Yoga Gen 5.

Minimal repro with a throwaway bar-widget plugin (kinds: ["bar-widget"], entry point BarWidget.qml that console.warns a BUILD-N marker on every render):

Action "Local plugin changed, reloading" logged New BUILD-N code runs
Save the .qml yes no
omarchy-shell shell rescanPlugins yes no (recreates the widget instance, but from the stale cached component)
omarchy restart shell – yes

Two extra notes on top of what's already here:

  1. rescanPlugins is affected too, and the docs say it shouldn't be. shell/README.md describes it as "re-walk plugin dirs and hot-reload plugin code", and also says "Saving a file anywhere under ~/.config/omarchy/plugins/ reloads plugin code automatically". Neither is true for bar-widget plugins. Panels and services do reload fine.

  2. Root cause matches #6981: finishPluginReload() guards on typeof Qt.clearComponentCache === "function", which is false in the packaged Quickshell (C++-only on QQmlEngine), so the guard silently no-ops and Qt.createComponent() returns the cached component.

Until the cache can actually be cleared, having reloadPlugins() detect that Qt.clearComponentCache is unavailable and fall back to a full omarchy restart shell (at least for the bar-widget kind) would make the documented workflow behave as written.

RUSSCALL avatar Aug 31 '26 04:08 RUSSCALL

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