Repository navigation
Conversation
When a worktree is removed and the user's CWD becomes invalid, the hint now checks whether `wt switch ^` would actually work (default branch has an existing worktree) before suggesting it. Three-tier fallback: 1. Default branch worktree exists → suggest `wt switch ^` 2. Repo found but no default branch worktree → suggest `wt list` 3. No repo found at all → plain "Current directory was removed." Closes #1168 Thanks to @davidbeesley for reporting. Co-Authored-By: Claude <[email protected]>
The test was calling `cwd_removed_hint()` which depends on the host repo having a default branch worktree. In CI's checkout this isn't guaranteed. Use `hint_for_repo()` with a purpose-built test repo instead. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
previously approved these changes
Mar 1, 2026
worktrunk-bot
left a comment
Collaborator
There was a problem hiding this comment.
Minor nit: the doc comment on try_repo_at still references "the fallback hint in main.rs" but that logic now lives in cwd_removed_hint() in the same file.
Same root cause as the unit test fix: without explicit PWD, CI's checkout doesn't have a default branch worktree, so recovery falls through to the `wt list` hint instead of `wt switch ^`. Also updates stale doc comment on try_repo_at. Co-Authored-By: Claude <[email protected]>
On Windows, `current_dir()` succeeds even after directory deletion (the process handle keeps it alive), so `Repository::current()` works and the hint correctly suggests `wt switch ^`. The "no recovery" scenario only occurs on Unix where the CWD becomes truly inaccessible. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
dismissed
their stale review
March 1, 2026 05:37
Windows CI failure in test_merge_cwd_removed_hint_no_recovery
worktrunk-bot
approved these changes
Mar 1, 2026
worktrunk-bot
pushed a commit
that referenced
this pull request
Mar 1, 2026
1. Add jq `!=` escaping warning to running-in-ci skill. Despite the pre-flight template fix in #1152, Claude still generates `!=` in ad-hoc jq queries during CI polling — 4 of 6 review sessions in the past 24 hours hit this bug. The new guidance tells Claude to use `| not` instead of `!=` in all jq expressions. 2. Swap Step 5 dismissal ordering in pr-review. Previously: dismiss approval first, then post analysis. If the session times out between these, the PR author gets a bare dismissal with no context (happened on PR #1238, run 22536752559). Now: post analysis first, dismiss second — the safer ordering. Closes #1239 Closes #1240 Co-Authored-By: Claude Opus 4.6 <[email protected]>
2 tasks
max-sixty
added a commit
that referenced
this pull request
Mar 11, 2026
Follow-up to #1238. Two small refinements to the CWD-removed hint system: - `cwd_removed_hint()` now returns `Option<String>` instead of `String` — when no repository can be found, there's no actionable hint to give, so `None` is more accurate than a plain string. The caller in `main.rs` uses `info_message` for the no-hint case instead of `hint_message`. - Dropped trailing period from the `wt list` fallback hint to match the `wt switch ^` hint (consistency). Ref #1168 > _This was written by Claude Code on behalf of @max-sixty_ --------- Co-authored-by: Claude <[email protected]>
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
wt switch ^wouldactually work before suggesting it. Three-tier fallback: suggest
wt switch ^if the default branch worktree exists, suggest
wt listif the repo is foundbut
^isn't resolvable, or show a plain message if no repo is found at all.Thanks to @davidbeesley for reporting in #1168.
Test plan
cwd_removed_hint()andhint_for_repo()(bare repofallback)
cargo run -- hook pre-merge --yespasses