-
Notifications
You must be signed in to change notification settings - Fork 0
Fix session discovery for Claude Code --worktree sessions #144
Description
Description
Claude Code has a --worktree flag that creates its own git worktrees under .claude/worktrees/<branch>/. When this flag is used, Claude Code keys the session directory to the main repo path rather than the worktree path. Partio's session discovery doesn't account for this, causing partio rewind, partio doctor, and the post-commit hook's session linking to silently fail.
This mirrors the fix in entireio/cli#817.
Root cause
find_session_dir.go walks up from the worktree root. But when Claude Code's --worktree creates sub-worktrees under .claude/worktrees/, the session is keyed to the parent (main repo root), not the worktree root. The walk-up logic misses this.
What to fix
In internal/agent/claude/find_session_dir.go:
- Detect if the current path is inside a
.claude/worktrees/<branch>/directory (Claude-managed worktree). - Resolve the main repo root (directory above
.claude/) and use it as the session key. - Add a table-driven test covering this case.
Why
Users who run Claude with --worktree get no checkpoints — a silent failure. Hooks run but sessions are never linked to commits.
Source
Inspired by entireio/cli#817
Acceptance Criteria
partio rewindfinds sessions when Claude Code was launched with--worktreepartio doctorcorrectly identifies the session directory in this casefind_session_dir.goresolves the main repo root when inside.claude/worktrees/<branch>/- Existing worktree tests still pass
- New table-driven test covers the
--worktreecase