Skip to content

Fix plugin reload stale qml - #7259

Open
ilyaZar wants to merge 4 commits into
omacom:quattrofrom
ilyaZar:fix-plugin-reload-stale-qml
Open

ilyaZar wants to merge 4 commits into
omacom:quattrofrom
ilyaZar:fix-plugin-reload-stale-qml

Conversation

@ilyaZar

@ilyaZar ilyaZar commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

refs #6981

Regarding the issue:

I can confirm the issue is real with my own plugin (plugin-control): also, on a testing machine, I had omarchy running for a couple of days and the shell wasnt restarded during that time

next, after using omarchy plugin remove <...> plus omarchy plugin add <...> on my plugin, I couldnt get it updated, and observed the stale behavior; the plugin update did not carry over properly

Regarding its solution

Essentially, this is a question about plugin lifecycle management or so:

user could own the complete removal process as per the documentation, but then every plugin maintainer would have to add more lines to removal code in addition to the simple omarchy plugin remove ... a follow up on shell reloads is necessary, which would duplicate to over 300 plugins or so. also many might just forget, and silent bugs being introduced all the time

integration into existing plugin removal seems (in some form or another) advantegous; not claiming this is the best way here, but its one with fewest lines of code changes I can think of atm. ; alternatives could be to elicit code parts from shell restart into the omarchy plugin remove ... but thats kinda duplication

not aware of strong side effects (overkill maybe, a bit heavier than needed; not dangerous in any form) stemming from omarchy restart shell; if so, duplication of code in omarchy plugin remove ... and change of exact behavior therein could be be better of course

- clear cached qml before a same id reinstall
- load updated qml in a fresh shell process
Copilot AI balanced review requested due to automatic review settings August 17, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #6981, where hot-reloading a changed plugin silently re-ran stale code. The root cause is that finishPluginReload() in the shell relies on Qt.clearComponentCache, which is not exposed to QML, so rescanPlugins re-creates plugin components from Qt's URL-keyed (stale) component cache. To guarantee updated plugin code takes effect, the PR replaces the lightweight omarchy-shell shell rescanPlugins IPC call with a full omarchy-restart-shell in the update and remove commands, which starts a fresh engine with a clean component cache. Note that omarchy-plugin-add and omarchy-plugin-clone deliberately keep rescanPlugins, which is correct since they introduce brand-new plugin ids/URLs that have no cache entry to invalidate.

Changes:

  • omarchy-plugin-update now restarts the shell (instead of rescanning) after any successful update.
  • omarchy-plugin-remove now restarts the shell (instead of rescanning) after removal, which also clears the cache so a later re-add of the same id gets fresh code.
  • The plugin-clone test stubs omarchy-restart-shell so its omarchy-plugin-remove exercise still passes.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
bin/omarchy-plugin-update Replaces rescanPlugins IPC with a full omarchy-restart-shell to avoid applying updates from a stale QML component cache.
bin/omarchy-plugin-remove Replaces rescanPlugins IPC with omarchy-restart-shell so removals (and later re-adds of the same id) start from a clean engine.
test/shell.d/plugin-clone-test.sh Adds an omarchy-restart-shell stub so the real command isn't invoked when the test exercises omarchy-plugin-remove.

A few notes for the human reviewer to weigh: this trades a cheap in-process rescan for a full desktop-shell restart on every plugin update/remove (re-lock flow, invitation-toast re-runs, and added latency), which the author themselves flagged as a possibly-heavy approach. Behavior under set -euo pipefail is not a regression, since the previous non-quiet omarchy-shell call also aborted the script when the shell was down. The behavior-change docs (e.g. manual/32-shell-plugins.md, docs/omarchy-shell.md) still describe the old reload semantics but are outside the diff.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ilyaZar

ilyaZar commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

maybe a note bc the clanker picked it up as well

  1. I do believe in the case of remove -> add life cycle, that a full omarchy restart shell is better , hence 1624d64 ; it "guarantees" that adding the same plugin ID cannot reuse QML cached before removal

  2. I am not sure about update as the trade-off is stability (omarchy restart shell seems to always work) vs. it would need to correctly identify and reload every affected service, panel, widget, and relative QML/JS dependencies etc. ; to me that seems more complex and (likely) more brittle ; so I'd lean still more towards 6d0df9d than a targeted solution

@omarchybot

Copy link
Copy Markdown
Collaborator

Verified on a disposable worker VM built from the Omarchy ISO, with this branch merged into current quattro (3faafba). It merges cleanly. The test plugin was a git-managed service plugin that reports its own version over IPC. On quattro, and again with your two commits reverted, the shell kept answering v1 after omarchy plugin update pulled v2, and still answered v1 after omarchy plugin remove followed by re-adding the plugin at v3. With this branch the shell answered v2 and then v3. So both paths you changed are fixed.

Tests on the worker: plugin-clone-test, menu-plugin-test and restart-shell-test pass. ./test/cli has one failure, the vscode generated theme assertion, and it fails the same way on quattro. menu-test could not run because node is not installed on the worker.

One low-severity finding, checked on the worker and left for you and the maintainer to decide on rather than pushed. If the session is locked when the command runs (over ssh, say), omarchy plugin update pulls the new code, then omarchy-restart-shell refuses with "Refusing to restart Omarchy shell while the session is locked", and set -e exits 1. The shell keeps serving the old code, and running the update again reports "up to date", so it never retries. omarchy plugin remove has the same exit, after the plugin is already gone. Serving stale code while locked is not new, since rescanPlugins never picked up new code either. What is new is the non-zero exit after the command did its work.

Scope: this fixes the update and remove commands, not the file-watcher reload on save that #6981 is mostly about. finishPluginReload() still re-creates plugins from the cached component, so this refs #6981 without closing it. #8766 attacks the shared reload path with Quickshell.reload(false). It currently conflicts with quattro, and it is waiting on quickshell-mirror/quickshell#956, a use-after-free at engine-generation teardown that is still open upstream. The two overlap: if #8766 lands, these restarts become redundant. Restarting the whole shell on every remove, including for a plugin that was never enabled, is a trade-off the maintainer should weigh.

Codex at medium effort reviewed the change separately and also compared it against #8766. It recommended this PR as the interim fix while #8766 waits on quickshell, and it raised the locked-session case, which I then reproduced. It could read this session's notes, so its agreement is not guaranteed to be independent. This now waits on the maintainer.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 2026
omarchybot and others added 2 commits November 16, 2026 17:32
quattro's update now asks the shell for reloadPlugins (omacom#18198), which still cannot clear the component cache, so the conflict keeps this branch's restart.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
omarchy-restart-shell refuses while the session is securely locked, and can time out from ssh or a TTY. Under set -e that turned an already completed remove or update into a failed command, and a retried update then reports up to date. Follow omarchy-update and omarchy-update-restart: the refusal is printed, and the command reports what it did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-wonder High <noreply@meta.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

quattro had moved on and this branch no longer merged, so I merged current quattro into it (c033bdf). The only conflict was in bin/omarchy-plugin-update, where quattro had switched the call to reloadPlugins. The merge keeps your omarchy-restart-shell, because a reload re-creates plugins from the same cached components.

I also pushed one fix on top (aadf4c0) for the locked-session case from my last comment. When the session is locked (over ssh, say), omarchy-restart-shell refuses, and set -e made omarchy plugin update and omarchy plugin remove exit 1 after they had already done their work. remove also skipped its closing messages, and running the update again said "up to date". Both now call omarchy-restart-shell || true, as omarchy-update and omarchy-update-restart already do. The refusal is still printed, and the command reports what it did.

Verified again on a disposable worker VM built from the Omarchy ISO, serving this branch at aadf4c0. The test plugin was a git-managed service plugin that reports its version over IPC:

  • At this head, the shell answered v2 after omarchy plugin update and v3 after remove plus re-add. On quattro (e19607f), and with your change reverted, it answered v1 both times.
  • With the session securely locked, update and remove both exit 0 and print the refusal. The version before aadf4c0 exits 1.
  • ./test/cli passes. So do plugin-clone-test, menu-plugin-test, restart-shell-test, plugin-add-test and plugin-enable-test.
  • plugins-test validates the built-in plugin manifests, which this PR doesn't touch, and could not run because node is not installed on the worker.

Codex at medium effort and muse-wonder at high effort reviewed the ported branch. Both found the locked-session exit fixed above and nothing else. Both reviewed the fix and found nothing further. They could read this session's notes, so their agreement is not guaranteed to be independent.

What is left is for the maintainer to decide:

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Plugin changes now reach the user's running Omarchy shell.

The PR appears safe to merge, with non-blocking concerns around open password prompts and restart error reporting.

Findings

  1. P2 Password prompts disappear ▶
  2. P2 Failed restarts report success ▶

Summary

Plugin removal and updates now restart the shell to clear stale QML.

  • Removing or updating a plugin now restarts the Omarchy shell.

Reviews (1) · Last reviewed commit: "Keep a refused shell restart from failin..." · Reviewed by Greptile

Comment thread bin/omarchy-plugin-update
if (( UPDATED_ANY )); then
omarchy-shell shell reloadPlugins >/dev/null
# A refused restart (locked session, ssh) only prints its reason: the update is already done.
omarchy-restart-shell || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Password prompts disappear

Updating or removing an unrelated plugin now kills any open Polkit password prompt. omarchy.polkit uses keepLoaded, so the previous rescan/reload kept its pending request alive. A full restart destroys that request, forcing the user to retry the privileged action. Check for an active authentication request and defer the restart until it finishes.

Comment thread bin/omarchy-plugin-remove
Comment on lines +121 to +122
# A refused restart (locked session, ssh) only prints its reason: the plugin is already gone.
omarchy-restart-shell || true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed restarts report success

|| true hides every restart failure, not just a refusal before restarting. omarchy-restart-shell also returns failure after killing the old shell if its replacement never answers, or if required services fail to return. Both plugin commands then report success, so scripts can continue while the desktop shell is still down. Distinguish a refused restart from a failed restart and return failure for the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants