fix(dev): name AFK worktrees without a tilde so edits auto-approve #72

Merged
dominik.polakovics merged 1 commit from fix/lab-afk-worktree-path-8.3 into main 2026-06-01 21:26:54 +02:00

Symptom

Starting an AFK run stalls: the agent freezes on a Do you want to make this edit to <file>? permission prompt and, with no one at the keyboard, never proceeds. Diagnosed against a live run (#63) frozen on exactly that prompt for tracker.go.

Root cause

This is not the MCP/folder-trust prompt the earlier #69–#71 fixes addressed. Auto mode already auto-approves workspace edits — the problem is the worktree path itself.

worktreePath joined the project name and issue number with instanceSep (~), so an AFK run's working directory was e.g. …/cloonar-cloonar-nixos~63. The ~63 component matches the Windows 8.3 short-name pattern (PROGRA~1), which claude treats as a path-confusion risk and forces manual approval for every file edit, in any --permission-mode (auto included).

Reproduced cleanly with claude --permission-mode auto:

  • in a normal repo → Write is auto-approved;
  • in a tilde~1-named dir → refused with "…the working directory path contains tilde~1, which matches a suspicious Windows short-name (8.3) pattern and requires manual approval. I can't override that."

Fix

Give the worktree path its own filesystem-safe separator (-) instead of reusing the tmux-oriented instanceSep. Session names keep ~ — it's the one separator tmux's target-pane parser doesn't reserve, and a session name is never a filesystem path. The new directory name also matches what git already derives for the worktree's admin dir under .git/worktrees/.

worktreePath("cloonar-cloonar-nixos", 63)…/cloonar-cloonar-nixos-63

Tests

  • New TestWorktreePath_no83ShortName guards the worktree name against any ~ (regression guard; would fail against the old ~-joined path).
  • Full go test ./..., go vet ./..., go build ./... pass locally — the pre-commit hook is eval-only and never compiles the Go, so these were run by hand.
## Symptom Starting an AFK run stalls: the agent freezes on a `Do you want to make this edit to <file>?` permission prompt and, with no one at the keyboard, never proceeds. Diagnosed against a live run (#63) frozen on exactly that prompt for `tracker.go`. ## Root cause This is **not** the MCP/folder-trust prompt the earlier #69–#71 fixes addressed. Auto mode already auto-approves workspace edits — the problem is the worktree path itself. `worktreePath` joined the project name and issue number with `instanceSep` (`~`), so an AFK run's working directory was e.g. `…/cloonar-cloonar-nixos~63`. The `~63` component matches the Windows **8.3 short-name pattern** (`PROGRA~1`), which claude treats as a path-confusion risk and forces manual approval for **every file edit, in any `--permission-mode` (auto included)**. Reproduced cleanly with `claude --permission-mode auto`: - in a normal repo → Write is auto-approved; - in a `tilde~1`-named dir → refused with *"…the working directory path contains `tilde~1`, which matches a suspicious Windows short-name (8.3) pattern and requires manual approval. I can't override that."* ## Fix Give the worktree path its own filesystem-safe separator (`-`) instead of reusing the tmux-oriented `instanceSep`. Session names keep `~` — it's the one separator tmux's target-pane parser doesn't reserve, and a session name is never a filesystem path. The new directory name also matches what git already derives for the worktree's admin dir under `.git/worktrees/`. `worktreePath("cloonar-cloonar-nixos", 63)` → `…/cloonar-cloonar-nixos-63` ## Tests - New `TestWorktreePath_no83ShortName` guards the worktree name against any `~` (regression guard; would fail against the old `~`-joined path). - Full `go test ./...`, `go vet ./...`, `go build ./...` pass locally — the pre-commit hook is eval-only and never compiles the Go, so these were run by hand.
worktreePath joined project and issue with instanceSep ("~"), so an AFK run's working directory was e.g. ".../cloonar-cloonar-nixos~63". The "~63" component matches the Windows 8.3 short-name pattern (PROGRA~1), which claude treats as a path-confusion risk and forces manual approval for every file edit — silently stalling an unattended AFK run on its first edit, in any --permission-mode (auto included). Reproduced with a tilde-named cwd, which claude blocks citing exactly that 8.3 reason.

Give the worktree path its own filesystem-safe separator ("-") instead of reusing the tmux-oriented instanceSep; session names keep "~" (the one separator tmux's target-pane parser doesn't reserve, and a session name is never a filesystem path). The new name also matches what git already derives for the worktree's admin dir under .git/worktrees/.
dominik.polakovics deleted branch fix/lab-afk-worktree-path-8.3 2026-06-01 21:26:54 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Cloonar/nixos!72
No description provided.