Skip to content

fix: exclude remote-only branches from switch tab completions#1416

Open
worktrunk-bot wants to merge 1 commit intomainfrom
fix/switch-completion-exclude-remotes
Open

fix: exclude remote-only branches from switch tab completions#1416
worktrunk-bot wants to merge 1 commit intomainfrom
fix/switch-completion-exclude-remotes

Conversation

@worktrunk-bot
Copy link
Collaborator

Summary

  • Exclude remote-only branches from wt switch tab completions by default, matching the interactive picker's behavior
  • When --remotes is explicitly on the command line, remote-only branches are included in completions
  • Repos with many remote branches (e.g. ~3000) no longer trigger zsh's "do you wish to see all N possibilities?" prompt

The fix leverages the existing exclude_remote_only field in BranchCompleter and adds --remotes flag detection (similar to existing --create detection) to override it when present.

Closes #1415

Test plan

  • Updated existing test to verify remote-only branches are excluded by default
  • Added test case verifying --remotes flag includes remote-only branches in completions
  • All 43 completion tests pass

🤖 Generated with Claude Code

Remote-only branches are now excluded from `wt switch` tab completions by
default, matching the interactive picker's behavior. In repos with many remote
branches this makes tab completion usable again. Passing `--remotes` on the
command line re-includes them.

Closes #1415

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
worktrunk-bot added a commit that referenced this pull request Mar 11, 2026
The claude-mention bot created a duplicate PR (#1442) when #1416 already
addressed the same issue, and shipped code without running cargo fmt —
causing a CI failure and requiring a second commit. Both gaps exist because
running-in-ci (loaded by all CI workflows) had no guidance on checking for
existing PRs or formatting code before committing. The triage-issue skill
had these checks but running-in-ci did not.

Add two subsections under "PR Creation":
- "Before creating a PR" — check open PRs and fix branches first
- "Before committing code changes" — run cargo fmt at minimum

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
max-sixty pushed a commit that referenced this pull request Mar 11, 2026
…1443)

## Summary

- Add "Before creating a PR" guidance: check for existing PRs and fix
branches before creating duplicates
- Add "Before committing code changes" guidance: run `cargo fmt`
(minimum) or full pre-merge before committing

## Evidence

In [run
22946109451](https://github.com/max-sixty/worktrunk/actions/runs/22946109451)
(`claude-mention` on issue #1415), the bot:

1. **Created a duplicate PR.** PR #1416 (created 2026-03-10) already
addressed the same issue — excluding remote branches from switch
completions. The bot created #1442 with a different approach without
checking for existing work. Both PRs are authored by `worktrunk-bot`.
The session log shows the bot went directly from reading the issue to
editing code — no `gh pr list` or branch check.

2. **Skipped `cargo fmt` before committing.** The bot ran `cargo check`
to verify compilation but not `cargo fmt`. CI failed on the pre-commit
hook's format check, requiring a second "style: rustfmt" commit and
another full CI polling cycle (~11 minutes of additional `sleep 60`
polls).

<details><summary>Session log: tool call sequence (run
22946109451)</summary>

```
Skill: running-in-ci
Bash: gh issue view 1415 ...
Read: src/completion.rs
Edit: src/completion.rs          ← code change
Grep: complete_branches          ← searched for tests, found none
Bash: cargo check                ← compilation only, no fmt
Bash: git checkout -b ...
Bash: git add && git commit      ← committed unformatted code
Bash: git push && gh pr create   ← created PR #1442 (duplicate of #1416)
... 11 CI poll cycles ...
Bash: gh run view --log-failed   ← discovered fmt failure
Bash: cargo fmt                  ← fixed formatting
Bash: git add && git commit      ← second commit
... 11 more CI poll cycles ...
```

</details>

## Root cause

The `running-in-ci` skill (loaded by all CI workflows) had no guidance
on either checking for existing PRs or formatting code before
committing. The `triage-issue` skill already had both — Step 3 ("Check
for duplicates") and Step 6.3 (`cargo run -- hook pre-merge --yes`) —
but this guidance didn't extend to the `claude-mention` workflow.

## Test plan

- [ ] Verify the skill file renders correctly
- [ ] Observe future `claude-mention` runs for improved behavior (check
for existing PRs, run `cargo fmt`)

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

---------

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

Tab completions for switch/remove include all remote branches, making them unusable in large repos

1 participant