Skip to content

Preserve PR description when branch push fails during PR creation#8713

Merged
alexr00 merged 2 commits into
mainfrom
copilot/fix-pr-description-reset-on-push-fail
May 5, 2026
Merged

Preserve PR description when branch push fails during PR creation#8713
alexr00 merged 2 commits into
mainfrom
copilot/fix-pr-description-reset-on-push-fail

Conversation

Copilot AI commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

When the create-PR flow failed (e.g. an amended commit requires --force push), the user's typed title and description were silently replaced with the PR template the next time the webview re-rendered from persisted state.

Root cause

submit() in webviews/common/createContextNew.ts cleared the persisted webview state before awaiting pr.create:

const args = this.copyParams();
vscode.setState(defaultCreateParams); // wiped immediately
await this.postMessage({ command: 'pr.create', args });

On failure, the in-memory catch set createError, but the persisted state was already gone. Since the create view doesn't use retainContextWhenHidden, hiding/reopening the panel reloaded the webview from vscode.getState(), and handleMessage('pr.initialize') then fell back to defaultDescription because pendingDescription was undefined — restoring the template over the user's text.

Change

  • Move vscode.setState(defaultCreateParams) to after the awaited pr.create round-trip in submit(). Reset only happens on success; on failure the user's title/description remain in persisted state alongside the new createError.

Cleanup on success paths is unchanged: _firstLoad reset and the 'reset' message dispatched from dispose() still clear state when the view is reopened.

// after
const args = this.copyParams();
await this.postMessage({ command: 'pr.create', args });
vscode.setState(defaultCreateParams); // only on success

Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix PR description reset if branch push fails Preserve PR description when branch push fails during PR creation Apr 28, 2026
Copilot AI requested a review from alexr00 April 28, 2026 11:18
@alexr00 alexr00 marked this pull request as ready for review May 5, 2026 09:46
Copilot AI review requested due to automatic review settings May 5, 2026 09:46

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

This PR fixes a state persistence bug in the “Create PR” webview where a failed PR creation attempt (e.g., push rejected due to needing --force) could cause the user’s typed title/description to be overwritten by the PR template when the webview reloads from persisted state.

Changes:

  • Delays clearing the webview’s persisted vscode state until after the pr.create request completes successfully, so failures retain the user-entered title/description.
  • Adds an inline rationale comment documenting the failure/reload scenario that motivated the change.
Show a summary per file
File Description
webviews/common/createContextNew.ts Moves persisted-state reset to after the pr.create round-trip to preserve user-entered text across reloads when creation fails.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@alexr00 alexr00 merged commit 4947e69 into main May 5, 2026
10 checks passed
@alexr00 alexr00 deleted the copilot/fix-pr-description-reset-on-push-fail branch May 5, 2026 16:16
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.

PR description reset if branch push fails

4 participants