feat: add shell -r/--restart for race-free shell restarts - #146
Open
dadams-AU wants to merge 1 commit into
Open
Conversation
Kills any running instance, waits for it to actually disappear from `qs list`, then starts the shell. Escalates to SIGKILL if the instance does not exit gracefully within 5s. Closes caelestia-dots#139 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
read contributing, NO AI CODE |
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.
Implements option 2 from #139, as discussed there.
What it does
caelestia shell -r(composes with-dand--log-rules):qs -c caelestia kill).qs -c caelestia list -juntil the instance actually disappears — teardown is not instant, and is slowest while a session lock is up, which is exactly when a reliable restart matters most.SIGKILLon the recorded PIDs (with a warning), waits again briefly, then proceeds.With no instance running it behaves like a plain start, so it's safe as the default "get me a shell" keybind.
Why not just propagate the exit status (option 1)
While implementing this I found that
qs -nitself exits 0 on the duplicate no-op:so propagating
subprocess.run's return code fromshell -dwouldn't have helped — pollingqs listis the only reliable way to detect the case. That makes--restartthe fix rather than a convenience.Testing
On a live session (Hyprland, quickshell-git):
shell -r -dwith a running instance: old instance killed and fully gone, new instance up and IPC-responsive, exactly one instance inqs listafterwards.qs -c caelestia kill; sleep .1; caelestia shell -r -d(restart requested mid-teardown) — waits out the dying instance and launches cleanly, whereshell -dpreviously no-op'd and left zero shells.shell -dwith a running instance is unchanged (message + exit 0, no second instance).Also adds the flag to the fish completions.
🤖 Generated with Claude Code