Coalesce concurrent shell restarts - #10634
Open
chivopic wants to merge 1 commit into
Open
Conversation
|
@robosayem review this |
robosayem
approved these changes
Sep 7, 2026
robosayem
left a comment
There was a problem hiding this comment.
Verified on head d7f1f10 — approve.
restart-shell-concurrency-testpasses, and the existingrestart-shell-teststill passes with the lock in place (8 assertions including locked-session preservation and crash recovery, which exercise the script far past the new guard)- The guard sits after the
CONFIG_DIRexistence check, so a misconfigured invocation still fails fast with its real error instead of being silently coalesced - Lock-hold duration is bounded by construction: the relock loop runs to a
SECONDSdeadline, the duplicate-instance kill loop is wrapped intimeout 5, and the new-shell ping loop is capped at 20 attempts — so a wedged restart releases the lock eventually and cannot permanently suppress future restarts - The idiom matches existing Omarchy code exactly (
omarchy-brightness-displayandomarchy-system-lockboth useflock -n || exit 0on anXDG_RUNTIME_DIR-based lock), so this is the established coalescing pattern, not a new invention
One tradeoff worth naming for the record: exit 0 on contention means an overlapping invocation also swallows the first attempt's failure — if the in-flight restart dies mid-flight, a user's immediate retry no-ops. The kernel releases the lock when the holder exits, so a later retry always works; acceptable, just noting the semantics.
Also for whoever merges: this touches the same file as PR #9469 (insert at ~line 14 vs #9469's additions further down), no textual conflict, but rebase order matters for both.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #10098.
omarchy-restart-shellcan be invoked twice in quick succession, for example by double-clicking the Dictation indicator. The first invocation may already have killed the old shell and started its replacement when the second invocation enters the kill loop, allowing the second restart to terminate the new Quickshell instance while it is still loading.Coalesce overlapping restart requests with a non-blocking
flockin the user runtime directory. The in-flight restart already satisfies the overlapping request, so later concurrent invocations exit successfully instead of entering the kill/relaunch sequence again.This follows the existing Omarchy pattern used for other duplicate event-driven actions such as display brightness handling.
Testing
test/shell.d/restart-shell-concurrency-test.sh.omarchy-restart-shell, and asserts the overlapping invocation exits successfully before reaching lock inspection, Quickshell kill, or Hyprland dispatch.