Skip to content

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

Closed
worktrunk-bot wants to merge 1 commit into
mainfrom
fix/switch-completion-exclude-remotes
Closed

worktrunk-bot wants to merge 1 commit into
mainfrom
fix/switch-completion-exclude-remotes

Conversation

@worktrunk-bot

Copy link
Copy Markdown
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner

@worktrunk-bot resolve conflicts

look back at the discussiosn — this went a few directions and I think we got a few ideas out. Explain exactly what this does and how it compares to our other options

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

This PR is superseded by #1442 (merged), which took the threshold approach discussed in #1415.

What this PR does: Unconditionally excludes remote-only branches from wt switch tab completions by default, and re-includes them when --remotes is on the command line (detected via remotes_flag_present() checking the completion context).

Why the discussion moved away from this approach:

  1. --remotes incongruence — --remotes controls the interactive picker, not tab completion. Overloading it to also toggle completion behavior conflates two concerns.
  2. Too aggressive for small repos — Users with few remote branches (where completions are manageable) lose a useful feature with no way to get it back except adding --remotes.

What #1442 does instead (already merged): Excludes remote-only branches only when the total branch count exceeds 100. Small repos are unaffected; large repos avoid the "do you wish to see all N possibilities?" prompt. This was the consensus from the #1415 discussion.

There are merge conflicts with main (in src/completion.rs) since #1442 changed the same area. I'd recommend closing this PR since the threshold approach covers the use case.

@max-sixty max-sixty closed this Mar 18, 2026
@max-sixty
max-sixty deleted the fix/switch-completion-exclude-remotes branch June 18, 2026 06:00
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

2 participants