v0.2.2: detached-session cleanup (shell ccclean + voice/CLI cleanup)
add a detached-only session cleanup in BOTH surfaces — the cc shell kit and the
claudedo daemon — so stale detached claude-* sessions can be cleared from either.
- cc.sh: ccclean kills DETACHED claude-* sessions only (tmux #{session_attached}==0),
never attached; reports 'killed X, Y (2 detached); kept Z (attached)' or 'nothing to
clean'. complements cckl (kill ALL incl attached), which stays the deliberate typed
nuke. header updated; sources clean under bash + zsh.
- target.py: cleanup_detached() kills detached claude-* and returns (killed, kept)
lists. it and list_sessions() now share ONE tmux query, _claude_sessions(), which
returns (name, attached) pairs — single source for session enumeration.
- grammar: cleanup command (aliases detached/detach) routes to Action('system',
'cleanup') — daemon-control, never injects. bare 'cleanup' and 'system cleanup' both
accepted. 'clean'/'wipe' deliberately NOT used as aliases — they fuzzy-collide with
erase's 'clear'/'wipe' (0.8 ratio); 'detached' is distinct. confirm command added for
the opt-in confirm flow.
- daemon: system 'cleanup' -> _do_cleanup -> target.cleanup_detached, reports
'[SYSTEM] cleanup: killed ...; kept ... (attached)'. behavior.cleanup_confirm
(default false) announces and waits for a following 'confirm' before killing.
- CLI: 'claudedo cleanup' (self-contained tmux op, no running daemon needed).
safety model: detached-only means a misheard voice cleanup can NEVER kill the active
(attached) session. the only kill-attached path remains the shell cckl.
Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
+30
-1
@@ -11,7 +11,8 @@
|
||||
# ccr <name> reattach only (error if it doesn't exist); writes ~/.claude-active
|
||||
# ccl list running claude- sessions
|
||||
# cck <name> kill claude-<name>
|
||||
# cckl kill ALL claude- sessions
|
||||
# ccclean kill DETACHED claude- sessions only (never attached) — safe cleanup
|
||||
# cckl kill ALL claude- sessions (including attached)
|
||||
|
||||
cc() {
|
||||
if [ -z "$1" ]; then
|
||||
@@ -60,6 +61,34 @@ cck() {
|
||||
fi
|
||||
}
|
||||
|
||||
ccclean() {
|
||||
killed=""
|
||||
kept=""
|
||||
while read -r name attached; do
|
||||
case "$name" in
|
||||
claude-*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
if [ "$attached" = "0" ]; then
|
||||
if tmux kill-session -t "$name" 2>/dev/null; then
|
||||
killed="${killed:+$killed, }$name"
|
||||
fi
|
||||
else
|
||||
kept="${kept:+$kept, }$name"
|
||||
fi
|
||||
done <<EOF
|
||||
$(tmux list-sessions -F '#{session_name} #{session_attached}' 2>/dev/null)
|
||||
EOF
|
||||
if [ -z "$killed" ]; then
|
||||
echo "nothing to clean (no detached sessions)"
|
||||
else
|
||||
n=$(printf '%s' "$killed" | awk -F', ' '{print NF}')
|
||||
msg="killed $killed ($n detached)"
|
||||
[ -n "$kept" ] && msg="$msg; kept $kept (attached)"
|
||||
echo "$msg"
|
||||
fi
|
||||
}
|
||||
|
||||
cckl() {
|
||||
tmux ls 2>/dev/null | grep '^claude-' | cut -d: -f1 | while read -r s; do
|
||||
tmux kill-session -t "$s" && echo "killed $s"
|
||||
|
||||
Reference in New Issue
Block a user