Skip to content

Auto-install official extension stubs in CI - #13581

Merged
BagToad merged 2 commits into
cli:trunkfrom
BagToad:bagtoad/kw-extension-install-non-interactive
Jun 4, 2026
Merged

BagToad merged 2 commits into
cli:trunkfrom
BagToad:bagtoad/kw-extension-install-non-interactive

Conversation

@BagToad

@BagToad BagToad commented Jun 3, 2026

Copy link
Copy Markdown
Member

Description

Skip the install prompt when CI is detected so official extension stubs (like gh aw, gh stack) auto-install instead of blocking on Y/n in CI runners and agent sessions.

Key Points

  • The previous version of this diff mirrored runCopilot exactly: TTY always wins, so a pseudo-TTY agent session with CI=1 still hung on the prompt. This revision flips the order so CI wins over TTY.
  • Intentional divergence from gh copilot: a follow-up could apply the same change there for consistency, but extension stubs are the more pressing case (agents call gh <extname> frequently).
  • CI is detected via ci.IsCI() (any of CI, BUILD_NUMBER, or RUN_ID).

Notes for reviewers

Two commits, reviewable in order:

  1. fix(extension): auto-install official extension stubs in CI is the behavior change. The official_extension_stub file holds the new branching; the stub test extends the existing run-function table test and clears CI env vars per subtest; the acceptance test clears CI env vars and expects non-zero exit plus install instructions on stderr.
  2. docs(extension): explain CI bypass in stub install logic is a one-line comment addressing review feedback that the non-TTY+CI behavior wasn't obvious from the code.

Additional Context

Manually verified locally with gh stack uninstalled. The TTY+CI case is the one this revision actually fixes versus the previous version of the diff:

$ CI=1 ./bin/gh stack --help              # TTY + CI
Successfully installed github/gh-stack    # exit 0

$ CI=1 ./bin/gh stack --help < /dev/null  # non-TTY + CI
Successfully installed github/gh-stack    # exit 0

$ ./bin/gh stack --help < /dev/null       # non-TTY, no CI
gh stack is available as an official extension.
To install it, run:
  gh extension install github/gh-stack    # exit 1

Copilot AI review requested due to automatic review settings June 3, 2026 16:15
@BagToad
BagToad requested a review from a team as a code owner June 3, 2026 16:15
@BagToad
BagToad requested a review from babakks June 3, 2026 16:15
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed unmet-requirements and removed needs-triage needs to be reviewed labels Jun 3, 2026
@github-actions

This comment was marked as off-topic.

@BagToad BagToad changed the title fix(extension): auto-install official extension stubs in CI Auto-install official extension stubs in CI Jun 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the hidden “official extension” stub command behavior so that invoking an uninstalled official extension no longer hangs in non-interactive CI: it auto-installs in CI when prompting isn’t possible, while preserving prompting behavior for interactive TTY sessions.

Changes:

  • Aligns official extension stub branching with ci.IsCI() detection to auto-install in non-TTY CI and show install instructions with a non-zero exit outside CI.
  • Extends unit tests for the stub run behavior across TTY/non-TTY and CI/non-CI permutations, including clearing CI-related env vars per subtest.
  • Updates telemetry acceptance test expectations to account for the new non-zero exit behavior outside CI.
Show a summary per file
File Description
pkg/cmd/root/official_extension_stub.go Adds CI-aware non-interactive behavior (auto-install in CI; instructions + SilentError outside CI).
pkg/cmd/root/official_extension_stub_test.go Expands table tests to cover CI/non-CI and TTY/non-TTY branches; resets CI env vars per case.
acceptance/testdata/telemetry/telemetry-for-official-extension-stub.txtar Ensures CI env vars are cleared and expects non-zero exit for the non-TTY outside-CI path.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

pkg/cmd/root/official_extension_stub_test.go:61

  • If declining the interactive prompt is changed to return cmdutil.SilentError (to match copilot semantics), this test case should expect the non-zero exit (and install guidance on stderr) rather than treating the declined prompt as success.
		{
			name:          "TTY declined does not install",
			isTTY:         true,
			confirmResult: false,
		},
  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread pkg/cmd/root/official_extension_stub.go Outdated

@babakks babakks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread pkg/cmd/root/official_extension_stub.go Outdated

@babakks babakks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

When CI is detected, skip the install prompt and install directly so
the stub doesn't block agents and CI runners. Outside CI, keep the
existing TTY-prompt and non-TTY silent-error behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BagToad
BagToad force-pushed the bagtoad/kw-extension-install-non-interactive branch from 08c6393 to ef8c7d8 Compare June 3, 2026 22:17
@BagToad
BagToad requested a review from babakks June 3, 2026 23:59
shacharPash added a commit to shacharPash/pr-review-assistant that referenced this pull request Jun 4, 2026
#14)

The '↑/↓ Expand 10' chips were Monaco content widgets, which float on top of
the editor text — so once context was expanded, the chip landed on top of a
code line (see report). Render them as Monaco view zones instead: each chip
gets its own reserved row, so it never overlaps code (GitHub-style).

Verified live on cli/cli#13581: chips sit in .expand-context-row zones with 0
overlapping code lines, before and after expanding; expand still works.
typecheck + build green.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shacharPash added a commit to shacharPash/pr-review-assistant that referenced this pull request Jun 4, 2026
The view-zone fix (#14) stopped the overlap but introduced a regression: Monaco
paints the .view-lines layer above the view-zones layer, so clicks on the chip
were swallowed by the lines layer (elementFromPoint returned .view-lines, not
the chip). Lift the chip row with position:relative + z-index so the button is
the topmost element at its location.

Verified live on cli/cli#13581: click now lands on the chip and expands context
(39 -> 49 lines); still no code overlap; no console errors.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shacharPash added a commit to shacharPash/pr-review-assistant that referenced this pull request Jun 4, 2026
…hidden (#16)

Two issues in the hunks-only renderer (used for files with hidden noise hunks):
- Every inter-hunk gap rendered BOTH the previous hunk's '↓ Expand' and the
  next hunk's '↑ Expand' — two buttons for one gap. Now render one chip per
  gap: each hunk's '↑ above' (covers the file head + each inter-hunk gap) plus
  '↓ below' only on the LAST hunk (the file tail).
- A ⋯ separator row was inserted between every pair of hunks even when they're
  contiguous (no hidden lines). Now it's inserted only when there's a real gap,
  so where a separator/chip appears the line numbers genuinely jump, and fully
  contiguous hunks render with no fake ⋯ / expand control.

Verified on cli/cli#13581: visible contiguous region shows consecutive line
numbers and no chip; file shows one head + one tail chip (no stacked pair).
typecheck + 70 tests + build green.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BagToad
BagToad enabled auto-merge (squash) June 4, 2026 16:09
@BagToad
BagToad merged commit 7ef9c54 into cli:trunk Jun 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants