Skip to content

Commit b43191a

Browse files
authored
Agents - add support for "Discard Changes" in "Uncommitted Changes" (#313530)
1 parent cdf20ff commit b43191a

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

extensions/copilot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5830,7 +5830,7 @@
58305830
"chat/input/editing/sessionChangeToolbar": [
58315831
{
58325832
"command": "github.copilot.sessions.discardChanges",
5833-
"when": "chatSessionType == copilotcli && isSessionsWindow && sessions.hasGitRepository && sessions.changesVersionMode == branchChanges && !sessions.isAgentHostSession",
5833+
"when": "chatSessionType == copilotcli && isSessionsWindow && sessions.hasGitRepository && !sessions.isAgentHostSession && (sessions.changesVersionMode == branchChanges || sessions.changesVersionMode == uncommittedChanges)",
58345834
"group": "navigation@2"
58355835
}
58365836
],

src/vs/sessions/contrib/changes/browser/changesViewModel.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,26 @@ export class ChangesViewModel extends Disposable {
259259
});
260260

261261
// Uncommitted changes
262+
const activeSessionUncommittedChangesCountObs = derived(reader => {
263+
const sessionMetadata = this._activeSessionMetadataObs.read(reader);
264+
const uncommittedChanges = sessionMetadata?.uncommittedChanges as number | undefined;
265+
266+
const activeSession = this.sessionManagementService.activeSession.read(reader);
267+
const workspace = activeSession?.workspace.read(reader);
268+
const workspaceRepository = workspace?.repositories[0];
269+
270+
return uncommittedChanges ?? workspaceRepository?.uncommittedChanges;
271+
});
272+
262273
this._activeSessionUncommittedChangesPromiseObs = derived(reader => {
263274
const repositoryPath = activeSessionRepositoryPathObs.read(reader);
264275
if (!repositoryPath) {
265276
return constObservable([]);
266277
}
267278

279+
// Re-run when the number of uncommitted changes changes
280+
activeSessionUncommittedChangesCountObs.read(reader);
281+
268282
const diffPromise = this._getRepositoryChanges(repositoryPath, 'HEAD', undefined);
269283
return new ObservablePromise(diffPromise).resolvedValue;
270284
});

0 commit comments

Comments
 (0)