Skip to content

fix: keep keepLoaded services across _syncServices disable - #12937

Open
chessing234 wants to merge 6 commits into
omacom:quattrofrom
chessing234:fix/sync-services-keep-loaded
Open

chessing234 wants to merge 6 commits into
omacom:quattrofrom
chessing234:fix/sync-services-keep-loaded

Conversation

@chessing234

@chessing234 chessing234 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • _syncServices() now skips serviceKeepLoaded() services in both the public _services drop loop and the AuthServiceStore reconciliation, matching unloadPluginServices().
  • Stops the builtin-defaults / disablement path from destroying third-party lock (and other keepLoaded) services while Hyprland still holds ext-session-lock.

Closes #11389

No visible change: keepLoaded services stay registered in the background. nothing on screen is redrawn.

Test plan

  • bash ./test/shell.d/plugins-test.sh (contract: _syncServices honors keepLoaded)
  • bash ./test/shell.d/plugin-auth-boundary-test.sh (AuthServiceStore keepLoaded guard in _syncServices)
  • bash ./test/shell.d/runtime-smoke-test.sh when a Wayland compositor is available (disablement keeps keepLoaded instance marker)

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

One lifecycle regression remains at 2d7bdee5716a: explicit disable and clone replacement now retain the old keepLoaded service.

Explicit disable keeps the old service running

The new guards in _syncServices() depend only on the installed manifest's keepLoaded flag, not why the service became disabled or whether a session lock is held.

Source tracing and a simulation using the extracted reconciliation functions show:

Operation on an already running service Base This PR
Enable a clone of omarchy.lock Original destroyed; clone retained Original and clone both retained
Disable omarchy.idle Idle service destroyed Idle service retained

Impact: The registry reports the old service disabled, but its live behavior can continue. The idle service does not gate its idle monitoring on plugin enablement. Lock cloning also preserves the built-in lock IPC target in the copied code, so retaining both instances creates competing handlers rather than a clean replacement. Which handler receives calls was modeled, not verified in a running compositor.

Suggested change: Distinguish transient configuration fallback from deliberate disable/replacement. For example, retain the last valid configuration across temporary empty/invalid reads, and defer an active locker's teardown until it can safely release the session lock. Preserve explicit disable behavior for other services and ensure a clone switch leaves only the intended handler active. Simply restoring unconditional destruction would reintroduce the locked-session failure.

Verified: In the extracted-code simulation, the PR preserves the same third-party lock instance through the reported defaults-window sequence; the base destroys and recreates it. This verifies the reconciliation change, not native suspend/resume recovery.


Review information

Test scope: Pinned base/head source review, extracted JavaScript reconciliation with synthetic service creation and IPC routing, and the repository plugin-contract test at both revisions. No live Quickshell/Wayland lock, authentication, or suspend/resume test was performed.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium initial inspection, independent Opus 5.5 High and GPT 6 Sol Xhigh technical assessments, then Astra Medium synthesis against source and targeted evidence.

Explicit disable and clone replacement must tear down idle and unlocked
lock instances. Defer teardown only when a keepLoaded service still
holds the session lock.
@chessing234

Copy link
Copy Markdown
Contributor Author

good catch. keepLoaded alone no longer keeps a disabled service alive — only while the live instance still reports locked === true (so a mid-lock defaults rewrite does not strand ext-session-lock). explicit disable and clone replacement tear the old one down again.

@chessing234

Copy link
Copy Markdown
Contributor Author

disabled keeploaded services are torn down again unless the instance still reports locked, so idle/clone originals do not stick around while a held session lock is still deferred.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up at 58f2abb4, after the earlier review and the author's reply.

Resolved: explicit disable and clone replacement again tear down an unlocked keepLoaded service. shouldRetainDisabledKeepLoaded() now keeps a disabled service only while its instance reports locked === true. Among shipped services, only omarchy.lock and its clones expose locked.

Verified in a simulation that runs the extracted reconciliation functions of each revision, with component creation and Quickshell's IPC registry stubbed:

Operation on a running service Base Previous head 2d7bdee5 This head
Disable omarchy.idle destroyed retained destroyed
Enable a clone of omarchy.lock (unlocked) original destroyed, clone serves lock IPC original retained, keeps lock IPC original destroyed, clone serves lock IPC
#11389 defaults window with a locked lock clone clone destroyed and recreated same instance kept same instance kept

This verifies the reconciliation decisions, not native ext-session-lock recovery.

A disabled lock can be kept without owning the session lock

The author's claim holds while unlocked. While the screen is locked, locked means "requested or held" (lockRequested || sessionLock.locked || sessionLock.secure, lock/Service.qml:46), and a new lock instance can raise lockRequested without ever holding a lock. A source trace (Omarchy and Quickshell v0.3.1) of enabling and then disabling a lock clone while another lock instance holds the session:

new lock instance created while another instance holds the lock
  -> checkStrandedLock(): omarchy-hyprland-session-locked exits 0 for any held lock
  -> treats the other instance's lock as stranded, beginLock(): lockRequested = true
  -> requestSessionLock() returns early (global sessionLock.secure), timer keeps retrying
instance disabled
  -> locked === true, so shouldRetainDisabledKeepLoaded() keeps it (owns no lock)
holder unlocks
  -> retained, disabled instance's pending timer takes a new session lock

The retention step is model-verified. The stranded-check and re-lock steps are source-traced only. The issue #11389 journal shows the same lock-stranded: recovering -> lock-requested sequence at base, most likely from the built-in lock the defaults window created.

Impact: after unlocking, a second lock screen can come from a plugin the registry reports disabled, while lock IPC and lock status still answer from the original holder. Separately, nothing re-runs _syncServices() on unlock (its only callers are startup, pluginsChanged and rescan), so a retained instance is torn down only at the first config change or rescan after its locked turns false, not at unlock. The trigger is uncommon: a clone enable and disable issued while locked (from a TTY, SSH or a script), or, not reproduced, the #11389 defaults window itself, if it lasts long enough for the built-in lock it creates to start a request and closes before unlock. It is still an improvement over base, which destroys the holder in the same sequence and strands the session. This was not reproduced in a live compositor.

Suggested change: in the stranded-lock check, ignore a lock already held by another instance in the same shell (for example, re-read sessionLock.secure in the helper's exit handler before recovering), so no spurious request is raised. Re-running reconciliation when a retained instance's locked becomes false would end retention at unlock. Otherwise, the comment at shell.qml:981-986 could say that retention also covers pending requests and lasts until the next reconciliation.

Optional test improvement: the #11389 path (a lock clone, reconciled through AuthServiceStore) is covered only by source-text checks. With the auth-path call passing null instead of AuthServiceStore.get(...), or the predicate made to ignore locked or never retain, plugins-test.sh and the headless part of plugin-auth-boundary-test.sh still pass. The runtime smoke fixture is a non-clone service on the _services path, so it would not catch the auth-path mutations either. A Node vm test that runs _syncServices with a locked lock-clone entry in AuthServiceStore, checking retention while locked and teardown while unlocked, would cover the fix.

Documentation: docs/omarchy-shell.md describes keepLoaded as surviving between summons and across hot-reload, but not disable. Retention across disable now depends on the root object exposing locked, so a hand-written third-party lock without that property is torn down in the defaults window, as at base.

Related PR: #12260 adds AuthServiceStore.get() at the same place, returning null for a missing id and asserting get(...) === null after destroy. This PR's getter returns undefined. The two changes will conflict. Keeping #12260's null-returning getter would satisfy both, since this PR's call site treats null the same way.


Review information

Test scope: Pinned source review of this head, the previous head and the merge-base; Quickshell v0.3.1 source; an extracted-code reconciliation simulation with stubbed component creation and IPC registry; repository plugins-test.sh and plugin-auth-boundary-test.sh at each revision plus labelled mutants, run in a sandbox. The runtime smoke test and auth-boundary runtime parts skipped (no compositor). No live Quickshell/Wayland lock, authentication, fingerprint or suspend/resume test was run.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@chessing234

Copy link
Copy Markdown
Contributor Author

stranded-lock false recover still needs a secure/locked re-check before requesting a new lock. will do that next unless you want it dropped.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 58f2abb4, read only: this was compared against the other open fix for the same teardown, #7572, and not run on a worker, because only one of two competing fixes is taken forward to verification.

The bug in #11389 is real on quattro: both drop loops in _syncServices() (shell/shell.qml, the _services loop and the AuthServiceStore loop) destroy a lock service that still holds ext-session-lock, with no guard of the kind unloadPluginServices() has. This pull request and #7572 both add that guard to both loops. #7572 is the more complete fix of the two, for these reasons:

  • What retention is keyed on. Here it is locked, which on the lock service is lockRequested || sessionLock.locked || sessionLock.secure (shell/plugins/lock/Service.qml:49). sessionLock.secure is read from Quickshell's process-wide session-lock manager, which an earlier teardown can leave set, so a disabled service can be kept for as long as that process lives while owning no lock. Spare the session-lock owner in every service teardown until it unlocks #7572 keys on a new sessionLockOwned (lockRequested || sessionLock.locked), which is this instance's own state.
  • Collection after unlock. Nothing here re-runs _syncServices() when a retained service unlocks, so a disabled lock service keeps running, and keeps answering the lock IPC target, until the next config change or rescan. Spare the session-lock owner in every service teardown until it unlocks #7572 emits unlockSettled when the unlock's wake exits and re-syncs then, which collects it.
  • A clone swap while locked. Enabling a lock clone while the original holds the lock mounts the clone beside it; the new instance finds the lock held, takes it for stranded and requests a new one (traced in the source, not reproduced). Spare the session-lock owner in every service teardown until it unlocks #7572 refuses a second member of the same clone family while one holds the lock and mounts it after unlock.
  • Reloads while locked. Spare the session-lock owner in every service teardown until it unlocks #7572 also applies the same skip in unloadPluginServices(), which spares by the current manifest's keepLoaded and so stops sparing a lock plugin the registry no longer lists.

One thing this pull request covers that #7572 does not: a lock clone made before the change has no sessionLockOwned, so #7572 does not protect it until it is cloned again, whereas locked exists on every existing clone. The #11389 setup is exactly such a clone. That is worth weighing, but it does not outweigh the gaps above, and #7572 has already been reproduced and verified on a disposable Omarchy VM.

The two also conflict: both edit the same lines of both drop loops and both add to AuthServiceStore.js.

The independent second opinion did not run on this one: the configured reviewer, Codex Medium, had used up today's review allowance, so the comparison above is one model's reading (Claude Opus 5.5), checked against the source at both heads.

Waiting on the maintainer to choose between this and #7572. If #7572 lands, #11389 should be checked against it, since the clone in that report predates sessionLockOwned.

@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The follow-up appears safe to merge.

Summary

Disabled keepLoaded services now stay alive while locked and are removed after unlock. This follow-up strengthens the tests without changing runtime behavior.

  • Disabled services stay alive only while they hold a session lock.

The earlier test-coverage finding was withdrawn by greptile-apps[bot] after chessing234 correctly noted that the test executes the helper.

Reviews (4) · Last reviewed commit: "test: keep a locked service through disa..." · Reviewed by Greptile

@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 9b666ac9, which merges quattro and adds a re-sync when a retained service unlocks. It was read and compared against #7572 again, not run on a worker: only one of two competing fixes goes on to verification.

What the new commit fixes. My last comment said nothing here collected a retained, disabled lock service after unlock. That no longer holds. shouldRetainDisabledKeepLoaded() (shell/shell.qml:1077-1093) now connects to lockedChanged and calls _syncServices() once locked falls, so the service is torn down after unlock. AuthServiceStore.get() returns the live instance, so the check also reaches the omarchy.lock service, which lives in that store. The bug in #11389 is still present on current quattro (3b36b9e1).

What is still open here, checked against the source:

  • Unlock wake can be cut short. finishUnlock() sets sessionLock.locked = false and only then starts wakeProcess (shell/plugins/lock/Service.qml:246-248). The re-sync then destroys the service on the next event loop turn, and omarchy-system-wake is a child Process of that service. Spare the session-lock owner in every service teardown until it unlocks #7572 waits for the wake process to exit (unlockSettled) before it re-syncs.
  • Removal while locked still strands the lock. Retention first checks serviceKeepLoaded(pluginId), which reads the registry's current manifest. If the plugin was removed, that check returns false and the locked service is destroyed. The same applies to unloadPluginServices() on a hot reload. Spare the session-lock owner in every service teardown until it unlocks #7572 keys on the instance's own state, so the manifest is not needed.
  • Enabling a lock clone while another holds the lock mounts the new one beside the holder (ensureService runs before the teardown loops), so two lock services answer the lock IPC target. Spare the session-lock owner in every service teardown until it unlocks #7572 defers the new one until the holder unlocks.
  • locked includes sessionLock.secure (Service.qml:65), which reflects whether the session is locked at all, not whether this instance holds the lock. So a disabled instance that does not own the lock can be retained. Keeping too much is safer than stranding the lock, but it can linger.
  • The new line in test/shell.d/plugin-auth-boundary-test.sh:33 greps shell.qml for the function this pull request adds, which AGENTS.md asks tests not to do. The runtime-smoke case is a real behavioural test.

What this pull request does that #7572 does not. A lock clone made before #7572 is a copy of the old Service.qml, so it has no sessionLockOwned, and #7572 would still destroy it while it holds the lock. That is the exact setup in #11389. This pull request keys on locked, which every existing clone already has. I've handed that over to #7572: it should fall back to locked, and to a lockedChanged re-sync, for an instance that has no sessionLockOwned. Your runtime-smoke fixture is the better kind of test for that, and the hand-off credits it to you.

Which one goes forward. #7572 is older, and this one is not clearly better: each misses cases the other handles, and the gaps above are on the path that keeps the lock alive. So #7572 stays the one taken forward, and it should take the improvement above. The second opinion split on this. Codex Medium preferred this pull request, mainly because of the old-clone case. muse-wonder (pi, thinking high) preferred #7572 with this pull request's locked fallback added. Both found the wake, clone-mount and secure issues above on their own. One also noted that a service which gains the authentication capability is still destroyed without a check (shell/shell.qml:1003-1010), which #7572 guards. Its concern that AuthServiceStore.get() exposes the credential-bearing object does not hold: each file that imports the store gets its own private copy, so get() reaches only shell.qml's own services. Both reviewers can read this session's working files, so where they agree with me, that agreement is not guaranteed to be independent.

Waiting on the maintainer to choose between this and #7572.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed the new head d06071296981efcf9b2f98eed64163f0f8574ca1 with GPT-6 High in Codex. It is an empty commit: its file tree is identical to 9b666ac9, so the code findings in the previous review have not changed. No contributor code was executed or worker tests run in this pass.

The old-clone handoff from the previous review is now implemented in #7572 at 3ce96716: authentication-store services without sessionLockOwned fall back to locked and are reconciled after unlock. That commit credits @chessing234 as co-author. #7572 remains a competing fix, not a duplicate of this pull request.

Opus 5.5 High and muse-wonder via pi (thinking high) also compared the identical code tree against #7572; both preferred its broader teardown coverage. Their agreement is not guaranteed to be independent. This was a source comparison, not a runtime verification.

Classification for the new SHA is unsettled. My classification is bug, but the configured classification model, deepseek-v4p1-flash, returned no class. This stops the queue pass before verification; no verification or readiness labels were added. The next step is to obtain an agreed classification, and the maintainer's choice between the competing fixes remains open.

@omarchybot omarchybot removed the bug Something isn't working label Nov 20, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Read the new head 4f299c35bb612fdb1d6afb771bf005929fe11181 with GPT-6 High in Codex, including the test-only change since d0607129, the surrounding reconciliation code, and the previous review discussion. The new assertions execute the extracted retention helpers and check locked, unlocked and non-keepLoaded cases. This was source review only; I did not run those assertions or any worker tests.

My classification is bug, but the configured classification model, deepseek-v4p1-flash, returned no class for this head. The queue workflow requires an agreed classification before proceeding, so this pass stops at disagree. No technical second opinion was requested and no verification or readiness labels were added. Waiting on classification to be settled before the review can continue.

@omarchybot

Copy link
Copy Markdown
Collaborator

Read the new head 8788328f170622174c4e3fa30e223eb1ee2889af with GPT-6 in Codex (reasoning effort not exposed), including the test-only delta, surrounding reconciliation code, base-branch rules and earlier review discussion. The new test exercises _syncServices() with a disabled, locked service in AuthServiceStore and asserts that it survives until unlock, then is destroyed. This was source review only; I did not execute the assertions or run worker tests.

My classification is bug, but the configured classification model, deepseek-v4p1-flash, returned no class for this head. The queue workflow requires this pass to stop at disagree before verification. No technical second opinion was requested, and no verification or readiness labels were added. Waiting on classification to be settled before review can continue.

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.

_syncServices() destroys keepLoaded services the builtin-defaults window marks disabled — any third-party lock plugin strands the session on resume

3 participants