Skip to content

Plugin: detect and reject stale worktree paths on resume#34

Open
huntharo wants to merge 1 commit intopwrdrvr:mainfrom
huntharo:codex/detect-removed-worktree-on-resume
Open

Plugin: detect and reject stale worktree paths on resume#34
huntharo wants to merge 1 commit intopwrdrvr:mainfrom
huntharo:codex/detect-removed-worktree-on-resume

Conversation

@huntharo
Copy link
Contributor

Summary

Adds an early guard in requestConversationBinding() (src/controller.ts) that checks whether a worktree-shaped workspace path still exists on disk before binding the conversation. Returns a clear error immediately instead of letting Codex fail later with a cryptic shell or git error.

Why this matters

From #27: a thread can be resumed even if its recorded cwd no longer exists. The failure only shows up later when Codex tries to execute shell commands in the missing directory — at which point the error is confusing and hard to connect back to the missing worktree.

Early detection turns a cryptic downstream failure into an immediate, actionable message:

Cannot resume: workspace path no longer exists on disk.
`/path/to/worktrees/bold-bartik/repo`

The worktree may have been removed. Check your local paths or start a new session.

Changes

  • src/controller.ts: added existsSync import from node:fs. Added guard in requestConversationBinding() (right after the !requestBinding check) that returns { status: "error" } if the workspace path matches the worktree pattern and doesn't exist on disk.
  • src/controller.test.ts: added a test covering resume with a nonexistent worktree path — asserts the error reply is returned before any binding proceeds.

The check is scoped to worktree-shaped paths (/worktrees/branch/repo) using the existing isWorktreePath() helper, avoiding false positives on configurable workspace roots that may not be local paths.

Testing

All 122 tests pass (pnpm typecheck + pnpm test).

Fixes #27

This contribution was developed with AI assistance (Claude Code).

Adds an early guard in requestConversationBinding() that checks whether a
worktree-shaped workspace path still exists on disk before binding the
conversation. Returns a clear error message immediately instead of letting
Codex fail later with a cryptic shell or git error.

The check is scoped to worktree paths (matching the /worktrees/ pattern)
to avoid false positives on configurable workspace roots that may not be
local paths.

Fixes pwrdrvr#27
Copy link

@mvanhorn mvanhorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The early guard catches the stale worktree case before Codex hits a cryptic shell error downstream. Scoping to isWorktreePath() avoids false positives on non-worktree workspace roots. Error message is clear and actionable.

Recommendation

Looks good to merge.


Review assisted by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin: detect threads whose worktree path was removed

2 participants