Skip to content

Confirm before discarding pull request creation with unsaved changes#8796

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/confirmation-popup-for-cancel-button
Draft

Confirm before discarding pull request creation with unsaved changes#8796
Copilot wants to merge 4 commits into
mainfrom
copilot/confirmation-popup-for-cancel-button

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Clicking Cancel in the PR creation view immediately discards any in-progress data. This is easy to trigger accidentally (e.g. tabbing from the description field and hitting Space/Enter), losing significant work.

Cancel now shows a modal confirmation when there are unsaved changes, mirroring VS Code's standard discard-changes prompt. Unsaved changes are detected for any of the following:

  • A title that has been manually edited (differs from the default derived from the branch name or latest commit message)
  • A description that differs from the loaded template (template-only contents do not prompt, since templates are easy to restore)
  • Any selected labels, assignees, reviewers, projects, or a milestone

Details:

  • Setting — adds githubPullRequests.showPullRequestCancelConfirmation (boolean, default true) as the persistent "never show again" state.
  • Types — adds CancelCreatePullRequestNew in common/views.ts, extending CreatePullRequestNew with a hasUnsavedChanges: boolean flag.
  • WebviewcancelCreate in createContextNew.ts computes hasUnsavedChanges from the current createParams (comparing pendingTitle/pendingDescription to their defaults and checking labels/assignees/reviewers/projects/milestone) and includes it in the cancel message. It no longer clears persisted state eagerly; it awaits the reply and only resets state on cancelled === true, so a declined dialog (or missing reply) preserves the in-progress data.
  • Extensioncancel() in createPRViewProvider.ts shows vscode.window.showWarningMessage({ modal: true, detail: 'Your unsaved changes to this pull request will be lost.' }, 'Discard', 'Don\'t Ask Again') when hasUnsavedChanges is true and the setting is enabled. Choosing Don't Ask Again flips the setting to false; dismissing the modal aborts the cancel. The handler replies with { cancelled: boolean }.

Cancels with no unsaved changes still proceed immediately with no prompt.

Copilot AI and others added 2 commits June 16, 2026 09:04
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
…ail wording

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Add confirmation popup for Cancel button in pull request creation Confirm before discarding pull request description on Cancel Jun 16, 2026
Copilot AI requested a review from alexr00 June 16, 2026 09:06
@HebaruSan

Copy link
Copy Markdown

Hi @copilot, a few points that may be worth considering if you read comments and react to them, otherwise these are suggestions for reviewer @alexr00:

  1. In addition to filling in a description, the user might also choose labels. This should probably also be considered an unsaved change and trigger the prompt if present.
  2. The text in the description might be filled in from a template (maybe from this extension itself and maybe from the remote repository) rather than user-entered. If this happens, it would be nice if you could only show the confirmation prompt if the user has made changes, since a template is easy to restore.
  3. Similar to both of the above, the title field always defaults in, either with the branch name or the latest commit message. If the user makes a change to this manually, it would be nice for the confirmation prompt to appear in that case as well, even if the description and labels are blank.
  4. I don't use the assignees, reviewers, milestones, or projects features, but I would guess that people who do use them would appreciate being prompted whether they want to lose that data as well.

@alexr00

alexr00 commented Jun 19, 2026

Copy link
Copy Markdown
Member

Thanks for looking at this @HebaruSan! I haven't had a chance to yet.

@copilot , address these comments:

  1. In addition to filling in a description, the user might also choose labels. This should probably also be considered an unsaved change and trigger the prompt if present.
  2. The text in the description might be filled in from a template (maybe from this extension itself and maybe from the remote repository) rather than user-entered. If this happens, it would be nice if you could only show the confirmation prompt if the user has made changes, since a template is easy to restore.
  3. Similar to both of the above, the title field always defaults in, either with the branch name or the latest commit message. If the user makes a change to this manually, it would be nice for the confirmation prompt to appear in that case as well, even if the description and labels are blank.
  4. I don't use the assignees, reviewers, milestones, or projects features, but I would guess that people who do use them would appreciate being prompted whether they want to lose that data as well.

…eviewers, projects, milestone

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for looking at this @HebaruSan! I haven't had a chance to yet.

@copilot , address these comments:
...

Addressed in 5b6022a. The dirty check now triggers the confirmation when any of the following has unsaved changes:

  • Title was manually edited (differs from the default derived from branch/commit)
  • Description differs from the loaded template (template-only contents still cancel without prompting)
  • Any labels, assignees, reviewers, projects, or a milestone are set

The setting description and modal detail were updated to reflect the broader scope.

Copilot AI changed the title Confirm before discarding pull request description on Cancel Confirm before discarding pull request creation with unsaved changes Jun 19, 2026
@HebaruSan

Copy link
Copy Markdown

Addressed in 5b6022a

The changes look good, but did @copilot hallucinate this commit hash? It's not in the list of commits, and the URL for it is a 404: 5b6022a

image

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.

3 participants