Skip to content

Recover shell restarts when the replacement launch is rejected - #11014

Closed
anovoselnik wants to merge 1 commit into
omacom:quattrofrom
anovoselnik:fix/dictation-shell-recovery
Closed

anovoselnik wants to merge 1 commit into
omacom:quattrofrom
anovoselnik:fix/dictation-shell-recovery

Conversation

@anovoselnik

Copy link
Copy Markdown

Closing the Dictation configuration terminal on Omarchy 4.0.3 left the bar down. The journal recorded Exiting due to IPC request, followed five seconds later by An instance of this configuration is already running. No core dump was recorded, and no Quickshell process remained afterward.

The restart command dispatches its replacement only once. If that launch is rejected while the old instance still holds its singleton lock, readiness polling cannot bring the shell back. Retry the existing no-duplicate launch every two seconds within a 30-second readiness deadline. Keep the active lock-screen guard and stranded-lock recovery intact.

This extends the longer readiness window proposed in #8630, credited in the commit. Unlike #10634 (overlapping restart requests), it handles a rejected replacement within a single restart. The missing-Voxtype install guard is already covered by #6832 and is outside this PR.

Validation:

  • Regression tests fail against the unchanged upstream restart command for both slow readiness and a rejected first launch, and pass with this change.
  • bash test/shell.d/restart-shell-test.sh, bash -n, and git diff --check pass, including active-lock preservation and stranded-lock recovery.
  • Live candidate restart succeeds and the replacement answers shell ping. The original singleton-lock timing has not been deterministically reproduced on the live desktop; its failure path is exercised with stubbed launch/IPC boundaries.
  • ./test/all: CLI passes; 230 of 236 shell test files pass. Six failures reproduce with the unchanged upstream restart script: config, launch-about, locate, network-qr, snapper, and unowned-system-paths. These include missing sibling packaging-checkout coverage and unrelated environment/test failures.

Prepared with Codex.

Allow a 30-second readiness window and retry the no-duplicate launch every two seconds. Cover a rejected first launch, slow startup, and the existing locked-session protections.

Co-authored-by: Jacky Lam <lamchun1110@gmail.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed against current quattro, alongside #13141, which fixes the same failed restart a different way. Both were read by Claude Opus 5.5 and by Codex Medium as a second opinion; Codex was asked which fix is better before it saw my answer, and picked #13141 for the same reasons (independence is not guaranteed, since it can read this session's notes). Nothing was run on a worker: whichever fix the maintainer goes ahead with gets that, and this one is waiting on that choice.

The five-second gap in the journal matches the kill loop in bin/omarchy-restart-shell: while timeout 5 quickshell kill … treats the timeout's exit status 124 as "no instances left" and launches straight away while the old shell is still exiting. Quickshell's duplicate refusal exits 0, so omarchy-launch-shell takes it as a deliberate stop and does not relaunch. That leaves nothing running.

This PR retries the launch every two seconds, but it checks omarchy-shell shell ping first on every pass, and omarchy-shell talks to whichever matching instance is newest. If the old shell still answers while it is going down, restart relocks if needed, reports success and exits before any retry. Then the old shell finishes exiting and there is no bar, which is the symptom this PR is fixing. #13141 waits until quickshell list shows no instance for the config before it launches anything, so a ping can only come from the replacement. That fixes the cause rather than working around it. Its SIGKILL fallback has a side effect: the killed shell's supervisor exits with status 137 and may try its own relaunch. That side effect is bounded, and the review of #13141 will cover it.

The 30-second readiness window in this PR is also proposed on its own in #8630.

Both branches also conflict with quattro, which now waits for the notification service after relocking. Whichever fix goes ahead has to keep that order: relock, then notifications, then invitations.

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

@omarchybot

Copy link
Copy Markdown
Collaborator

Closing this alternative after #11015 merged into quattro. The merged restart gives the old shell 30 seconds to exit and then checks for its disappearance before replacing it; the worker reproduction covered the seven-second slow-exit race. This settles the reported five-second duplicate-refusal case. Force-killing permanently wedged instances and retrying other launch failures are not claimed fixed.

Scope checked by GPT-6 in Codex and Codex Medium against the discussion and landed change; review independence is not guaranteed. No tests were rerun for this cleanup.

Omabot on behalf of DHH

@omarchybot omarchybot closed this Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants