Skip to content

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

Merged
merged 7 commits into from
Jun 30, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 28, 2025

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 tooltip
  • webviews/components/timeline.tsx: Enhanced session log buttons in Copilot events to support modifier key detection
  • webviews/common/context.tsx: Updated openChanges() and openSessionLog() methods to accept optional inSecondEditorGroup parameter

Backend

  • src/github/pullRequestOverview.ts: Modified message handlers to process the new inSecondEditorGroup parameter
  • src/github/pullRequestModel.ts: Enhanced openChanges() to automatically split editor and focus second group when requested
  • src/view/sessionLogView.ts: Updated session log viewer to open in ViewColumn.Two when requested

Testing

  • src/test/github/pullRequestOverview.test.ts: Added focused unit tests to verify both features work correctly with the second editor group functionality

User Experience

Before

  • Clicking "Open Changes" or "View Session" always opened in the current editor group
  • No way to open these views in a different editor group without manual splitting

After

  • Regular click: Maintains existing behavior (opens in current editor group)
  • Ctrl/Cmd+click: Opens in second editor group, automatically creating it if needed
  • Tooltips: Updated to inform users about the Ctrl/Cmd+click functionality

Implementation Details

  • Uses React's standard mouse event properties (e.ctrlKey || e.metaKey) for cross-platform modifier key detection
  • For multi-diff views: Leverages VS Code's workbench.action.splitEditor and workbench.action.focusSecondEditorGroup commands
  • For session logs: Uses vscode.ViewColumn.Two parameter in createWebviewPanel()
  • Maintains full backward compatibility with existing functionality
  • Minimal, surgical changes that follow VS Code extension best practices

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.

Copilot AI and others added 3 commits June 28, 2025 05:17
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>
@Copilot Copilot AI changed the title [WIP] Overview of "Open Changes" and "View Session Log" Features in PR Detail Webview Add Ctrl/Cmd+click support to open PR changes and session logs in second editor group Jun 28, 2025
@Copilot Copilot AI requested a review from rebornix June 28, 2025 05:22
Copilot finished work on behalf of rebornix June 28, 2025 05:22
@rebornix rebornix marked this pull request as ready for review June 30, 2025 05:43
@rebornix rebornix enabled auto-merge (squash) June 30, 2025 05:43
@rebornix rebornix added this to the June 2025 milestone Jun 30, 2025
@rebornix rebornix merged commit 92da29e into main Jun 30, 2025
3 checks passed
@rebornix rebornix deleted the copilot/fix-54cf03bc-fbd7-4837-97ed-3af5d44cc2ba branch June 30, 2025 06:03
@alexr00 alexr00 restored the copilot/fix-54cf03bc-fbd7-4837-97ed-3af5d44cc2ba branch June 30, 2025 09:49
@@ -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;
Copy link
Member

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.

Comment on lines +1289 to 1298
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);
}
Copy link
Member

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.

@alexr00 alexr00 deleted the copilot/fix-54cf03bc-fbd7-4837-97ed-3af5d44cc2ba branch June 30, 2025 10:11
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.

4 participants