Skip to content

Add "create/add to stack" option when creating PR - #8992

Open
Alex Ross (alexr00) wants to merge 3 commits into
alexr00/prime-gamefowlfrom
alexr00/raspy-nightingale
Open

Alex Ross (alexr00) wants to merge 3 commits into
alexr00/prime-gamefowlfrom
alexr00/raspy-nightingale

Conversation

@alexr00

Copy link
Copy Markdown
Member

No description provided.

@alexr00 Alex Ross (alexr00) self-assigned this Sep 30, 2026
@alexr00
Alex Ross (alexr00) added this pull request to stack #8993 September 30, 2026 08:59
@alexr00
Alex Ross (alexr00) marked this pull request as ready for review September 30, 2026 09:03
Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:03

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.

Copilot review overview

🟡 Changes recommended

Stale asynchronous updates and incomplete unsupported-server handling can produce incorrect UI state and repeated warnings.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds pull-request stack creation and extension support to the Create PR workflow.

Changes:

  • Detects eligible stack parents and integrates GitHub’s Stacks API.
  • Adds stack selection UI while disabling incompatible auto-merge options.
  • Adds tests for eligibility, creation, validation, state changes, and failures.
File Description
common/​views.ts Adds stack-related request and view models.
src/​github/​createPRViewProvider.ts Detects candidates and adds created PRs to stacks.
src/​github/​githubRepository.ts Implements stack lookup and mutation API calls.
src/​test/​github/​createPRViewProvider.test.ts Tests provider-level stack workflows.
src/​test/​github/​githubRepository.test.ts Tests branch lookup error behavior.
src/​test/​github/​pullRequestModel.test.ts Tests stack detection and API operations.
webviews/​common/​createContextNew.ts Manages stack selection and submission state.
webviews/​createPullRequestViewNew/​app.tsx Adds stack controls and menu behavior.
webviews/​createPullRequestViewNew/​index.css Styles the stack option.
webviews/​createPullRequestViewNew/​test/​app.test.tsx Tests stack UI and state handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/github/createPRViewProvider.ts Outdated
Comment thread src/github/githubRepository.ts Outdated
Comment thread webviews/common/createContextNew.ts
Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:50

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.

Copilot review overview

🔵 Needs a closer look

No-op picker selections currently clear stack state, and branch changes trigger redundant GitHub API requests.

Review effort: Balanced
Findings: None

Resolved since last review (3)
Previously missed (3)

In code that hasn't changed since last review

Medium severity Duplicate eligibility lookups waste API requests

src/​github/​createPRViewProvider.ts:720

Picker-driven model updates already fetch stackCandidate explicitly in processRemoteAndBranchResult, while each setter also fires this handler and starts another full GraphQL parent lookup plus REST stack lookup. Changing owner and branch can start three checks; the sequence guard only discards stale results after those requests complete. Deduplicate or cache the eligibility lookup to avoid unnecessary API-rate consumption.

Medium severity Case-only remote changes incorrectly clear stack selection

webviews/​common/​createContextNew.ts:44

GitHub owner and repository names are case-insensitive, but this helper treats a casing-only update as a different remote. If an initialize response canonicalizes the casing, selectionChanged clears an otherwise valid stack selection. Compare both components case-insensitively, as isCreatable already does in this file.

Medium severity Reselecting the current option clears the stack selection

webviews/​common/​createContextNew.ts:165

This unconditionally clears a checked stack option even when the user reselects the current base remote/branch and the returned candidate is unchanged. A same-selection round trip is used to refresh warnings, so merely reopening/reselecting the picker can lose the user's choice. Preserve addToStack unless the branch, remote, or candidate actually changed.

This issue also appears on line 212 of the same file.

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.

Copilot review overview

🔵 Needs a closer look

Auto-merge state is lost when toggling stacking, and stack eligibility checks can generate excessive API traffic.

Review effort: Balanced
Findings: None

Previously missed (2)

In code that hasn't changed since last review

Medium severity Avoid repeated API lookups on unrelated model updates

src/​github/​createPRViewProvider.ts:721

This lookup now runs for every model change, including update({}) emitted on each local repository-state event while the compare branch is checked out (src/view/createPullRequestDataModel.ts:55-59). Each lookup performs both a GraphQL PR query and a REST stacks request, so ordinary Git state refreshes can repeatedly consume API quota and delay webview updates. Recompute the candidate only when one of the selected owner/branch fields changes; initial loading already fetches it in getCreateParams().

Medium severity Preserve auto-merge selection when toggling stack option

webviews/​createPullRequestViewNew/​app.tsx:391

Checking this option permanently overwrites the user's selected auto-merge mode. When the option is unchecked again, params.autoMerge is already false, so the previous “Create + Auto‑…” action is not restored. Auto-merge is already masked while stacking in the menu label/value and in copyParams(), so only update addToStack here and preserve the underlying selection.

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.

4 participants