Repository navigation
fix: use cross-platform wrapper for wt CLI in Claude Code integration - #1754
Conversation
On Windows the binary is git-wt.exe, not wt. Add a wt.sh wrapper
script that detects the platform and calls the correct binary, then
update hooks.json to use it via ${CLAUDE_PLUGIN_ROOT}.
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
wt CLI in plugin hookswt CLI in Claude Code integration
|
thanks! can we have it fall back to (unless there's some non-convoluted way to detect that |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9be3764104
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
A few options for detecting Windows Terminal's
case "$(uname -o 2>/dev/null)" in
Msys|Cygwin)
if command -v git-wt.exe >/dev/null 2>&1; then
WT=git-wt.exe
else
WT=wt
fi
;;
*) WT=wt ;;
esac
case "$(uname -o 2>/dev/null)" in
Msys|Cygwin)
if command -v git-wt.exe >/dev/null 2>&1; then
WT=git-wt.exe
elif command -v wt >/dev/null 2>&1 && ! command -v wt 2>/dev/null | grep -qi WindowsApps; then
WT=wt
else
echo "worktrunk not found — install with: cargo install worktrunk --features git-wt" >&2
exit 1
fi
;;
*) WT=wt ;;
esacOption 2 seems like the right balance — simple, handles the "deactivated @lucaspimentel what do you think — want to go with option 2 (fallback) or 3 (with WindowsApps detection)? |
|
@worktrunk-bot can we combine both checks? "if (is windows) AND ( |
On Windows, try git-wt.exe first and fall back to wt if it doesn't exist. This handles users who have deactivated the wt alias. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Done — pushed a commit that does exactly that: on Windows, tries |
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Check that `wt` doesn't resolve to the WindowsApps directory before using it as a fallback, since that path is the Windows Terminal alias. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The WindowsApps detection on line 11 works, but the ${WT:=wt} default on line 16 undoes it: when git-wt.exe is absent and wt is Windows Terminal, neither branch sets WT, so the default still invokes Windows Terminal — the exact bug this PR fixes.
Co-authored-by: worktrunk-bot <w@worktrunk.dev>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The Windows Terminal detection logic looks good now. One bug: the final invocation line is duplicated, so every hook command will execute twice.
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@lucaspimentel would you mind running this for a day or so to confirm it behaves well? It's difficult to test this stuff... |
|
@max-sixty definitely. I opened the PR too quickly (edit: the fix wasn't as simple as I originally thought) 😅 I'll convert it to a draft while I keep testing. |
Remove OS-specific branching — git-wt.exe check is harmless on non-Windows. Add missing PATH validation and distinct error for Windows Terminal alias vs not-found cases. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
|
thank you v much @lucaspimentel ! |
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
The UserPromptSubmit hook runs on every prompt, including outside git repos. Guard against missing git and non-repo directories to prevent "fatal: not a git repository" stderr noise in Claude Code. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
When set, use WORKTRUNK_BIN exclusively to find the worktrunk binary instead of searching PATH. Fail with a clear error if not found. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@lucaspimentel to the extent you've been using this and it's been successful, we could consider merging... |
|
@worktrunk-bot resopve conflicts |
# Conflicts: # .claude-plugin/plugin.json
|
Resolved and pushed (d3da440). Conflict was in Heads up — main also added |
|
@lucaspimentel give the go ahead if you've been using it and we should merge! ty! |
Fix this. |
These hooks were added to main after this branch and merged in cleanly, but invoked bare wt — undoing the cross-platform wrapper coverage this PR introduces for the other three hooks. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Done — pushed de3cd47b wrapping the |
@max-sixty good to go, thanks! |
Bump worktrunk to **0.49.0** — minor bump (semver-checks reports a
breaking change in `GitError::UncommittedChanges`, which gained a
`dirty_files: Vec<String>` field).
## Highlights
**Improved**
- New `codename(n)` template filter — deterministic friendly worktree
names from a ~1.26M-combo pool (`{{ branch | codename(2) }}` →
`malleable-opah`).
[#2641](#2641), thanks
@endigma
- Picker preview disk cache for Log / BranchDiff / UpstreamDiff, with
background refresh for stale Log decorations.
[#2628](#2628),
[#2646](#2646)
- Picker shares one `default_branch_sha` lookup across BranchDiff items
instead of forking N rev-parse subprocesses.
[#2658](#2658)
- "X has uncommitted changes" errors now list the dirty files inline.
[#2653](#2653)
**Fixed**
- `wt switch` integrates with `cd` aliases like zoxide (uses `builtin
cd`). [#2644](#2644), thanks
@xkumiyu for reporting
- Empty hook tables no longer panic during `wt switch --create`.
[#2635](#2635), thanks @topit
for reporting
- `Repository::current_worktree()` and five sibling helpers no longer
silently leak the process CWD when called via `Repository::at(p)`.
[#2652](#2652)
- `WorkingTree::is_linked` tolerates non-git CWDs (e.g. Nix sandbox).
[#2625](#2625), thanks
@DArtagan for reporting
- Picker no longer overlays `collect` warnings on the active TUI; clears
its frame on exit in inline mode.
[#2627](#2627),
[#2626](#2626)
- Failed `git log` no longer poisons the picker's preview disk cache.
[#2651](#2651)
- `wt step prune` says "removing branch" for branch-only candidates.
[#2619](#2619)
- Claude Code Windows integration uses a `wt.sh` wrapper to avoid
colliding with Windows Terminal's `wt.exe`.
[#1754](#1754), thanks
@lucaspimentel
**Documentation**
- cmux workspace integration recipe.
[#1907](#1907), thanks
@alvistar
See
[CHANGELOG.md](https://github.com/max-sixty/worktrunk/blob/release/CHANGELOG.md)
for the full list including internal CI / test-isolation changes.
## Test plan
- [x] `cargo run -- hook pre-merge --yes` (tests + lints clean)
- [x] `cargo semver-checks check-release -p worktrunk` (one breaking
change confirmed → minor bump)
- [x] CHANGELOG entries verified by subagent against actual diffs
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Currently, Worktrunk's Claude Code hook keeps opening Windows Terminal windows because it calls
wt, which is an alias~/AppData/Local/Microsoft/WindowsApps/wt.exeby default.Windows users have three workarounds:
git-wt.exewt.exeand disable the Windows Terminal alias to avoid conflictswt.exeand re-order the paths inPATHso Worktrunk is found firstChanges
wt.shwrapper script that tries to find the correct Worktrunk binary.hooks.jsonto usewt.sh.Manual tests
Tested all scenarios (I hope)
git-wt.exeorwt.exewtalias enabled or disabled