Repository navigation
feat(zsh): complete PR numbers for gh pr view/update-branch - #367
Merged
Merged
Conversation
gh registers no completion for the `[<number> | <url> | <branch>]` positional: `gh __complete pr view ""` returns zero candidates with directive 0 (ShellCompDirectiveDefault), which tells the shell to fall back to file completion. `gh pr view <TAB>` therefore offers the working directory. Add `_gh_pr_numbers`, which supplies open PR numbers at that position for the thirteen `gh pr` subcommands that take it and delegates everything else to the cobra-generated `_gh` — the same wrap-and-delegate shape as `_chezmoi_edit_managed` directly above it. Candidates use `_describe`'s `number:description` pair form so only the bare number is inserted, since the real gh consumes the word verbatim and cannot strip a suffix the way `_gh_pick_arg` does for the `gh*` wrappers. Uncached, matching those wrappers: one `gh pr list` per TAB at that position. Upstream has this as cli/cli#360, open since 2020 and labelled `pitch` in 2026-03 (pitched internally, `help wanted` removed), gated on a caching foundation for API-powered completions. Covered by tests/test-gh-completion.sh: 11 unit assertions on position detection plus 4 pty-driven end-to-end checks, and a control run with the hook unloaded that requires the file-completion fallback to reappear. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HjMHsjiYriW362KrsuwV2N
Every script in tests/ has a matching `test:*` mise task; without one the gh-completion suite is orphaned and would only run when someone invokes it by path. Same wrapper shape as test:shell-precedence. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HjMHsjiYriW362KrsuwV2N
laurigates
added a commit
that referenced
this pull request
Aug 19, 2026
…368) ## What ADR-0017 records the decision to test macOS alongside Ubuntu in CI, replacing the Ubuntu-only status quo that has held since 2025-09-15. Docs only — the workflow change lands separately. Also updates the ADR index and the count in `CLAUDE.md`. ## Why `a264a61` ("ci: simplify smoke test workflow", #78) removed `lint-macos` and `build-macos`, giving as its reason *"reduce CI complexity and runtime"* — in the same commit that swapped individual linters for pre-commit and moved shell testing from zsh to fish. Two beliefs accumulated afterwards and were repeated when the decision came up again: that macOS runners are expensive, and that they are slow. Both were checked; neither holds here. **Cost.** Public repositories bill standard runners at zero, macOS included. Measured rather than inferred, against a sibling public repo that does run macOS jobs: ``` $ gh api repos/laurigates/kicad-mcp/actions/runs/30608467472/timing --jq .billable MACOS: jobs=3 total_ms=0 UBUNTU: jobs=7 total_ms=0 ``` The 10× macOS multiplier applies to private repositories and paid minutes. GitHub's billing docs are ambiguous about whether `macos-latest` counts as a "larger runner", which is where the belief came from; the billing API is not. **Runtime.** Same run: macOS queued 2–3 s against Ubuntu's 2–4 s and ran 25–33 s against Ubuntu's 22–27 s — ~20% slower, not an order of magnitude. This repo's `smoke.yml` currently runs Linters 92 s + Build (Ubuntu) 46 s. **Coverage.** `Build (Ubuntu)` runs `chezmoi apply` under Homebrew-on-Linux. It catches template and source-tree errors, and it usefully guards against macOS-only assumptions leaking into cross-platform paths — but it cannot exercise zsh startup, macOS formula availability, completion generation, or launchd. That is the surface this repo exists to configure. ## What the ADR does not claim The 2025-09 removal also cited *complexity*, and this ADR does not disprove that — only the cost and runtime claims were measured. The ADR says so, and records that if the macOS job proves flaky the response should be moving it to a schedule rather than deleting it, so the coverage question stays visible. The daily-driver counter-argument is recorded rather than dismissed: macOS breakage does surface within hours anyway, which makes this a convenience. The ADR's position is that it is a convenience that catches regressions before they reach the machine the author depends on. ## Scope limit worth flagging `tests/test-gh-completion.sh` (added in #367) is explicitly kept out of CI. It drives a pty against whatever PRs happen to be open, so its candidate set is live remote state — it would be green or skipped depending on the day. CI runs tests whose inputs live in the repository. ## Follow-ups Four separate PRs, each independent: - restore the macOS job in `smoke.yml` (implements this ADR; also corrects the now-false "Multi-platform (Ubuntu/macOS)" line in `CLAUDE.md`) - migrate the four drifted workflows to their `laurigates/.github` counterparts - workflow-level `permissions` and `concurrency` on the checks that lack them - Renovate `helpers:pinGitHubActionDigests` for SHA pinning Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
_gh_pr_numbers, a zsh completion wrapper that offers open PR numbers atthe first positional of
gh pr view,gh pr update-branch, and the elevensibling subcommands that take
[<number> | <url> | <branch>]. Everything else— subcommands, flags, other command trees — is handed straight back to gh's
own cobra-generated
_gh.Ships with
tests/test-gh-completion.sh.Why
gh registers no completion for that positional:
Zero candidates with directive
0tells the shell to fall back to filecompletion, so
gh pr view <TAB>currently offers the working directory.Upstream tracks this as cli/cli#360, open since 2020-02-12 with 42 👍. A
working
ValidArgsFunctionpatch forpr/viewsits in that thread from 2022and was never turned into a PR; maintainers have twice said the mechanism is
right but that they want a caching foundation for API-powered completions
first. The issue picked up the
pitchlabel ("pitched internally forprioritisation") on 2026-03-10 and lost
help wantedon 2025-04-10 — so it isalive, unbuilt, and not soliciting outside patches. Local workaround until it
lands. Related: cli/cli#360, cli/cli#11406.
How
Same wrap-and-delegate shape as
_chezmoi_edit_manageddirectly above it:_gh_pr_at_number_argwalks$words, skipping flags and the values of theones that take an argument (
-R,--jq, …), and fires only when exactly twopositionals (
pr,<sub>) precede the cursor.gh pr view 123 <TAB>andgh pr list <TAB>fall through._describe'snumber:descriptionpair form, which splits atthe first colon — so only the bare number is inserted while branch, title and
author stay in the description column and the fzf-tab preview. The
gh*wrapper completions below use a
number[branch] titleform and strip thesuffix in
_gh_pick_arg; that is not available here, since the realghconsumes the word verbatim.
Uncached, matching the existing
gh*wrapper completions: each TAB at thatposition costs one
gh pr list(~0.5–1 s). Outside a GitHub repo the candidatelist comes back empty and completion falls through to
_gh.Testing
tests/test-gh-completion.sh— 18 assertions, all passing:_gh_pr_at_number_argdirectly over synthetic
$words/$CURRENT(gh -R o/r pr viewfires,gh pr view 123does not,gh issue viewdoes not, …).zsh/zpty),reading back what TAB actually inserted:
gh pr view <TAB>andgh pr update-branch <TAB>insert the PR numbers;gh pr vie<TAB>stillcompletes to
viewandgh pr view --w<TAB>to--web, proving delegationsurvives.
fallback to appear. Without it a green suite would prove nothing about the
hook.
The completion code under test is extracted from
chezmoi cat ~/.zshrcratherthan retyped into the harness, so the test exercises the text that reaches
~/.zshrc. The control repo is chosen at runtime from repos that actually haveopen PRs, and the suite SKIPs loudly rather than passing vacuously when none is
reachable.