Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Defers plugin reloads while the session lock is active, preventing lock-service teardown and session stranding.
Changes:
- Polls every two seconds until the session unlocks.
- Adds regression coverage for the reload guard.
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 |
Guards plugin reloads while locked. |
test/shell.d/plugin-reload-lock-guard-test.sh |
Tests lock-aware reload deferral. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // A deferred reload is postponed, not dropped: the guard re-arms the reload | ||
| // timer so the pending change is picked up shortly after unlock. | ||
| assert( | ||
| /if \(lockService && lockService\.locked\) \{\s*\n\s*localPluginReloadTimer\.interval = \d+\s*\n\s*localPluginReloadTimer\.restart\(\)\s*\n\s*return/.test(shellQml), |
There was a problem hiding this comment.
Addressed in defd790 — rather than pinning 2000 (which would fail on any legitimate retune), the test now captures both intervals and asserts the deferral poll is numerically slower than the debounce, which is the actual invariant. 🤖 via Claude Code
|
Re-reviewed at What the new commit fixes
Two things that skip does not do, worth stating so nobody reads it as broader than it is. It preserves only a service whose Excluding What is still openThe one that matters:
I am re-rating this medium rather than the high it was given last time, and the reason is worth stating plainly: reaching it needs a terminal on a locked session, and in that same window today's Timer interval leaks across the lock boundary ( The reload replayed at unlock is a single full teardown, within 2s of unlock, What does not holdThe guard sitting after the The deferral is also not lossy and holds nothing unbounded in memory: many writes during a lock coalesce into one eventual scan. The tests
They also cannot fail. Codex reported that the nine assertions survive deliberate breakage, and I re-ran that myself against the head rather than taking it: all nine still pass with Where this sits#7572, #7169 and #7605 are three different fixes for #7106 and choosing between them is the maintainer's call, not mine — I am not recommending one over another and I have not touched the other two. What the VM run does establish for this one: with the patch, the #7106 trigger fired while locked — a write into a live plugin directory, Worth keeping in the frame that none of the three is a fix for the underlying defect. That is quickshell-mirror/quickshell#962: One small thing on the body: it now carries two Waiting on you for the |
|
Both open items are in Timer interval. The timer is now armed from one helper that picks its interval from the lock state, and a reload that proceeds stops it. One note on the suggested shape: setting the interval where the timer is armed and leaving
The check reads Tests. You were right that the nine assertions could not fail, and the point about The file is now checked against nine deliberate breakages — your five, plus four for the behaviour these commits add — and each one makes it fail:
27 assertions, plus 126 across the affected shell suites and 116 in Body. Rewritten as a description of the change as it stands, one Testing section, branch history dropped. It also folds in your two corrections from #7106, both of which I checked against source first: Still yours and the maintainer's call which of the three lands; nothing here is an argument that it should be this one. |
|
Re-reviewed at Timer interval — the reasoning holds, checked rather than taken.
The part not yet spoken to: the refusal is unconditional, but the discovery poll only exists on the enable branch ( Two mutations still got through the suite. Pushed as
The commit compares the guard's whole condition rather than looking for the call inside it, and adds the Still open, low. What ran: Waiting on the maintainer, for the unconditional-refusal question and for which of #7572, #7169 and #7605 lands. Nothing here argues for one over another; for what it is worth, this PR and #7169 do not overlap much — #7169 carries recovery for an already-poisoned process and this carries prevention — while #7605 is an alternative to the prevention half. |
|
Reproduced on the post-0.3.1 stack, so this hasn't been overtaken by the quickshell update — Omarchy 4.0.1-1, quickshell 0.3.1-1, qt6-base 6.11.2-2. A One thing from those runs that's worth having before anyone verifies this PR: the stranding is deterministic, the abort isn't. Two locked plugin writes here, both stranded the lock at +1s, only one reached Also a small data point for the debounce: one Glad to run this branch against a real session lock on this box if another 0.3.1 data point would help. |
unloadPluginServices() now keeps a keepLoaded service across a plugin hot-reload, but _syncServices destroys services inline on its own, without going through it and without consulting keepLoaded, whenever the registry stops listing a plugin as installed, enabled and service-declaring. It is reached straight from pluginsChanged, so `omarchy plugin disable omarchy.lock` gets there with no reload at all, as does a local lock clone whose manifest is unreadable during the write that triggered the rescan. Destroying the service that holds the live ext-session-lock abandons the compositor-side lock and drops Hyprland into its lockscreen-died failsafe, which is the failure keepLoaded was added to prevent. Skip that one service for as long as it owns the lock. The signal is a new readonly property on the lock service rather than `locked`, which carries sessionLock.secure: secure resolves through the process-wide session-lock manager and an earlier teardown can leave it dangling, so a poisoned process would suppress every teardown for its whole life while protecting nothing. The skip is duck-typed rather than keyed on the omarchy.lock id so a cloned lock plugin is covered too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhPK6AtHo1fHNQBBNfKkpk
eee64ff to
64b9874
Compare
|
Force-pushed. The branch is rebuilt from current #9485 landed, and it changes what this PR should be. What the merge does not cover, and what is left here. I am deliberately not making the broader claim that any empty scan strands the lock. @omarchybot's still-open low finding — "collect[ed] after unlock" with nothing connecting unlock to The tests. @parker-brown-family — thank you for the caution about asserting on 🤖 Generated with Claude Code |
The lock service moved into AuthServiceStore when first-party plugins gained the authentication capability, so the teardown this branch guards has to be read against current quattro.
On quattro the first-party lock carries the authentication capability, so it is retained in AuthServiceStore rather than _services, and _syncServices destroys it through the authentication loop the existing skip never reaches. Disabling omarchy.lock while locked still dropped Hyprland into its lockscreen-died failsafe with this branch merged. The store answers whether a service owns the lock instead of handing the service out, so it still exposes no credential-bearing object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quattro's _syncServices destroys a published service earlier, when it gains the authentication capability, so the first .destroy() in the body is no longer the teardown's and the ordering assertion failed on the merged tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ordering checks searched raw source, so a guard commented out still satisfied them while the lock was destroyed again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
Reviewed and run on a disposable Omarchy VM. The bug is real, but on current What changed under it. Since this branch was cut, first-party plugins gained host capabilities (#9618), and Pushed to your branch:
Tests, on the VM at Second opinion: Codex Medium reviewed it over two rounds, and its independence from this review is not guaranteed. It found the commented-out-guard hole fixed above. It also pointed out that a lock copy declaring
I declined one further test point: a This now waits on the maintainer: whether the retention after unlock is acceptable, and whether to merge. |
unloadPluginServices spares a service by the keepLoaded of its current manifest, and the registry no longer lists a lock plugin removed while locked. The first reload after the removal leaves the lock to the _syncServices skip, and a second reload before unlock destroyed it. Both loops now also spare the instance that owns the session lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A published service that gains the authentication capability is destroyed and recreated in AuthServiceStore. For a lock copy that holds the session lock, that destroy abandoned the lock. It now stays where it is until a later sync. The reverse move needs no guard: the store keeps an id trusted for the life of the process, so a service it holds never loses the capability. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The teardown skips kept a lock service that was disabled or removed mid-lock until whichever pluginsChanged came next. Its lock IPC target kept answering in that window, so the disabled plugin could lock the screen again. The lock service now emits unlockSettled when an unlock's wake exits. If that service is no longer enabled and installed, or no longer belongs in the map it was placed in, the shell re-runs _syncServices, which collects or moves it. An ordinary unlock re-syncs nothing, so third-party services are not handed a fresh manifest copy on every unlock. The signal comes from the wake's exit, not from sessionLockOwned changing. Every unlock path gives up the lock before it starts the wake, and destroying the service kills a wake still in flight, because Quickshell kills a Process's child with the object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plugin change that lands between unlock and the wake's exit collects a disabled lock service while omarchy-system-wake is still running, and Quickshell kills a Process's child with its object, so the displays or keyboard backlight could stay off. The service now reruns the wake detached from Component.onDestruction when one is in flight. Every step of the wake is safe to repeat: the display step skips lit panels, and the keyboard step restores a saved value without consuming it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Enabling, disabling or removing a lock clone while locked swaps which member of the clone family the registry wants, while the member holding the lock is kept until unlock. _syncServices then mounted the other member beside it. That second lock service found the compositor lock held, took it for stranded and re-locked over it, which Quickshell answers with the qFatal traced in quickshell-mirror/quickshell#962 and still open as omacom#1054. That consequence is from reading the source and the upstream thread; it was not reproduced here. Both services also declared the lock IPC target. ensureService now records each service's clone family (its clone source, else its own id), and refuses a family member while another member holds the lock. The record outlives a removal, so a removed clone still matches. The re-sync after unlock mounts the waiting member. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The teardown loops in _syncServices keep a lock owner that is no longer installed, enabled and service-declaring, but the unlock re-sync only checked installed, enabled and classification. A lock clone whose manifest dropped its service entry point while locked was kept by the loop and then never collected, so its lock IPC target kept answering after unlock. Check the same service declaration the loops do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
Re-reviewed at On the VM. On current
Pushed to your branch: Tests, on the VM at Second opinion: Codex Medium reviewed the five new commits and then the fix, over two rounds. Its independence from this review is not guaranteed. It found the gap fixed above, and one more that is still open:
It also flagged two things as choices rather than defects: the detached wake rerun in This now waits on the maintainer: the open clone-retry gap, the scope of the wake rerun, and whether to merge. |
ensureService refuses a clone-family member while another member holds the session lock, and the unlock re-sync mounts it. But the re-sync only ran for a holder no longer wanted where it is. Enabling clone B while clone A holds the lock disables the first-party source, not A, so A stays wanted, its unlock re-synced nothing, and B stayed unmounted until the next plugin change. A refusal now marks the deferral, and the holder's unlock re-syncs while it is set. Each _syncServices pass clears it before mounting anything, so a member still refused on that pass marks it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re-reviewed at The new case, on the VM. Clone The original bug, re-checked at this head. On current Reading the change. Tests, on the VM at
Second opinion: none this round. Only Claude Opus 5.5 reviewed this commit. Codex Medium answers a ping, but omabot's daily review budget was used up before it could review this commit. Codex Medium did agree with classifying the PR as a bug fix. This now waits on the maintainer: a second review of |
A clone of omarchy.lock is a copy of Service.qml as it was when cloned, so one made before this branch has no sessionLockOwned and no unlockSettled. Every ownership skip read false for it, and disabling or removing it while locked still destroyed the live session lock, which is the setup reported in omacom#11389. The store now falls back to the clone's own locked for a service without sessionLockOwned, and such a clone re-syncs when locked falls instead of when its wake exits. Only authentication services get the fallback: those are omarchy.lock, omarchy.polkit and their clones, and polkit has no locked. Co-Authored-By: Taksh <takshkothari09@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I pushed two commits to this branch and re-ran it on a disposable Omarchy VM with a live What I pushed:
The description's line "A clone made before this change has no On the VM. The pre-change clone below is
Tests on the VM at
Second opinion: Codex Medium and muse-wonder (pi, thinking high) reviewed the merge and the new commit. Both found the merge sound and agreed that limiting the fallback to the authentication store is right. Both can read this session's working files, so that agreement is not guaranteed to be independent. Codex Medium raised one issue I have not changed. When a pre-change clone is collected right after unlock, it can still be running This waits on the maintainer: the scope of the wake rerun and of the family guard (both in the description), whether that wake gap for pre-change clones needs closing, and whether to merge. |
[Medium impact] The changes affect lock-service teardown, unlock, and clone swaps in the shell's plugin workflow. The testing-rule violation must be addressed before merging; no separate behavioral blocker was established. Findings
SummaryKeeps the service that owns the session lock alive across plugin disable, removal, reload, and capability changes.
Acknowledged scope: vonsensey leaves detached wake reruns during shell teardown and the breadth of the clone-family guard to the maintainer. Older non-authentication clones without No tests or graphical checks were run during this review.
|
| const syncGuardMatch = sync.match(/if \((.+?)\) continue\s*\n\s*if \(inst && typeof inst\.destroy/) | ||
| assert(syncGuardMatch, '_syncServices guards the destroy with a skip that continues') | ||
| assertEqual( | ||
| syncGuardMatch[1].trim(), | ||
| 'inst && inst.sessionLockOwned === true', | ||
| 'the skip fires when the instance owns the session lock -- not negated, not widened' |
There was a problem hiding this comment.
Tests check spelling, not teardown
These assertions require an exact spelling of the ownership guard rather than checking what teardown does. An equivalent rewrite fails, while broken control flow around the guard can pass.
AGENTS.md says not to restate the implementation and to extend an existing area test. Before merging, replace the source comparisons with checks that run the teardown logic against service objects, and put them in an existing lock or authentication suite. Keep the checks that already run real functions.
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!
Closes the teardown paths that #9485 left uncovered, for #7106.
The gap
#9485 made
unloadPluginServices()spare akeepLoadedservice, so a plugin hot-reload no longer destroysomarchy.lockwhile Hyprland still holds the session lock. Other paths still destroy the service that owns the liveWlSessionLock._syncServices()teardown. It destroys services inline, without going throughunloadPluginServices()and without consultingkeepLoaded, whenever the registry stops listing a plugin as installed, enabled and service-declaring. It does that in two loops. Since #9618,omarchy.lockdeclares theauthenticationhost capability, so its service is retained inAuthServiceStorerather than_services, and it is the second loop that reaches it:A lock copy that is not classified as an authentication service lives in
_servicesand reaches the first loop'sinst.destroy()instead.omarchy plugin removereaches the same teardown through its ownsetPluginEnabled <id> falsestep (bin/omarchy-plugin-remove:96). So does a local lock clone whosemanifest.jsonis unreadable at the moment the rescan reads it:parseScanOutputdrops that one plugin from the registry, and_syncServicesthen destroys its service. That is the "local lock-plugin clone" shape reported in #7106.A second reload.
unloadPluginServices()spares by the current manifest'skeepLoaded, and the registry no longer lists a lock copy removed mid-lock. The first reload leaves the lock to the_syncServicesskip; a second reload before unlock destroyed it.omarchy plugin removeends in a rescan, and onegit pullin a plugin checkout produces several watcher events, so the second reload needs no second user action.A capability change. A published service that gains the
authenticationcapability is destroyed and recreated inAuthServiceStore. For a lock copy holding the lock, that destroy abandons it. This one is from reading the source, not reproduced.A clone swap. Enabling a lock clone disables its source in the same mutation (
PluginRegistry.qml:548-549), and disabling or removing the clone restores the source. Done while locked, the member holding the lock is retained, and_syncServicesmounted the other member beside it. That second lock service finds the compositor lock held, takes it for stranded, and re-locks over it, which Quickshell answers with theqFataltraced in quickshell-mirror/quickshell#962 and still open as #1054. Both services also declaretarget: "lock". This consequence is from reading the source and the upstream thread, not reproduced.The disable path was reproduced on a VM on current
quattro, and the second reload at64b98747. Both end the waykeepLoadedwas added to prevent: the compositor-sideext-session-lockis abandoned without an unlock, Hyprland shows its lockscreen-died failsafe, and the process-global lock manager is left dangling so in-process recovery cannot retake the lock.The change
Skip the service that owns the lock at every destroy that can reach it, and collect it once it lets go.
_syncServices, authentication loop.AuthServiceStore.ownsSessionLock(id)answers yes or no, so the store still hands out no service object. This is the guard that protectsomarchy.lockon currentquattro, and a lock clone declaringclonedFrom: "omarchy.lock", which inherits the capability._syncServices,_servicesloop.inst.sessionLockOwned === truecovers a lock copy that is not classified as an authentication service.unloadPluginServices, both loops. The same two checks, beside thekeepLoadedspare.authenticationstays where it is until a later sync. The reverse move needs no guard:AuthServiceStorekeeps an id trusted for the life of the process, so a service it holds never loses the capability.unlockSettledwhen an unlock's wake exits. If that service is no longer installed, enabled and service-declaring (the same test both teardown loops use), or no longer belongs in the map it was placed in, or a family member was refused while it held the lock (below), the shell re-runs_syncServices, unless a reload in flight is about to. That pass collects a service the user disabled or removed, or moves one whose capability changed, so itslockIPC target stops answering. An ordinary unlock re-syncs nothing, so third-party services are not handed a fresh manifest copy on every unlock. The signal comes from the wake's exit rather than fromsessionLockOwnedchanging, because every unlock path gives up the lock before it startsomarchy-system-wake, and destroying the service kills a wake still in flight: Quickshell kills aProcess's child with the object.Component.onDestructionwhen one is in flight. Every step is safe to repeat: the display step skips lit panels, and the keyboard step restores a saved value without consuming it. The normal path does not rely on this, so the wake runs once.ensureServicerecords each service's clone family (itsclonedFromsource, else its own id) and refuses a family member while another member holds the lock. The record outlives a removal, so a removed clone still matches. The holder can stay wanted (enabling a second clone disables the first-party source, not the holder), so a refusal sets_familyMountDeferred, and the holder's unlock re-syncs while it is set. That pass mounts the waiting member. Each_syncServicespass clears the mark before mounting anything, so a member still refused marks it again.All the skips read a new
sessionLockOwnedon the lock service rather than the existinglocked.lockedcarriessessionLock.secure, which resolves through the process-wide session-lock manager; an earlier teardown can leave it dangling, so a guard reading it would suppress every teardown for the life of a poisoned process while protecting nothing.lockRequestedis the shell's own state andsessionLock.lockedis the instance-localSessionLockManager::mLock, both deterministic on a rebuilt service.The skips and the signal are duck-typed rather than keyed on the
omarchy.lockid, so a cloned lock plugin gets the same protection. A clone made before this change has nosessionLockOwnedand is not covered until it is cloned again.What this does not do
~QSWaylandSessionLock()releases the Wayland object without clearing the process-globalQSWaylandSessionLockManager::active, so the pointer dangles for the life of the process. The abort it leads to is still open as feat: Add atuin in terminal tools #1054, reported there for a lock orphaned by a crashed instance. This keeps Omarchy from reaching it.Testing
test/shell.d/lock-service-teardown-test.sh, 54 assertions. Guard checks run on brace-matched function bodies with comments stripped, and compare whole conditions and operand sets, because token-presence matching cannot tell a guard that works from one that reads as present and does nothing.ownsSessionLockis run against the realAuthServiceStore.jsin a Node VM, and the realsyncServicesAfterUnlockandsessionLockHeldByFamilybodies against stubs. Each of these breakages makes the file fail:!== true) or widened (!== false), orif (false && serviceKeepLoaded(...))ownsSessionLockanswering for a service without the lock, or one it does not holdunlockSettledconnection removed, or made after the service is storedensureServicesyncServicesAfterUnlockbody_syncServicesnot clearing it before it mountsensureServiceand_syncServicesunlockSettledemitted without the ownership check, or from asessionLockOwnedchangestartDetachedcountensureServicedeleted, commented out or negated, the family record deleted, or the family ignoringclonedFromensureServicesessionLockHeldByFamilyblocking a plugin itself, ignoring the family, ignoring ownership, or missing an owner in either mapsessionLockHeldByFamilybodysessionLockOwnedchanged from OR to ANDsessionLock.secureadded tosessionLockOwned, directly or through a helper propertyA
/* */block comment or an early return around a guard still gets past a text-matching test; covering every such edit is not proportionate.@omarchybot ran
61dcbe2eon a disposable Omarchy VM against a livesecure=truelock.omarchy plugin disable omarchy.lockwhile locked drops Hyprland into the lockscreen-died failsafe onquattro, and again on this branch before the authentication-loop skip. With it, the lock screen and its password field stay up and thelockIPC target still answers.It then ran
987de0adon the VM, covering the five commits after61dcbe2e. Onquattro(97a9fce5), and on this branch with the three shell files reverted, disablingomarchy.lockwhile locked still drops into the failsafe. On this branch:rescanPluginsreloads. The lock screen stays up, thelocktarget answers, and the shell process never restarts.omarchy plugin enable omarchy.lockbrings it back. An ordinary unlock leaves the service in place.omarchy plugin remove <clone> --yeswhile the clone holds the lock, then two reloads. The lock holds, and after unlock the restoredomarchy.lockis mounted.987de0aditself is the bot's: the post-unlock check now uses the service-declaration test the loops use.It then ran
60c7ca2e(the refused-member deferral) on the VM. Setup: cloneomarchy.lockto A, add a disabled second clone B, lock, then enable B while A holds the lock.987de0ad, B is refused while locked and is still not mounted after the password unlock.60c7ca2e, B is mounted about three seconds after unlock.The original disable-while-locked case, rechecked at this head against
quattro(b18ab495), behaves as above. On the VM at60c7ca2e, the full./test/shellfails 7 of 286 files, all of which fail the same way onquattro.Locally at
60c7ca2e:lock-service-teardownpasses 54/54. Its new case fails without the fix.plugin-auth-boundary,plugins,plugin-registry-contract,lock-stranded-recovery,system-lock,sleep-lock,plugin-enable,plugin-clone,restart-shell,runtime-smoke(which loads the shell with the changed code),hyprland-session-locked,lock-blank-fingerprintandlock-password-overflow.qmlformatparsesshell.qml../test/shellfails 11 of 286 files, the same count as at1b376039,a1697289and61dcbe2e. None are in lock or plugin code (config,snapper,unowned-system-pathsand eight others).On the bot's VM,
./test/clihas one failure,vscode generated theme references current theme file, which fails the same way onquattro. The two Quickshell behaviours the collection relies on were checked in a throwawayqsinstance:ProcesschildstartDetached()fromComponent.onDestructionstill runs a fresh copyLeft to the maintainer
Component.onDestructionreruns an in-flight wake detached for any destroy, including shell teardown. The wake steps are safe to repeat, but it is the most discretionary part of the change.clonedFromis a lock, whatever that plugin implements.History
This PR previously carried a second mechanism: deferring the whole reload until unlock, with a slow poll during the lock, plus a refusal in
omarchy plugin addandomarchy plugin clonefor the window where discovery was deferred. #9485 made the deferral redundant for the reload path it protected, and the CLI refusal existed only to cover the discovery gap the deferral opened, so both were removed. #9618 then movedomarchy.lockintoAuthServiceStore, so the branch was brought up to date withquattroand given the matching skip in the authentication loop. The review of that round listed the remaining gaps (a second reload, the capability change, retention after unlock), and three commits close them. Two more close what those left open: a wake cut short by a plugin change right after unlock, and a second lock service mounted by a clone swap while locked. The bot's next round added the service-declaration check (987de0ad) and found one more gap: a clone refused while a still-wanted sibling held the lock was never mounted after unlock.60c7ca2ecloses it.🤖 Generated with Claude Code
https://claude.ai/code/session_01LhPK6AtHo1fHNQBBNfKkpk
Fixes #11389