Skip to content

Commit 24f7924

Browse files
authored
remove save-block when stashing session (microsoft#203164)
also restore save-block when unstashing and fix and issues that would prevent stashing fixes microsoft/vscode-copilot#3654
1 parent e1e590c commit 24f7924

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,8 @@ export class InlineChatController implements IEditorContribution {
852852
assertType(this._strategy);
853853
this._sessionStore.clear();
854854

855+
// only stash sessions that were not unstashed, not "empty", and not interacted with
856+
const shouldStash = !this._session.isUnstashed && !!this._session.lastExchange && this._session.hunkData.size === this._session.hunkData.pending;
855857
let undoCancelEdits: IValidEditOperation[] = [];
856858
try {
857859
undoCancelEdits = this._strategy.cancel();
@@ -862,8 +864,7 @@ export class InlineChatController implements IEditorContribution {
862864
}
863865

864866
this._stashedSession.clear();
865-
if (!this._session.isUnstashed && !!this._session.lastExchange && this._session.hunkData.size === this._session.hunkData.pending) {
866-
// only stash sessions that were not unstashed, not "empty", and not interacted with
867+
if (shouldStash) {
867868
this._stashedSession.value = this._inlineChatSessionService.stashSession(this._session, this._editor, undoCancelEdits);
868869
} else {
869870
this._inlineChatSessionService.releaseSession(this._session);
@@ -1142,7 +1143,11 @@ export class InlineChatController implements IEditorContribution {
11421143
}
11431144

11441145
unstashLastSession(): Session | undefined {
1145-
return this._stashedSession.value?.unstash();
1146+
const result = this._stashedSession.value?.unstash();
1147+
if (result) {
1148+
this._inlineChatSavingService.markChanged(result);
1149+
}
1150+
return result;
11461151
}
11471152

11481153
joinCurrentRun(): Promise<void> | undefined {

src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class InlineChatSavingServiceImpl implements IInlineChatSavingService {
5555
@IWorkingCopyFileService private readonly _workingCopyFileService: IWorkingCopyFileService,
5656
@ILogService private readonly _logService: ILogService,
5757
) {
58-
this._store.add(_inlineChatSessionService.onDidEndSession(e => {
58+
this._store.add(Event.any(_inlineChatSessionService.onDidEndSession, _inlineChatSessionService.onDidStashSession)(e => {
5959
this._sessionData.get(e.session)?.dispose();
6060
}));
6161
}

0 commit comments

Comments
 (0)