From 07c112ab472ee303b3d0b782901f4ed6941bfd87 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Wed, 11 Nov 2026 10:25:05 -0700 Subject: [PATCH 1/2] fix(runner): clean runner checkouts after every session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Short Summary (TL;DR) Runner checkouts are now cleaned after every session and before every runner start. A session's leftovers are kept as stashes or rescue directories, so a new session no longer starts in a mess it can't clean. ## The Issue A runner keeps its clones in `~/workspace/runner-` from one session to the next. Nothing cleaned them, so sessions left uncommitted changes, untracked files, worktrees and extra clones behind. The runner's `--release-idle-session-min 30` releases a session after 30 idle minutes, dirty or not. Coder stopping the workspace kills the runner mid-session. The next session found those files and was told not to delete them without the user's approval. A web session often can't get that approval, and the skill suggested a worktree for a second checkout. So sessions created worktrees and clones to get around the leftovers, which made the next checkout worse. The SessionStart hook added in #234 also ran on `compact` and `clear`. At that point the dirty files are the session's own work. ## How This PR Solves The Issue - New `claude-runner-sweep ` cleans one runner's directory, and loses nothing a commit or remote doesn't already hold. - In the runner's own clones, it stashes uncommitted changes, including untracked files, as `runner-rescue` stashes. - It stashes changes in worktrees the same way, then removes the worktrees. - It deletes other clones a session made if everything in them is pushed. Otherwise it moves them, and broken worktrees, to `~/.local/state/claude-runner-rescue//