Repository navigation
Conversation
Qt.clearComponentCache() is not a member of the QML Qt object, so the guarded call in finishPluginReload was a no-op and the engine kept serving the cached component after an edit. The engine caches compiled components by URL for its lifetime and gives QML no way to clear it. rescan() now symlinks each plugin source dir into a fresh per-rescan dir under the shell cache and emits it alongside the source dir; entryPointUrl() loads through it, so the component URL changes and the engine recompiles the entry point and relative imports, without building a new engine and dropping the keepLoaded services. Shim creation is best-effort and falls back to the source dir if the cache is unwritable.
|
| + " if [[ ${manifest##*/} == \"manifest.json\" ]]; then sub=\"${manifest%/manifest.json}\"; else sub=\"$(dirname -- \"$manifest\")\"; fi; " | ||
| + " printf '===%s::%s===\\n' \"$kind\" \"$sub\"; " | ||
| + " target=\"${sub%/}\"; load=\"$sub\"; " | ||
| + " if [[ -n $rev_dir ]]; then shim=\"$rev_dir/$(printf '%s' \"$target\" | md5sum | cut -c1-16)\"; if ln -sfn \"$target\" \"$shim\" 2>/dev/null; then load=\"$shim\"; fi; fi; " |
There was a problem hiding this comment.
The shim for Indicators.qml points only to bar/widgets, where its manifest lives. The widget uses Qt.resolvedUrl("../indicators/" + …), which now points to rev.*/indicators/ instead of bar/indicators/. Those files cannot load, so the configured indicator icons disappear. Preserve the surrounding directory layout when creating fresh load URLs.
Knowledge Base Used: Shell UI and desktop interactions
| function ensureUserDir() { | ||
| initProcess.command = ["bash", "-c", "mkdir -p \"$0\"", registry.pluginsDir] | ||
| // Wipe stale load shims from the previous shell run before the first scan. | ||
| initProcess.command = ["bash", "-c", "mkdir -p \"$0\" && rm -rf \"$1\" && mkdir -p \"$1\"", registry.pluginsDir, registry.loadRoot] |
There was a problem hiding this comment.
Startup deletes fresh plugin links
ensureUserDir() starts cleanup in one process, while shell.qml immediately calls rescan() in another. Cleanup can remove a shim after the scan has emitted its URL. If cleanup finishes while scanning is still true, its follow-up scan is skipped. The first scan then publishes URLs to deleted files, leaving plugins unable to load. Wait for cleanup before starting the first scan.
| var separator = startMatch[2].indexOf("::") | ||
| if (separator === -1) { | ||
| currentSource = startMatch[2].replace(/\/$/, "") | ||
| currentLoad = currentSource | ||
| } else { | ||
| currentSource = startMatch[2].slice(0, separator).replace(/\/$/, "") | ||
| currentLoad = startMatch[2].slice(separator + 2).replace(/\/$/, "") |
There was a problem hiding this comment.
Splitting at the first :: breaks valid source directory names containing those characters. A manually installed plugin under plugins/acme::clock/ is scanned, but this parser records plugins/acme as its source and clock::<shim> as its load directory. Its entry point then points to the wrong file. Escape or encode the path fields instead of splitting raw paths.
| registry.parseScanOutput(block("thirdparty", "/third/regression", manifest("third.regression", ["panel"], { panel: "Panel.qml" }), "/load/rev-a/regression")) | ||
| root.assertEqual(registry.installedPlugins["third.regression"].__sourceDir, "/third/regression", "a load-dir line keeps the source dir") | ||
| root.assertEqual(registry.installedPlugins["third.regression"].__loadDir, "/load/rev-a/regression", "a load-dir line records the per-rescan dir") | ||
| root.assertEqual(registry.entryPointUrl(registry.installedPlugins["third.regression"], "panel"), "file:///load/rev-a/regression/Panel.qml", "entryPointUrl loads through the per-rescan dir") |
There was a problem hiding this comment.
Reload behavior lacks coverage
These assertions only parse invented scan lines and compare URL strings. They do not check that rescan() creates usable shims or that edited QML runs after a second scan. Add a test with a real temporary plugin that loads, changes, rescans, and returns the changed value. That would protect the actual hot-reload fix rather than just its scan format.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Good find that
|
|
Reviewed at f4955e3, by reading this diff and the competing ones against current The diagnosis is right.
The new fixture checks only parse invented scan lines. Nothing edits a loaded plugin and checks that the new code runs, so neither problem above would show up in them. Competing fixes: this is the sixth open pull request for this bug. #11408 is the one recommended to the maintainer so far. It reloads the engine on a local Codex Medium reviewed this separately. It found the same two defects, and it checked the indicator URL against the installed Qt runtime. It also confirmed with a probe that changing the directory alias, unlike a query string, does make an edited relative import recompile. It agreed this one should not be brought forward. On which competitor should be, it leaned to #10576 as the oldest, rather than #11408. It can read this session's notes, so its agreement is not guaranteed independent. Waiting on the maintainer to choose among the competing fixes. |
Problem
Editing a plugin (or running
omarchy-shell shell rescanPlugins) does not pickup the change: the shell keeps running the old code, and a bar widget can
vanish from the bar, until the shell is restarted.
finishPluginReloadinshell.qmltried to force a recompile withbut
clearComponentCacheis a method ofQQmlEngine, not of the QMLQtobject, so the guard is always false and the call never runs. The QML engine
caches compiled components by URL for its whole lifetime and exposes no QML API
to clear that cache, so re-loading the same URL always returns the cached
component.
Fix
Load every plugin through a fresh URL on each rescan:
PluginRegistry.rescan()symlinks each plugin source dir into a newper-rescan revision dir under the shell cache (
loadRoot) and emits the loaddir alongside the source dir in its scan output
(
===<kind>::<source>::<load>===).__loadDir(falling back to__sourceDir), andentryPointUrl()resolves the entry point through it. The component URLtherefore changes on every rescan and the engine recompiles the entry point
and its relative imports.
back to the source dir, so behavior is unchanged. Older revisions are left in
place for the session so preserved
keepLoadedservices keep resolving, andensureUserDir()wipes stale shims at startup.keepLoadedservices (for example the lock) arenot dropped.
A two-field scan line (
===<kind>::<source>===) still parses and resolvesthrough the source dir, so the format change is backward compatible.
Testing
test/shell.d/plugin-registry-contract-test.shis extended with checks that athree-field line records
__loadDir, thatentryPointUrl()resolves throughit, and that a two-field line falls back to the source dir. The new checks
fail against the current
quattroand pass with this change.rescanPlugins, and saw theedited code run; a second edit also took effect. Startup and every rescan
create a fresh
rev.*dir, so each edit gets a new URL.Fixes #10729.