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]>
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]>
The "no recovery" case isn't a hint (no actionable command to suggest), so use info_message instead of hint_message. Also drop trailing periods from hint text to match existing conventions. Co-Authored-By: Claude <[email protected]>
# Conflicts: # src/git/recover.rs # src/main.rs # tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_fallback_to_list.snap # tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_no_recovery.snap
Merge conflict resolution missed the new quiet parameter added on main. Co-Authored-By: Claude <[email protected]>
# Conflicts: # src/git/recover.rs # tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_fallback_to_list.snap # tests/snapshots/integration__integration_tests__merge__merge_cwd_removed_hint_no_recovery.snap
worktrunk-bot
approved these changes
Mar 11, 2026
2 tasks
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.
Follow-up to #1238. Two small refinements to the CWD-removed hint system:
cwd_removed_hint()now returnsOption<String>instead ofString— when no repository can be found, there's no actionable hint to give, soNoneis more accurate than a plain string. The caller inmain.rsusesinfo_messagefor the no-hint case instead ofhint_message.wt listfallback hint to match thewt switch ^hint (consistency).Ref #1168