Skip to content

Commit 957cb94

Browse files
authored
fix: assign keybinding for edits view (microsoft#232214) (microsoft#232215)
* fix: assign keybinding for edits view (microsoft#232214) * fix: don't unnecessarily prompt when clearing existing editing session * fix: only reveal chat edited files after they exist on disk * fix: sync all attachments to working set when submitting request
1 parent 59260b3 commit 957cb94

File tree

7 files changed

+32
-18
lines changed

7 files changed

+32
-18
lines changed

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,6 @@ export function registerNewChatActions() {
166166
});
167167

168168
return Boolean(result);
169-
} else {
170-
const result = await dialogService.confirm({
171-
title: localize('chat.startEditing.confirmation.title', "Start new editing session?"),
172-
message: localize('chat.startEditing.confirmation.message', "Starting a new editing session will end your current editing session and discard edits to {0} files. Do you wish to proceed?", currentEditCount),
173-
type: 'info',
174-
primaryButton: localize('chat.startEditing.confirmation.primaryButton', "Yes")
175-
});
176-
177-
return result.confirmed;
178169
}
179170
}
180171

@@ -328,7 +319,7 @@ export function registerNewChatActions() {
328319
constructor() {
329320
super({
330321
id: 'workbench.action.chat.openEditSession',
331-
title: localize2('chat.openEdits.label', "Open Edit Session"),
322+
title: localize2('chat.openEdits.label', "Open {0}", 'Copilot Edits'),
332323
category: CHAT_CATEGORY,
333324
icon: Codicon.goToEditingSession,
334325
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED),
@@ -343,7 +334,12 @@ export function registerNewChatActions() {
343334
when: CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED,
344335
group: 'a_chatEdit',
345336
order: 1
346-
}]
337+
}],
338+
keybinding: {
339+
weight: KeybindingWeight.WorkbenchContrib,
340+
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyI,
341+
when: ContextKeyExpr.and(ContextKeyExpr.notEquals('view', EDITS_VIEW_ID), CONTEXT_CHAT_EDITING_PARTICIPANT_REGISTERED)
342+
}
347343
});
348344
}
349345

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ class SendToChatEditingAction extends Action2 {
216216
if (currentEditCount) {
217217
const result = await dialogService.confirm({
218218
title: localize('chat.startEditing.confirmation.title', "Start new editing session?"),
219-
message: localize('chat.startEditing.confirmation.message', "Starting a new editing session will end your current editing session and discard edits to {0} files. Do you wish to proceed?", currentEditCount),
219+
message: currentEditCount === 1
220+
? localize('chat.startEditing.confirmation.message.one', "Starting a new editing session will end your current editing session containing {0} file. Do you wish to proceed?", currentEditCount)
221+
: localize('chat.startEditing.confirmation.message.many', "Starting a new editing session will end your current editing session containing {0} files. Do you wish to proceed?", currentEditCount),
220222
type: 'info',
221223
primaryButton: localize('chat.startEditing.confirmation.primaryButton', "Yes")
222224
});

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ class QuickChatGlobalAction extends Action2 {
109109
category: CHAT_CATEGORY,
110110
keybinding: {
111111
weight: KeybindingWeight.WorkbenchContrib,
112-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyI,
113-
linux: {
114-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.KeyI
115-
}
112+
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.KeyI,
116113
},
117114
menu: {
118115
id: MenuId.ChatCommandCenter,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,9 @@ export function registerChatTitleActions() {
474474
} else {
475475
const result = await dialogService.confirm({
476476
title: localize('chat.startEditing.confirmation.title', "Start new editing session?"),
477-
message: localize('chat.startEditing.confirmation.message', "Starting a new editing session will end your current editing session and discard edits to {0} files. Do you wish to proceed?", currentEditCount),
477+
message: currentEditCount
478+
? localize('chat.startEditing.confirmation.message.one', "Starting a new editing session will end your current editing session containing {0} file. Do you wish to proceed?", currentEditCount)
479+
: localize('chat.startEditing.confirmation.message.many', "Starting a new editing session will end your current editing session containing {0} files. Do you wish to proceed?", currentEditCount),
478480
type: 'info',
479481
primaryButton: localize('chat.startEditing.confirmation.primaryButton', "Yes")
480482
});

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ITextModelService } from '../../../../../editor/common/services/resolve
2020
import { localize, localize2 } from '../../../../../nls.js';
2121
import { IContextKey, IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
2222
import { EditorActivation } from '../../../../../platform/editor/common/editor.js';
23+
import { IFileService } from '../../../../../platform/files/common/files.js';
2324
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
2425
import { bindContextKey } from '../../../../../platform/observable/common/platformObservableUtils.js';
2526
import { IProgressService, ProgressLocation } from '../../../../../platform/progress/common/progress.js';
@@ -86,6 +87,7 @@ export class ChatEditingService extends Disposable implements IChatEditingServic
8687
@ICodeMapperService private readonly _codeMapperService: ICodeMapperService,
8788
@IEditorService private readonly _editorService: IEditorService,
8889
@IDecorationsService decorationsService: IDecorationsService,
90+
@IFileService private readonly _fileService: IFileService,
8991
@IWorkbenchAssignmentService private readonly _workbenchAssignmentService: IWorkbenchAssignmentService
9092
) {
9193
super();
@@ -243,6 +245,7 @@ export class ChatEditingService extends Disposable implements IChatEditingServic
243245

244246
let editsSource: AsyncIterableSource<IChatTextEditGroup> | undefined;
245247
const editsSeen = new ResourceMap<{ seen: number }>();
248+
const editedFilesExist = new ResourceMap<Promise<boolean>>();
246249

247250
const onResponseComplete = (responseModel: IChatResponseModel) => {
248251
if (responseModel.result?.errorDetails) {
@@ -256,14 +259,22 @@ export class ChatEditingService extends Disposable implements IChatEditingServic
256259
editsSource?.resolve();
257260
editsSource = undefined;
258261
editsSeen.clear();
262+
editedFilesExist.clear();
259263
};
260264

261265

262266
const handleResponseParts = (responseModel: IChatResponseModel) => {
263267
for (const part of responseModel.response.value) {
264268
if (part.kind === 'codeblockUri' || part.kind === 'textEditGroup') {
265269
// ensure editor is open asap
266-
this._editorService.openEditor({ resource: part.uri, options: { inactive: true, preserveFocus: true, pinned: true } });
270+
if (!editedFilesExist.get(part.uri)) {
271+
editedFilesExist.set(part.uri, this._fileService.exists(part.uri).then((e) => {
272+
if (e) {
273+
this._editorService.openEditor({ resource: part.uri, options: { inactive: true, preserveFocus: true, pinned: true } });
274+
}
275+
return e;
276+
}));
277+
}
267278

268279
// get new edits and start editing session
269280
const first = editsSeen.size === 0;

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
593593
}
594594
// this file does not exist yet, create it and try again
595595
await this._bulkEditService.apply({ edits: [{ newResource: resource }] });
596+
this._editorService.openEditor({ resource, options: { inactive: true, preserveFocus: true, pinned: true } });
596597
return this._createModifiedFileEntry(resource, responseModel, true);
597598
}
598599
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,11 @@ export class ChatWidget extends Disposable implements IChatWidget {
10121012
}
10131013
}
10141014
workingSet = [...uniqueWorkingSetEntries.values()];
1015+
const currentEditingSession = this.chatEditingService.currentEditingSessionObs.get();
1016+
for (const file of workingSet) {
1017+
// Make sure that any files that we sent are part of the working set
1018+
currentEditingSession?.addFileToWorkingSet(file);
1019+
}
10151020
attachedContext = editingSessionAttachedContext;
10161021
}
10171022

0 commit comments

Comments
 (0)