Plugin: detect and reject stale worktree paths on resume#34
Open
huntharo wants to merge 1 commit intopwrdrvr:mainfrom
Open
Plugin: detect and reject stale worktree paths on resume#34huntharo wants to merge 1 commit intopwrdrvr:mainfrom
huntharo wants to merge 1 commit intopwrdrvr:mainfrom
Conversation
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
mvanhorn
reviewed
Mar 22, 2026
mvanhorn
left a comment
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
cwdno 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:
Changes
src/controller.ts: addedexistsSyncimport fromnode:fs. Added guard inrequestConversationBinding()(right after the!requestBindingcheck) 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 existingisWorktreePath()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).