Skip to content

fix(shell): guard fish lazy-load wrapper against completion-mode recursion - #3250

Merged
max-sixty merged 2 commits into
mainfrom
fix/fish-wrapper-complete-guard
Jun 25, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/fish-wrapper-complete-guard

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Follow-up to #3241, requested in #3240.

#3241 made the completion files wt itself writes resolve the binary, so they no longer re-enter the fish lazy-load stub. But the stub (functions/wt.fish) is still unguarded, leaving one narrow residual case: a stale third-party completion that calls the bare wt command with COMPLETE set — e.g. an old Homebrew vendor_completions.d/wt.fish left on disk from before an upgrade — re-enters the stub and recurses to fish's call-stack limit until the package is rebuilt.

This adds the same COMPLETE short-circuit that bash and zsh already use, so the stub delegates straight to the binary in completion mode regardless of which completion file is active:

function wt
    if set -q COMPLETE
        command wt $argv   # bypass the stub, let the binary emit completions
        return
    end
    command wt config shell init fish | source
    ...
end

This makes fish immune to stale third-party completions, matching bash/zsh.

Changes

Closes #3240.

🤖 Generated with Claude Code

…rsion

The fish lazy-load stub (`functions/wt.fish`) re-sources the full
integration on every call and self-invokes `wt $argv`, with no guard for
completion mode. #3241 fixed the completions wt itself writes to resolve
the binary, but the stub stays vulnerable to a stale third-party
completion that calls the bare `wt` command with COMPLETE set (e.g. an
old Homebrew `vendor_completions.d/wt.fish` left on disk before an
upgrade): that re-enters the stub and recurses to fish's call-stack limit.

Add the same `COMPLETE` short-circuit bash/zsh already use, so the stub
delegates to the binary in completion mode regardless of which completion
file is active.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The lazy-load wrapper stub gained an 8-line COMPLETE guard, shifting the
`command wt config shell init fish | source` marker from line 7 to line 15.
config_show renders that line number, so config_show_fish_with_completions and
config_show_fish_without_completions need regenerating alongside the
configure_shell_fish_dry_run snapshot already updated in this PR.

Co-Authored-By: Claude <[email protected]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Heads-up on the red Windows checks — this is the known unrelated PTY flake, not a regression from this change.

Both Windows legs (test (windows), required, and affected tests (windows, advisory)) failed on the same single test, test_switch_picker_worktree_row_comments_tab_shows_thread (1 of 3877 / 1 of 1804) — the Windows ConPTY write-after-exit race that #3242 is de-flaking. It lives in the switch picker PTY suite and is untouched by this PR, which only changes the fish lazy-load wrapper: every fish/completion test passed, and the required test (linux) and test (macos) legs are green.

I've re-run the two failed Windows legs.

@max-sixty
max-sixty merged commit c2b7ab6 into main Jun 25, 2026
44 of 47 checks passed
@max-sixty
max-sixty deleted the fix/fish-wrapper-complete-guard branch June 25, 2026 22:21
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.

Bug: fish completion infinitely recurses through the lazy-load wt function

2 participants