Skip to content

fix: remove prefix filtering from HookCommandCompleter for shell consistency - #1627

Merged
max-sixty merged 4 commits into
mainfrom
fix/hook-completer-consistency
Mar 19, 2026
Merged

max-sixty merged 4 commits into
mainfrom
fix/hook-completer-consistency

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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

worktrunk-bot and others added 4 commits March 19, 2026 16:31
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]>
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]>
…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
max-sixty merged commit e6c5067 into main Mar 19, 2026
21 checks passed
@max-sixty
max-sixty deleted the fix/hook-completer-consistency branch March 19, 2026 22:58
max-sixty added a commit that referenced this pull request Mar 20, 2026
)

Single call site — the free function just forwarded the struct's fields
as parameters. Inlining removes a level of indirection, matching the
pattern established in #1627 for `HookCommandCompleter`.

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

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.

2 participants