Add conflict resolution shortcut icon to Mergeable column#266
Add conflict resolution shortcut icon to Mergeable column#266
Conversation
Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
blt-leaf | d00b6b8 | Commit Preview URL Branch Preview URL |
Mar 08 2026, 06:33 PM |
|
@copilot please make sure the github comment is pre-filled |
Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
Done in 45d0816. The PR is now opened with the comment pre-filled using GitHub's |
There was a problem hiding this comment.
Pull request overview
Adds a quick-action affordance in the PR list to help maintainers notify authors when a PR has merge conflicts, by exposing an inline “conflict message” shortcut in the Mergeable column.
Changes:
- Added a green-styled global
showSuccessToastutility (mirrors existingshowErrortoast pattern). - Rendered an inline orange comment icon button next to the “Conflicts” mergeable state label.
- Implemented click behavior to build a pre-filled conflict-resolution message, copy it to clipboard, and open the PR in a new tab with URL parameters.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| conflictMessageBtn.addEventListener('click', async (e) => { | ||
| e.stopPropagation(); | ||
| const prUrl = conflictMessageBtn.dataset.prUrl; | ||
| const authorLogin = conflictMessageBtn.dataset.authorLogin; | ||
| const authorMention = authorLogin && /^[a-zA-Z0-9_.-]+$/.test(authorLogin) ? `@${authorLogin}` : 'contributor'; | ||
| const message = `Hi ${authorMention}, this PR has merge conflicts that need to be resolved before it can be merged. Could you please fix the conflicts? Thank you!`; | ||
| const prUrlWithComment = `${prUrl}?expand=1&body=${encodeURIComponent(message)}`; | ||
| try { | ||
| await navigator.clipboard.writeText(message); | ||
| showSuccessToast('Opening PR with conflict message pre-filled...'); | ||
| } catch (err) { | ||
| console.error('Failed to copy conflict message:', err); | ||
| } | ||
| window.open(prUrlWithComment, '_blank', 'noopener,noreferrer'); |
There was a problem hiding this comment.
window.open(...) is called after await navigator.clipboard.writeText(...). Awaiting an async operation can cause the browser to treat the later window.open as not being directly user-initiated, which may trigger popup blocking and break the shortcut. Open the new tab synchronously within the click handler (before awaiting), or avoid await by handling the clipboard promise without delaying the window.open call.
| conflictMessageBtn.addEventListener('click', async (e) => { | |
| e.stopPropagation(); | |
| const prUrl = conflictMessageBtn.dataset.prUrl; | |
| const authorLogin = conflictMessageBtn.dataset.authorLogin; | |
| const authorMention = authorLogin && /^[a-zA-Z0-9_.-]+$/.test(authorLogin) ? `@${authorLogin}` : 'contributor'; | |
| const message = `Hi ${authorMention}, this PR has merge conflicts that need to be resolved before it can be merged. Could you please fix the conflicts? Thank you!`; | |
| const prUrlWithComment = `${prUrl}?expand=1&body=${encodeURIComponent(message)}`; | |
| try { | |
| await navigator.clipboard.writeText(message); | |
| showSuccessToast('Opening PR with conflict message pre-filled...'); | |
| } catch (err) { | |
| console.error('Failed to copy conflict message:', err); | |
| } | |
| window.open(prUrlWithComment, '_blank', 'noopener,noreferrer'); | |
| conflictMessageBtn.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| const prUrl = conflictMessageBtn.dataset.prUrl; | |
| const authorLogin = conflictMessageBtn.dataset.authorLogin; | |
| const authorMention = authorLogin && /^[a-zA-Z0-9_.-]+$/.test(authorLogin) ? `@${authorLogin}` : 'contributor'; | |
| const message = `Hi ${authorMention}, this PR has merge conflicts that need to be resolved before it can be merged. Could you please fix the conflicts? Thank you!`; | |
| const prUrlWithComment = `${prUrl}?expand=1&body=${encodeURIComponent(message)}`; | |
| // Open the PR in a new tab synchronously in response to the click | |
| window.open(prUrlWithComment, '_blank', 'noopener,noreferrer'); | |
| // Copy the message to the clipboard without delaying the window.open call | |
| navigator.clipboard.writeText(message) | |
| .then(() => { | |
| showSuccessToast('Opening PR with conflict message pre-filled...'); | |
| }) | |
| .catch((err) => { | |
| console.error('Failed to copy conflict message:', err); | |
| }); |
| try { | ||
| await navigator.clipboard.writeText(message); | ||
| showSuccessToast('Opening PR with conflict message pre-filled...'); | ||
| } catch (err) { | ||
| console.error('Failed to copy conflict message:', err); | ||
| } |
There was a problem hiding this comment.
The success toast is only shown when navigator.clipboard.writeText succeeds. If clipboard access is denied/unavailable, the PR still opens but no toast is shown, which doesn’t match the described behavior of always confirming the action. Consider showing a success toast for the tab-open action regardless, and separately showing a warning/error toast if clipboard copy fails.
PRs with merge conflicts have no quick action to notify contributors — maintainers must manually open the PR, compose a message, and tag the author.
Changes
mergeable_state === 'dirty'(shown as "Conflicts"), an orangefa-comment-dotsicon appears inline next to the label in the Mergeable column@mentionmessage:Hi @{author}, this PR has merge conflicts that need to be resolved before it can be merged. Could you please fix the conflicts? Thank you!?expand=1&body=<encoded_message>URL parameter, so the maintainer can submit it with one clickshowSuccessToast— new utility function mirroring the existingshowErrortoast, using green stylingauthorLoginis validated against^[a-zA-Z0-9_.-]+$before being used in the@mention; falls back to"contributor"if invalidaria-label="Copy conflict message and open PR"and a descriptivetitle🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.