Repository navigation
Reload shell safely when local plugin sources change - #11408
thelonewander3r wants to merge 9 commits into
Conversation
|
Reviewed at 40a195e, run on a disposable worker VM built from the Omarchy ISO. The shell was served from this branch merged into current The fix works for what it targets. I used a local service plugin with a sibling One blocking finding. If a local plugin's QML changes while the session is locked, the lock screen dies. Two smaller gaps, found by reading the code. Tests on the worker: Related: #8766 takes the same Only one model reviewed this, Claude Opus 5.5. The configured second opinion, Codex Medium, answered a ping but did not run, because today's review budget was spent. Next step is yours: keep the soft reload from taking down the lock screen, for example by not reloading while the session is locked. Whether this should also wait for a Quickshell build that carries the upstream teardown fix is the maintainer's call. |
[Medium impact] The change affects how the shell refreshes loaded local plugins. Changes are needed before merging: source reloads can run before update checks finish, and the multiple-screen smoke-test failure remains. Findings
SummaryLocal plugin source edits now request a debounced shell reload so QML and imported JavaScript refresh.
|
|
Addressed the locked-session reload issue in The source classifier now includes bash -n test/shell.d/plugin-hot-reload-test.sh
bash test/shell.d/plugin-hot-reload-test.sh
bash test/shell.d/plugin-auth-boundary-test.shAll 16 hot-reload assertions and the authentication-boundary static checks pass. The compositor runtime portion skips on this macOS host. I have not rerun the locked/unlocked Quickshell VM scenario, so that runtime verification remains needed; the reported upstream teardown use-after-free is also outside this fix. |
|
Thanks for the two pushes, 5e3a40d and 26ee2ef, which answer the locked-session finding and the Only one model, Claude Opus 5.5, looked at this run, and it only read the diff of 5e3a40d. It has no findings to report from that reading. The locked-session reload and the new source classifier still need the worker run your comment asks for. That re-review, with the second opinion, happens on a later run. Until then this waits on that run, not on you. |
|
Reviewed at 4b5bfb2, merged into current The fix works, and the locked-session finding from the last review is fixed. Your new runtime test fails on One blocking finding: an open polkit prompt is torn down by a source edit. I tried the obvious fix: also defer while any authentication service has Tests on the worker: Competing fixes for #6981: this is the one I'm recommending over #8766, #10576 and #13911. #8766 is older, but it does an engine reload on every rescan, with no lock guard. #10576 and #13911 version only the entry-point URL, so a sibling Codex Medium reviewed this separately and found the polkit gap and the Next step is yours: keep a source reload from taking down an open polkit prompt, in a way the runtime smoke test can still pass. |
|
I reviewed the open PRs for local plugin hot reload picking up stale code (#6981), plus an offscreen check of the cache-busting approach on my laptop.
I'd go with #11408. Reloading the engine is the only way to drop Qt's component cache for every file in a plugin. It holds the reload while the lock screen is up, and for edits that aren't code it keeps the cheap plugin reload. #13911, #7771 and #8766 duplicate it. #13911 also adds a new cache entry on every reload. Suggestion for #11408: a full reload resets every panel's state, so a short debounce for edits that come in bursts (an |
…shell quattro runs the runtime smoke test on base-test.sh's scratch shell (83f0400), so the source-version probe uses scratch_ipc and SCRATCH_PID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`omarchy plugin update` fast-forwards, validates, and resets when validation fails. With a 150ms quiet window a slow validation let the shell reload onto the rejected code and again after the reset, and a full reload resets every panel. Source edits now wait 500ms after the last watcher event; registry-only rescans keep 150ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| sed -i 's/qml-before/qml-after/' "$hot_reload_dir/Overlay.qml" | ||
| wait_source_version "qml-after:js-before" | ||
| pass "QML edits refresh the mounted plugin through the live watcher and shell reload" | ||
|
|
||
| sed -i 's/js-before/js-after/' "$hot_reload_dir/Model.js" | ||
| wait_source_version "qml-after:js-after" |
There was a problem hiding this comment.
Multiple screens fail the test
These source-edit checks reload the shell twice before the later duplicate-handler check reads the entire SCRATCH_LOG. With multiple screens, each shell load adds the expected per-screen handler collisions again. The combined count exceeds screens - 1, so a healthy shell fails the smoke test. Move the collision check before these reloads, or count only one shell load.
| if (shell.localPluginQmlReloadPending) { | ||
| // Keep the edit queued until unlock without polling the idle shell. | ||
| localPluginReloadTimer.interval = 1000 | ||
| localPluginReloadTimer.start() |
There was a problem hiding this comment.
While a source edit is queued behind a lock, localPluginReloadTimer checks the lock every second until unlock. The shell guide requires events instead of polling whenever a change signal exists. The lock service's locked property already provides lockedChanged. Connect that signal inside the private store and notify the shell without exposing the service object. This repository requirement must be met before merging.
File Used: agents/skills/shell-dev.md (source)
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!
quattro's omacom#18198 splits the watcher's timer into a full plugin reload for a plugin the shell already runs and a gentle rescan for one that just appeared. A source edit now takes the engine reload only for a loaded plugin, so a new plugin's files arriving still only add it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lock service's bound locked property once missed a change notification and reported locked after an unlock, which is why its own decisions read currentlyLocked(). Read that here too, so a stale value neither holds a queued reload forever nor lets one through under a live lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| function quietInterval(sourcePending) { | ||
| return sourcePending ? 500 : 150 |
There was a problem hiding this comment.
quietInterval() treats 500 ms without file events as the end of a plugin update. But omarchy-plugin-update checks the new files only after Git has written them, and those read-only checks do not extend the timer. If the checks take longer than 500 ms, the shell loads the new QML or JavaScript before they finish—even if the command later rejects and rolls back the update. The rollback cannot undo work that code already started.
Coordinate reloads with the update command rather than using a fixed delay as proof that it finished.
| run_node_test <<'JS' | ||
| const fs = require('fs') | ||
| const vm = require('vm') | ||
| function loadModule(file) { | ||
| const context = vm.createContext({}) | ||
| vm.runInContext(fs.readFileSync(root + '/shell/services/' + file, 'utf8'), context) | ||
| return context | ||
| } | ||
| const reload = loadModule('PluginReload.js') | ||
| const auth = loadModule('AuthServiceStore.js') |
There was a problem hiding this comment.
Tests break the placement rule
This adds plugin-hot-reload-test.sh even though runtime-smoke-test.sh already covers local plugin reloads and is extended by this PR. The contributor guide requires extending the area's existing test file instead of adding another *-test.sh. Splitting this coverage adds maintenance work. Move these helper checks into an existing plugin test file before merging to meet that requirement.
File Used: AGENTS.md (source)
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!
|
Reviewed at b736fe8. Since quattro's #18198 rewrote the same watcher handler, the branch no longer merged, so I pushed two commits to it. Everything below was run at the new head, 08b198f, on a disposable worker VM built from the Omarchy ISO. Pushed:
The fix still works on current Still open, and blocking: an open polkit prompt is torn down by a source edit. This is the finding from the last review, and nothing has changed it: Smaller points:
Tests on the worker:
Competing fixes for #6981: this is still the one I'm recommending. #7259 is the oldest, but it restarts the shell only after Two models reviewed this separately: Codex Medium and muse-wonder (via pi, thinking high). Both found no defect in the merge resolution or in 08b198f. Both confirmed the polkit gap is still there. Both chose this pull request over the other three. Both explained why the multi-screen point does not hold, and raised the 500ms and #12189 points. They can read this session's notes, so their agreement is not guaranteed independent. Next step is yours: keep a source reload from taking down an open polkit prompt, in a way the runtime smoke test can still pass. |
Local plugin source edits now trigger a debounced
Quickshell.reload(false)so compiled QML and imported JavaScript refresh..qml,.js,.mjs, andqmldircount as source changes; other files retain the registry-only rescan.Source reloads stay queued while any private authentication service holds a lock, then reload once after unlock. This avoids tearing down an active
WlSessionLockon a source edit. The lock query returns only a boolean and preserves the private authentication object boundary.The unreachable
Qt.clearComponentCacheguard is removed. Focused behavioral tests execute the real JavaScript classifier, lock store, and reload decision rather than matching source text.Validation on macOS:
bash -n test/shell.d/plugin-hot-reload-test.shbash test/shell.d/plugin-hot-reload-test.sh: all 16 assertions pass.bash test/shell.d/plugin-auth-boundary-test.sh: static checks pass; compositor runtime test skips.git diff --check: clean.Live locked/unlocked Quickshell verification still needs an Omarchy VM. The reported upstream teardown use-after-free remains outside this patch.
Fixes #11397
Fixes #6981