Skip to content

Commit 360e15e

Browse files
authored
fix some papercuts with edits -> checkpoints interaction (microsoft#256620)
* do not show prompt files in edits * fix some papercuts with checkpoints -> editing interactions
1 parent b296d37 commit 360e15e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatClearActions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ export function registerNewChatActions() {
181181
}
182182

183183
async runEditingSessionAction(accessor: ServicesAccessor, editingSession: IChatEditingSession) {
184+
const widget = accessor.get(IChatWidgetService);
184185
await editingSession.redoInteraction();
186+
widget.lastFocusedWidget?.viewModel?.model.setCheckpoint(undefined);
185187
}
186188
});
187189

src/vs/workbench/contrib/chat/browser/chatWidget.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
169169
private focusedInputDOM!: HTMLElement;
170170
private editorOptions!: ChatEditorOptions;
171171

172+
private recentlyRestoredCheckpoint: boolean = false;
173+
172174
private settingChangeCounter = 0;
173175

174176
private listContainer!: HTMLElement;
@@ -969,7 +971,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
969971

970972
this._register(this.renderer.onDidFocusOutside(() => {
971973
this.finishedEditing();
972-
this.viewModel?.model.setCheckpoint(undefined);
973974
}));
974975

975976
this._register(this.renderer.onDidClickFollowup(item => {
@@ -1062,6 +1063,11 @@ export class ChatWidget extends Disposable implements IChatWidget {
10621063
return;
10631064
}
10641065

1066+
// this will only ever be true if we restored a checkpoint
1067+
if (this.viewModel?.model.checkpoint) {
1068+
this.recentlyRestoredCheckpoint = true;
1069+
}
1070+
10651071
this.viewModel?.model.setCheckpoint(currentElement.id);
10661072

10671073
// set contexts and request to false
@@ -1144,7 +1150,11 @@ export class ChatWidget extends Disposable implements IChatWidget {
11441150
finishedEditing(completedEdit?: boolean): void {
11451151
// reset states
11461152
const editedRequest = this.renderer.getTemplateDataForRequestId(this.viewModel?.editing?.id);
1147-
this.viewModel?.model.setCheckpoint(undefined);
1153+
if (this.recentlyRestoredCheckpoint) {
1154+
this.recentlyRestoredCheckpoint = false;
1155+
} else {
1156+
this.viewModel?.model.setCheckpoint(undefined);
1157+
}
11481158
this.inputPart.dnd.setDisabledOverlay(false);
11491159
if (editedRequest?.contextKeyService) {
11501160
ChatContextKeys.currentlyEditing.bindTo(editedRequest.contextKeyService).set(false);
@@ -1750,6 +1760,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
17501760

17511761
if (this.viewModel?.editing) {
17521762
this.finishedEditing(true);
1763+
this.viewModel.model?.setCheckpoint(undefined);
17531764
}
17541765
return result.responseCreatedPromise;
17551766
}

0 commit comments

Comments
 (0)