fix: Include dirty worktree paths in commit prompt and fix retry counter

Three bugs fixed in auto-cleanup commit retry flow:

1. resumeForCommit now calls getDirtyWorktreePaths() to include specific
   project subdirectory names in the prompt, so the agent knows which
   dirs to cd into and commit (instead of running git from the non-repo
   parent dir).

2. Removed finally block in tryAutoCleanup that reset the retry counter
   after every call, making MAX_COMMIT_RETRIES ineffective. Counter is
   now only cleaned up on success, max retries, or error.

3. resumeForCommit returns false early if no worktrees are actually
   dirty, preventing unnecessary commit retries for clean agents.
This commit is contained in:
Lukas May
2026-02-10 13:44:10 +01:00
parent a6371e156a
commit 60f06671e4

View File

@@ -114,6 +114,18 @@ cw account add --token <token> --email user@example.com
Stored as `credentials: {"claudeAiOauth":{"accessToken":"<token>"}}` and `configJson: {"hasCompletedOnboarding":true}`. Stored as `credentials: {"claudeAiOauth":{"accessToken":"<token>"}}` and `configJson: {"hasCompletedOnboarding":true}`.
## Auto-Cleanup & Commit Retries
After an agent completes (status → `idle`), `tryAutoCleanup` checks if its project worktrees have uncommitted changes:
1. `CleanupManager.getDirtyWorktreePaths()` runs `git status --porcelain` in each project subdirectory (not the parent `agent-workdirs/<alias>/` dir)
2. If all clean → worktrees and logs removed immediately
3. If dirty → `resumeForCommit()` resumes the agent's session with a prompt listing the specific dirty subdirectories (e.g. `- \`my-project/\``)
4. The agent `cd`s into each listed directory and commits
5. On next completion, cleanup runs again. `MAX_COMMIT_RETRIES` (1) limits retries — after that the workdir is left in place with a warning
The retry counter is cleaned up on: successful removal, max retries exceeded, or unexpected error. It is **not** cleaned up when a commit retry is successfully launched (so the counter persists across the retry cycle).
## Log Chunks ## Log Chunks
Agent output is persisted to `agent_log_chunks` table and drives all live streaming: Agent output is persisted to `agent_log_chunks` table and drives all live streaming: