Skip to content

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

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-pr-description-reset-on-push-fail
Draft

Preserve PR description when branch push fails during PR creation#8713
Copilot wants to merge 2 commits intomainfrom
copilot/fix-pr-description-reset-on-push-fail

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

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
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

2 participants