Background - fix changes paths in the working set (#3893)

* Background - fix changes paths in the working set

* Pull request feedback

---------

Co-authored-by: João Moreno <joaomoreno@users.noreply.github.com>
This commit is contained in:
Ladislau Szomoru
2026-02-20 13:47:06 +01:00
committed by GitHub
parent 5f34e85fcc
commit 05f70cd3a8
@@ -328,19 +328,28 @@ export class ChatSessionWorktreeService extends Disposable implements IChatSessi
return [];
}
const changes = diff.map(change => ({
filePath: change.uri.fsPath,
originalFilePath: change.status !== 1 /* INDEX_ADDED */
? change.originalUri?.fsPath
: undefined,
modifiedFilePath: change.status !== 6 /* DELETED */
? change.uri.fsPath
: undefined,
statistics: {
additions: change.insertions,
deletions: change.deletions
}
} satisfies ChatSessionWorktreeFile));
const changes = diff.map(change => {
// Since the diff was computed using the main repository, the file paths in the diff are relative to the
// main repository. We need to convert them to absolute paths by joining them with the repository path.
const worktreeFilePath = path.join(worktreeProperties.worktreePath, path.relative(worktreeProperties.repositoryPath, change.uri.fsPath));
const worktreeOriginalFilePath = change.originalUri
? path.join(worktreeProperties.worktreePath, path.relative(worktreeProperties.repositoryPath, change.originalUri.fsPath))
: undefined;
return {
filePath: worktreeFilePath,
originalFilePath: change.status !== 1 /* INDEX_ADDED */
? worktreeOriginalFilePath
: undefined,
modifiedFilePath: change.status !== 6 /* DELETED */
? worktreeFilePath
: undefined,
statistics: {
additions: change.insertions,
deletions: change.deletions
}
} satisfies ChatSessionWorktreeFile;
});
this.setWorktreeProperties(sessionId, {
...worktreeProperties, changes
@@ -349,7 +358,6 @@ export class ChatSessionWorktreeService extends Disposable implements IChatSessi
return changes;
}
getSessionIdForWorktree(folder: vscode.Uri): string | undefined {
for (const [sessionId, value] of this._sessionWorktrees.entries()) {
if (typeof value === 'string') {