Skip to content

fix(completion): skip prefix filtering to enable shell substring matching - #1471

Merged
max-sixty merged 1 commit into
mainfrom
fix/completion-skip-prefix-filter
Mar 12, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/completion-skip-prefix-filter

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Closes #1468

Test plan

  • All 46 completion tests pass (including updated test_complete_with_partial_prefix_returns_all_branches and new test_complete_switch_returns_candidates_for_substring_matching)
  • Unit tests pass
  • Lints pass
  • CI green across platforms

🤖 Generated with Claude Code

Return all branch candidates to the shell instead of pre-filtering by
prefix. This lets fish and zsh apply their native substring/fuzzy
matching — e.g. `wt switch auth<TAB>` now surfaces `feature/user-auth`
in fish. The >100 remote-only branch exclusion from #1442 is preserved
to avoid overwhelming shells with thousands of candidates.

Closes #1468

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@max-sixty
max-sixty merged commit b527e42 into main Mar 12, 2026
22 checks passed
@max-sixty
max-sixty deleted the fix/completion-skip-prefix-filter branch March 12, 2026 22:40
@max-sixty

Copy link
Copy Markdown
Owner

thanks @benjaminbauer !

@benjaminbauer

Copy link
Copy Markdown

thank you @max-sixty for the swift solution and for running an awesome project!

max-sixty pushed a commit that referenced this pull request Mar 13, 2026
…hing (#1471)

## Summary

- Stop prefix-filtering branch candidates in
`BranchCompleter::complete()` — return all surviving candidates (after
the >100 remote exclusion from #1442) and let the shell apply its own
matching
- Enables fish substring matching (`auth<TAB>` → `feature/user-auth`)
and zsh fuzzy matching for `wt switch` completions
- Adds dedicated test for the substring-matching use case from #1468

Closes #1468

## Test plan

- [x] All 46 completion tests pass (including updated
`test_complete_with_partial_prefix_returns_all_branches` and new
`test_complete_switch_returns_candidates_for_substring_matching`)
- [x] Unit tests pass
- [x] Lints pass
- [ ] CI green across platforms

🤖 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 added a commit that referenced this pull request Mar 19, 2026
Bash's programmable completion (`complete -F`) does not filter
`COMPREPLY` by prefix — whatever the completion function puts in the
array is displayed as-is. After #1471 removed prefix filtering to enable
fish/zsh substring matching, bash users saw all branches regardless of
what they'd typed. For users with many branches (the reporter had 80),
`wt switch feat<TAB>` prompts "Display all 80 possibilities?" instead of
showing only the `feature/*` branches.

When the requesting shell is bash (`COMPLETE=bash`), filter completion
candidates by prefix before outputting them. Fish and zsh still receive
all candidates so they can apply their native substring/fuzzy matching.
The filtering runs in `maybe_handle_env_completion()` after
`engine::complete()` returns, so it handles all argument forms correctly
(`--base=m` → `--base=main`, `-b m` → `main`, etc.).

Adds `test_completion_cross_shell_filtering_contract` which verifies the
same branches with the same typed prefix produce different results per
shell — the test that would have caught the #1471 regression.

Thanks to @altruic for reporting in #1621.

Closes #1621

> _This was written by Claude Code on behalf of @max-sixty_

---------

Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
max-sixty added a commit that referenced this pull request Mar 19, 2026
…istency

HookCommandCompleter was pre-filtering completions by prefix, preventing
fish/zsh users from doing substring matching on hook command names.
BranchCompleter was already fixed for this (#1471), but HookCommandCompleter
was missed. The bash-specific prefix filter in maybe_handle_env_completion()
already handles bash correctly.

Also inlines complete_hook_commands() (single call site) and fixes stale
docstring (wt step → wt hook).

Co-Authored-By: Claude <[email protected]>
max-sixty added a commit that referenced this pull request Mar 19, 2026
…istency (#1627)

`HookCommandCompleter::complete()` was pre-filtering completions by
prefix, preventing fish/zsh users from doing substring matching on hook
command names. `BranchCompleter` was already fixed for this in #1471,
but `HookCommandCompleter` was missed.

The bash-specific prefix filter in `maybe_handle_env_completion()`
already handles bash correctly — this just removes the redundant (and
harmful) filter from the completer itself, matching `BranchCompleter`'s
approach.

Also inlines `complete_hook_commands()` (single call site) and fixes a
stale docstring (`wt step` → `wt hook`).

> _This was written by Claude Code on behalf of @max-sixty_

---------

Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: Claude <[email protected]>
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.

Support fuzzy shell completion for switch

3 participants