fix: improve worktree/session handling in cmd_start and cmd_continue #195

Merged
shoko merged 1 commits from fix/issue-daemon-worktree-session-handling into main 2026-04-07 03:41:28 +02:00
Owner

Bug

When daemon calls cmd_continue for an issue where session file exists but worktree doesn't, it would silently fail - agent gets forked but no worktree exists.

Fix

cmd_continue

  • Check if worktree exists before continuing
  • If worktree is missing, remove stale session file and exit with error
  • Tell user to use cmd_start instead

cmd_start

  • Check BOTH worktree AND session existence
  • If only worktree exists (not session): remove worktree, recreate both fresh
  • If only session exists (not worktree): remove session, recreate both fresh
  • If both exist: tell user to use continue

Daemon

  • Fixed wrong path in check_task_completion ($HOME/.kugetsu-worktrees -> $WORKTREES_DIR)

Design Principles

  • Daemon stays lean - delegates logic to separate functions
  • Functions handle edge cases rather than daemon
  • Session/worktree consistency is maintained
## Bug When daemon calls `cmd_continue` for an issue where session file exists but worktree doesn't, it would silently fail - agent gets forked but no worktree exists. ## Fix ### `cmd_continue` - Check if worktree exists before continuing - If worktree is missing, remove stale session file and exit with error - Tell user to use `cmd_start` instead ### `cmd_start` - Check BOTH worktree AND session existence - If only worktree exists (not session): remove worktree, recreate both fresh - If only session exists (not worktree): remove session, recreate both fresh - If both exist: tell user to use `continue` ### Daemon - Fixed wrong path in `check_task_completion` (`$HOME/.kugetsu-worktrees` -> `$WORKTREES_DIR`) ## Design Principles - Daemon stays lean - delegates logic to separate functions - Functions handle edge cases rather than daemon - Session/worktree consistency is maintained
shoko added 1 commit 2026-04-07 03:30:09 +02:00
cmd_continue:
- Check if worktree exists before continuing
- If worktree is missing, remove stale session and exit with error
- Tell user to use cmd_start instead

cmd_start:
- Check BOTH worktree AND session existence
- If only worktree exists (not session): remove worktree, recreate both
- If only session exists (not worktree): remove session, recreate both
- If both exist: tell user to use continue

Daemon:
- Fixed wrong path in check_task_completion ($HOME/.kugetsu-worktrees -> $WORKTREES_DIR)
shoko force-pushed fix/issue-daemon-worktree-session-handling from 4ec76b1248 to de1b02c585 2026-04-07 03:34:18 +02:00 Compare
shoko force-pushed fix/issue-daemon-worktree-session-handling from de1b02c585 to 9d0bcef465 2026-04-07 03:40:29 +02:00 Compare
shoko merged commit 478f7ceeba into main 2026-04-07 03:41:28 +02:00
Sign in to join this conversation.