Skip to content

Keep first-party services alive during local plugin reloads - #7605

Closed
oorestisime wants to merge 1 commit into
omacom:quattrofrom
oorestisime:fix/keep-first-party-services-on-plugin-reload
Closed

oorestisime wants to merge 1 commit into
omacom:quattrofrom
oorestisime:fix/keep-first-party-services-on-plugin-reload

Conversation

@oorestisime

Copy link
Copy Markdown

Fixes #7106.

Alternative to #7572; overlaps the lock-preservation part of #7169.

Problem

A practical trigger is phone vibe coding through T3 Code: the computer idle-locks while the user continues editing an Omarchy plugin from their phone. Saving plugin changes updates ~/.config/omarchy/plugins/, whose watcher starts a full plugin reload even though only local plugin code changed.

reloadPlugins() currently destroys every plugin service, including the package-owned omarchy.lock service and its live WlSessionLock. Destroying that service while it owns ext-session-lock strands the compositor lock. The replacement service can then race while recreating lock surfaces and make Quickshell abort with:

FATAL: Tried to show lockscreen surfaces without active lock

This was observed in two SIGABRT coredumps. One crash coincided exactly with a local plugin manifest edit; the stack reached WlSessionLock::updateSurfaces() from the QML reload lifecycle.

Fix

Treat automatic local-plugin changes differently from an explicit full rescan:

  • reloadLocalPlugins() retains package-owned first-party service instances, including omarchy.lock, idle, notifications, polkit, and media.
  • Third-party services are still destroyed and recreated, so the plugin being edited reloads immediately.
  • Explicit rescanPlugins calls keep the existing full-reload behavior and unload every service.

The first-party boundary is intentional: files changed by the local plugin watcher cannot modify package-owned plugin sources, so retaining those instances cannot leave the edited third-party plugin stale.

Unlike #7572, this does not defer the edit until the session unlocks. Phone-driven/T3 Code plugin development remains live while the lock infrastructure stays intact, and no polling is introduced.

Testing

  • Added test/shell.d/plugin-reload-test.sh covering first-party retention, third-party teardown, lock-service identity, and explicit full rescans.
  • Focused regression test passes: 5/5 assertions.
  • git diff --check and QML parsing pass.
  • Two manual local-plugin edits reloaded without changing the Quickshell PID or producing a fatal error.
  • ./test/all: all relevant tests pass. The three packaging-coverage files fail because this machine does not have the separate omarchy-pkgs checkout (config-test.sh, snapper-test.sh, and unowned-system-paths-test.sh); this is unrelated to the patch.

Copilot AI balanced review requested due to automatic review settings August 20, 2026 11:31

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

Preserves first-party services during local plugin reloads while retaining full teardown for explicit rescans.

Changes:

  • Adds local versus full reload handling.
  • Retains first-party service instances.
  • Adds regression coverage for teardown behavior.

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 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
shell/shell.qml Separates local and explicit plugin reload lifecycles.
test/shell.d/plugin-reload-test.sh Tests first-party retention and full teardown.

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

Comment thread shell/shell.qml
Comment on lines +362 to +364
if (keepFirstParty && manifest && manifest.__isFirstParty) {
retained[existingId] = inst
continue

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for flagging this — I checked the concern against the Qt version Quattro is running and tested the suggested alternative before changing the patch.

Qt 6.11's QQmlEngine::clearComponentCache() contract says it drops unreferenced components and explicitly does not drop components that are still referenced: https://doc.qt.io/qt-6/qqmlengine.html#clearComponentCache. trimComponentCache() documents an extant instance (or an object instantiated by it) as keeping that component in use as well: https://doc.qt.io/qt-6/qqmlengine.html#trimComponentCache.

Here the retained first-party service instance keeps its component and dependencies referenced, and _syncServices() does not instantiate a replacement because that service remains in _services. The unloaded third-party services/panels/widgets are unreferenced and remain eligible for eviction. In other words, on Qt 6.11 the existing cache call already provides the scoped behavior suggested here.

I also tested skipping the cache call in a minimal Quickshell fixture: after destroying a dynamically created component, editing its QML, and recreating the same URL, the second instance still returned the old value. So suppressing cache eviction would make the local-plugin watcher remount stale third-party code, defeating the live reload this PR preserves.

The type-identity warning applies if the same cleared QML code is instantiated again while an old instance remains. This path neither evicts nor recreates the retained first-party service component. The shell root and other long-lived QML objects also already survive the pre-existing cache call, so retaining the service does not introduce the first live object across this boundary.

If there is a concrete component path that Qt fails to retain through the live service's dependency references, I agree that path would need separate handling, but skipping the cache globally for local reloads is not safe for plugin development.

@oorestisime

Copy link
Copy Markdown
Author

CLosing this since it fell behind.Many PRs on this subject

@oorestisime oorestisime closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saving a file under ~/.config/omarchy/plugins/ while locked strands the session, and omarchy-restart-shell refuses to help

2 participants