Skip to content

Background - use merge-base commit for the left hand side of the diff editor#311026

Merged
lszomoru merged 2 commits intomainfrom
lszomoru/rare-hippopotamus
Apr 17, 2026
Merged

Background - use merge-base commit for the left hand side of the diff editor#311026
lszomoru merged 2 commits intomainfrom
lszomoru/rare-hippopotamus

Conversation

@lszomoru
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 17, 2026 15:47
@lszomoru lszomoru self-assigned this Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Copilot CLI chat sessions’ diff construction so the left-hand side (original) of the diff editor uses the merge-base commit (when available), aligning the editor view with how git diffs are computed (e.g., --merge-base).

Changes:

  • Compute and persist mergeBaseCommit (and baseCommit for workspace sessions) in repository/session metadata.
  • Use mergeBaseCommit as the original ref when creating ChatSessionChangedFile entries for workspace sessions.
  • Extend worktree/session property types to carry mergeBaseCommit.
Show a summary per file
File Description
extensions/copilot/src/extension/chatSessions/vscode-node/folderRepositoryManagerImpl.ts Computes merge-base and stores baseCommit/mergeBaseCommit into RepositoryProperties during repo discovery.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts Uses stored merge-base ref when building workspace changed-file entries.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts Uses merge-base/base commit as the diff original ref for workspace changed-file entries.
extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts Adds merge-base tracking and uses it for diff original ref selection in agent sessions workspaces.
extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorkspaceFolderServiceImpl.ts Computes merge-base commit during workspace diff computation and stores it back to metadata.
extensions/copilot/src/extension/chatSessions/common/chatSessionWorktreeService.ts Adds mergeBaseCommit?: string to worktree properties v2.
extensions/copilot/src/extension/chatSessions/common/chatSessionMetadataStore.ts Adds baseCommit?: string and mergeBaseCommit?: string to RepositoryProperties.

Copilot's findings

Comments suppressed due to low confidence (4)

extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts:782

  • ILogService.error is intended for logging exception details by passing the Error object as the first argument and an optional stable context string as the second. Interpolating ${error} into the message can leak error details/customer data and loses stack traces; pass the error separately and keep the message free of error contents.
		} catch (error) {
			this.logService.error(`[ChatSessionWorktreeService][_getWorktreeChanges] Error while getting merge base (${worktreeProperties.branchName}, ${worktreeProperties.baseBranchName}) for session ${sessionId}: ${error}`);
		}

extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorkspaceFolderServiceImpl.ts:254

  • The workspace diff is computed via git diff ... --merge-base <baseBranchName> (i.e. merge-base with HEAD), but this merge-base commit is computed using repositoryProperties.branchName. If the user has switched branches, these can diverge. Consider computing the merge base against 'HEAD' (or repository.headBranchName) to match the diff baseline, or only computing it when the stored branch matches the current HEAD branch.
			if (repositoryProperties.branchName && repositoryProperties.baseBranchName) {
				mergeBaseCommit = await this.gitService.getMergeBase(repository.rootUri, repositoryProperties.branchName, repositoryProperties.baseBranchName);
			}

extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorkspaceFolderServiceImpl.ts:257

  • ILogService.error should receive the thrown error as the first argument and a stable context message as the second; avoid embedding ${error} in the message (it can include stack/message). Pass the error object separately and keep the message to branch/session context only.
		} catch (error) {
			this.logService.error(`[ChatSessionWorkspaceFolderService][getWorkspaceChanges] Error while getting merge base (${repositoryProperties.branchName}, ${repositoryProperties.baseBranchName}): ${error}`);
		}

extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts:822

  • originalFileRef now prefers worktreeProperties.mergeBaseCommit, but in getWorktreeChanges() the returned changes.map(...) uses the pre-update worktreeProperties object (before setWorktreeProperties(..., ...properties)), so the newly computed/stored mergeBaseCommit won’t be used in the first result. Consider mapping with an updated properties object (e.g., { ...worktreeProperties, ...properties }) so the diff LHS uses the merge-base immediately.
		if (worktreeProperties.version === 2) {
			// Commit | Working tree
			originalFileRef = vscode.workspace.isAgentSessionsWorkspace
				? worktreeProperties.mergeBaseCommit ?? worktreeProperties.baseCommit
				: worktreeProperties.baseCommit;
  • Files reviewed: 7/7 changed files
  • Comments generated: 4

@github-actions
Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: b5e65eb7 Current: c86de3ba

Changed (1)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after

@lszomoru lszomoru enabled auto-merge (squash) April 17, 2026 16:06
@lszomoru lszomoru added this to the 1.117.0 milestone Apr 17, 2026
@lszomoru lszomoru merged commit 20298ed into main Apr 17, 2026
26 checks passed
@lszomoru lszomoru deleted the lszomoru/rare-hippopotamus branch April 17, 2026 16:37
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