Skip to content

SCM - revert back to computing incoming/outgoing changes using the history item view models#281273

Merged
lszomoru merged 1 commit intomainfrom
lszomoru/moral-quelea
Dec 4, 2025
Merged

SCM - revert back to computing incoming/outgoing changes using the history item view models#281273
lszomoru merged 1 commit intomainfrom
lszomoru/moral-quelea

Conversation

@lszomoru
Copy link
Member

@lszomoru lszomoru commented Dec 4, 2025

Fixes #280265

Copilot AI review requested due to automatic review settings December 4, 2025 16:23
@lszomoru lszomoru enabled auto-merge (squash) December 4, 2025 16:23
@lszomoru lszomoru self-assigned this Dec 4, 2025
@lszomoru lszomoru added the scm General SCM compound issues label Dec 4, 2025
@lszomoru lszomoru added this to the November 2025 milestone Dec 4, 2025
Copy link
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 reverts the logic for computing incoming/outgoing changes in the SCM history graph back to using view models instead of raw history items. This change fixes issue #280265 by performing incoming/outgoing node insertion after view models are created, allowing the code to leverage swimlane colors for proper graph rendering.

Key Changes:

  • Moved the computation of incoming/outgoing changes from operating on ISCMHistoryItem[] to ISCMHistoryItemViewModel[]
  • Removed the getHistoryItemViewModelKind function as the kind is now determined inline during view model creation
  • Updated addIncomingOutgoingChangesHistoryItems to work with view models and manipulate swimlane connections
  • Skipped a test case that likely needs updates to align with the new implementation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/vs/workbench/contrib/scm/browser/scmHistory.ts Refactored incoming/outgoing changes computation to work with view models post-creation, enabling proper swimlane color usage and graph node insertion
src/vs/workbench/contrib/scm/test/browser/scmHistory.test.ts Skipped test case "graph with incoming/outgoing changes (remote ref first)" that may need updates for the new implementation

Comment on lines +498 to +501
viewModels[afterHistoryItemIndex].inputSwimlanes.push({
id: currentHistoryItemRef.revision,
color: historyItemRefColor
});
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Direct mutation of viewModels[afterHistoryItemIndex].inputSwimlanes by pushing a new node violates immutability principles and is inconsistent with the pattern used for incoming changes (lines 445-459), where a new view model object is created via the spread operator.

This should follow the same pattern as incoming changes by creating a new view model object:

viewModels[afterHistoryItemIndex] = {
	...viewModels[afterHistoryItemIndex],
	inputSwimlanes: [...viewModels[afterHistoryItemIndex].inputSwimlanes, {
		id: currentHistoryItemRef.revision,
		color: historyItemRefColor
	}]
};
Suggested change
viewModels[afterHistoryItemIndex].inputSwimlanes.push({
id: currentHistoryItemRef.revision,
color: historyItemRefColor
});
viewModels[afterHistoryItemIndex] = {
...viewModels[afterHistoryItemIndex],
inputSwimlanes: [
...viewModels[afterHistoryItemIndex].inputSwimlanes,
{
id: currentHistoryItemRef.revision,
color: historyItemRefColor
}
]
};

Copilot uses AI. Check for mistakes.
* * f(g)
*/
test('graph with incoming/outgoing changes (remote ref first)', () => {
test.skip('graph with incoming/outgoing changes (remote ref first)', () => {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

The test "graph with incoming/outgoing changes (remote ref first)" is being skipped, but there's no explanation or tracking issue comment indicating why it's skipped or when it should be re-enabled.

According to the PR description (Fixes #280265), this PR is supposed to fix an issue. If this test is expected to pass after the fix, it should be unskipped. If it needs to remain skipped, add a comment explaining why (e.g., // TODO: Re-enable once #XXXXX is fixed).

Copilot uses AI. Check for mistakes.
@lszomoru lszomoru merged commit 25f178e into main Dec 4, 2025
33 of 34 checks passed
@lszomoru lszomoru deleted the lszomoru/moral-quelea branch December 4, 2025 17:04
aka1976mb added a commit to aka1976mb/vscode that referenced this pull request Dec 4, 2025
…story item view models (microsoft#281273)

<!-- Thank you for submitting a Pull Request. Please:
* Read our Pull Request guidelines:
  https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests
* Associate an issue with the Pull Request.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

scm General SCM compound issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SCM: Incoming Changes item no longer adjacent to Current History Item

3 participants