feat(shell): auto-cd to newly created worktree after add#100
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe changes add auto-directory-switching functionality after Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d0782a6a9
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
This PR implements automatic directory switching after successful wtp add commands in interactive TTY sessions, addressing issue #90. The feature extends shell hooks for bash, zsh, and fish to intercept wtp add commands, execute them with the --quiet flag to get clean path output, and automatically cd to the newly created worktree. Non-TTY contexts (pipes, command substitution) maintain standard CLI behavior without auto-switching.
Changes:
- Extended shell hooks (bash/zsh/fish) to detect
wtp addcommands and perform auto-cd in interactive TTY sessions - Updated documentation to explain the new auto-cd behavior and clarify shell integration capabilities
- Added unit tests verifying the shell hook scripts contain correct TTY guards, quiet flag usage, and cd logic
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/wtp/hook.go | Added wtp add auto-cd logic to bash, zsh, and fish shell hooks with TTY detection and quiet mode |
| cmd/wtp/hook_test.go | Added test cases verifying shell hooks generate correct auto-cd patterns for all three shells |
| cmd/wtp/shell_init.go | Updated command descriptions to reflect expanded shell integration capabilities beyond just cd |
| docs/architecture.md | Documented that shell hooks now support auto-switching after successful wtp add in interactive sessions |
| README.md | Added usage example and explanation of auto-cd behavior for wtp add with TTY detection note |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0d0782a to
92f7c52
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/wtp/hook.go`:
- Around line 95-107: The wrapper currently returns the original `wtp` exit code
(`status`) even if `cd "$target_dir"` fails, so update the auto-switch flow (the
`elif [[ "$1" == "add" ]]` block and the similar blocks at the other
occurrences) to capture the `cd` command's exit status and return that if
non-zero; specifically, after computing `target_dir` and verifying `$status -eq
0` and `-n "$target_dir"`, run `cd "$target_dir"` and if `cd` fails propagate
its exit code (e.g., assign and return the `cd` exit code) instead of always
returning the original `status`.
Summary
Closes #90
Summary by CodeRabbit
New Features
wtp add -bin interactive shells.wtp adddoes not auto-switch directories when stdout is not a TTY.Documentation
Tests