-
Notifications
You must be signed in to change notification settings - Fork 624
Add Ctrl/Cmd+click support to open PR changes and session logs in second editor group #7139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ctrl/Cmd+click support to open PR changes and session logs in second editor group #7139
Conversation
Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
…ond editor group Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
@@ -105,11 +105,16 @@ function Title({ title, titleHTML, number, url, inEditMode, setEditMode, setCurr | |||
function ButtonGroup({ isCurrentlyCheckedOut, canEdit, isIssue, repositoryDefaultBranch, setEditMode }) { | |||
const { refresh, copyPrLink, copyVscodeDevLink, openChanges } = useContext(PullRequestContext); | |||
|
|||
const handleOpenChangesClick = (e: React.MouseEvent) => { | |||
const openToTheSide = e.ctrlKey || e.metaKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows, the default to-the-side modifier is alt
as far as I know.
if (openToTheSide) { | ||
if (vscode.window.tabGroups.all.length < 2) { | ||
await vscode.commands.executeCommand('workbench.action.splitEditor'); | ||
} | ||
|
||
await vscode.commands.executeCommand('workbench.action.focusSecondEditorGroup'); | ||
} | ||
|
||
return vscode.commands.executeCommand('vscode.changes', vscode.l10n.t('Changes in Pull Request #{0}', pullRequestModel.number), args); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to fix the vscode.changes
command to properly handle the usual open arguments.
Summary
This PR adds support for Ctrl/Cmd+click functionality to the "Open Changes" and "View Session Log" buttons in the PR detail webview. When users hold Ctrl (Windows/Linux) or Cmd (macOS) while clicking these buttons, the views will open in the second editor group instead of the current one.
Changes Made
Frontend (Webviews)
webviews/components/header.tsx
: Added click handler for "Open Changes" button to detect modifier keys and updated tooltipwebviews/components/timeline.tsx
: Enhanced session log buttons in Copilot events to support modifier key detectionwebviews/common/context.tsx
: UpdatedopenChanges()
andopenSessionLog()
methods to accept optionalinSecondEditorGroup
parameterBackend
src/github/pullRequestOverview.ts
: Modified message handlers to process the newinSecondEditorGroup
parametersrc/github/pullRequestModel.ts
: EnhancedopenChanges()
to automatically split editor and focus second group when requestedsrc/view/sessionLogView.ts
: Updated session log viewer to open inViewColumn.Two
when requestedTesting
src/test/github/pullRequestOverview.test.ts
: Added focused unit tests to verify both features work correctly with the second editor group functionalityUser Experience
Before
After
Implementation Details
e.ctrlKey || e.metaKey
) for cross-platform modifier key detectionworkbench.action.splitEditor
andworkbench.action.focusSecondEditorGroup
commandsvscode.ViewColumn.Two
parameter increateWebviewPanel()
Testing
The implementation includes comprehensive unit tests and has been designed to be easily testable in a live VS Code environment with PRs that have file changes and Copilot session events.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.