Skip to content

Remove auto-cd functionality from wtp add command#18

Merged
satococoa merged 1 commit intomainfrom
remove-auto-cd-feature
Aug 13, 2025
Merged

Remove auto-cd functionality from wtp add command#18
satococoa merged 1 commit intomainfrom
remove-auto-cd-feature

Conversation

@satococoa
Copy link
Owner

@satococoa satococoa commented Aug 13, 2025

Summary

  • Removes the automatic directory change behavior from wtp add command
  • Simplifies the codebase by removing complex shell wrapper logic
  • Makes behavior more predictable and explicit

Breaking Change

Before: wtp add feature/xyz would automatically cd to the new worktree
After: Users need to explicitly run wtp add feature/xyz && wtp cd feature/xyz

Changes

  • Removed auto-cd logic from bash completion script
  • Removed auto-cd logic from zsh completion script
  • Removed auto-cd logic from fish completion script
  • No documentation updates needed (feature was not documented)
  • All tests pass

Migration Guide

Users who relied on the auto-cd behavior will need to update their workflow:

# Before (v1.1.x)
wtp add feature/new-feature  # Automatically cd's to new worktree

# After (v1.2.0)
wtp add feature/new-feature && wtp cd feature/new-feature

Test Plan

  • Run go tool task dev - all tests pass
  • Manually test wtp add command - creates worktree without changing directory
  • Shell completion still works for all shells

This is the first step in the migration plan outlined in the Untitled.md document, preparing for the future wtp init-shell command architecture.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Simplified shell integration for the add command across Bash, Zsh, and Fish.
    • The shell no longer auto-navigates to the newly created worktree after running add.
    • Commands now execute without post-add directory changes; users should cd manually if desired.
    • Other completion features and cd helpers remain unchanged and continue to work as before.

Remove the automatic directory change behavior after creating a new worktree.
This simplifies the codebase and makes behavior more predictable.

Users now need to explicitly use:
  wtp add feature/xyz && wtp cd feature/xyz

Instead of the automatic cd that happened before.

BREAKING CHANGE: wtp add no longer automatically changes directory to the new worktree

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 13, 2025 14:33
@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Walkthrough

Removed the post-add auto-cd behavior from shell completion/integration for Bash, Zsh, and Fish in cmd/wtp/completion.go. The add path now simply invokes wtp "$@" without parsing arguments or attempting to cd. Other completion helpers and cd integration remain unchanged.

Changes

Cohort / File(s) Summary
Shell completions (Bash/Zsh/Fish)
cmd/wtp/completion.go
Deleted logic that, after wtp add, parsed args to find the new worktree and auto-cd into it; now defers to wtp "$@" only. Existing completion helpers (__branches, __worktrees, __worktrees_cd, cd integration) unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant S as Shell (completion)
  participant W as wtp

  rect rgb(240,240,240)
    note over U,S: Previous flow (with auto-cd)
    U->>S: wtp add <args>
    S->>W: invoke wtp add <args>
    W-->>S: exit code
    S->>S: parse args, resolve worktree dir
    alt dir found
      S->>S: cd to new worktree
    else
      S-->>U: return without cd
    end
  end

  rect rgb(235,250,235)
    note over U,S: New flow (no auto-cd)
    U->>S: wtp add <args>
    S->>W: invoke wtp add <args>
    W-->>S: exit code
    S-->>U: return (no cd)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Poem

I hop through shells—bash, zsh, and fish—
No magic leaps to folders on a wish.
Add, then pause; I twitch an ear—
The cd is yours to engineer.
Carrot-commit made crisp and clean,
A simpler trail across the green. 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2168efa and 1493ec7.

📒 Files selected for processing (1)
  • cmd/wtp/completion.go (0 hunks)
💤 Files with no reviewable changes (1)
  • cmd/wtp/completion.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test (macos-latest, 1.24)
  • GitHub Check: E2E Tests (macos-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-auto-cd-feature

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@satococoa satococoa self-assigned this Aug 13, 2025
@satococoa satococoa merged commit 9ecd26f into main Aug 13, 2025
7 checks passed
@satococoa satococoa deleted the remove-auto-cd-feature branch August 13, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments