Skip to content

fix: filter completions by prefix for bash shell - #1622

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-1621
Mar 19, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-1621

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Collaborator

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

Bash's programmable completion (-F) does not filter COMPREPLY by prefix —
whatever the completion function puts in the array is displayed as-is. The
binary was returning all branch candidates for every shell, expecting each
shell to apply its own matching. This works for fish (substring) and zsh
(fuzzy), but bash users see all branches regardless of what they've typed.

Now the binary filters completions by prefix when the requesting shell is
bash (COMPLETE=bash), while still returning all candidates for fish/zsh.

Closes #1621

Co-Authored-By: Claude <[email protected]>
@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label Mar 19, 2026
Adds test_completion_cross_shell_filtering_contract which verifies the same
branches with the same typed prefix produce different results per shell:
- bash: only prefix matches (binary filters)
- fish/zsh: all candidates (shell does its own matching)

This captures the tension between #1468 and #1621 in a single test. Also
fixes a stale comment in test_complete_base_flag_all_formats.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 76d8866 into main Mar 19, 2026
22 checks passed
@max-sixty
max-sixty deleted the fix/issue-1621 branch March 19, 2026 19:07
worktrunk-bot added a commit that referenced this pull request Mar 19, 2026
The review bot consistently performs full code analysis (10-18 minutes
of CI compute) on self-authored PRs, only to stay silent because it
cannot approve its own work. Observed 6 times across PRs #1610, #1613,
#1614, #1619, #1622, #1623.

Add early-exit guidance in step 1 to skip steps 2-4 for self-authored
PRs. The bot still monitors CI and resolves threads, but skips the
redundant code review that always produces zero visible output.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wt switch <tab> doesn't work

2 participants