mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-02 00:09:30 +01:00
change first checkpoint to something more friendly (#306178)
This commit is contained in:
@@ -39,6 +39,7 @@ export function registerChatForkActions() {
|
||||
order: 3,
|
||||
when: ContextKeyExpr.and(
|
||||
ChatContextKeys.isRequest,
|
||||
ChatContextKeys.isFirstRequest.negate(),
|
||||
ContextKeyExpr.or(
|
||||
ChatContextKeys.lockedToCodingAgent.negate(),
|
||||
ChatContextKeys.chatSessionSupportsFork
|
||||
|
||||
@@ -583,7 +583,7 @@ registerAction2(class RestoreCheckpointAction extends Action2 {
|
||||
id: MenuId.ChatMessageCheckpoint,
|
||||
group: 'navigation',
|
||||
order: 2,
|
||||
when: ContextKeyExpr.and(ChatContextKeys.isRequest, ChatContextKeys.lockedToCodingAgent.negate())
|
||||
when: ContextKeyExpr.and(ChatContextKeys.isRequest, ChatContextKeys.lockedToCodingAgent.negate(), ChatContextKeys.isFirstRequest.negate())
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -617,6 +617,42 @@ registerAction2(class RestoreCheckpointAction extends Action2 {
|
||||
}
|
||||
});
|
||||
|
||||
registerAction2(class StartOverAction extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: 'workbench.action.chat.startOver',
|
||||
title: localize2('chat.startOver.label', "Start Over"),
|
||||
tooltip: localize2('chat.startOver.tooltip', "Clears the chat and undoes all changes"),
|
||||
f1: false,
|
||||
category: CHAT_CATEGORY,
|
||||
menu: [
|
||||
{
|
||||
id: MenuId.ChatMessageCheckpoint,
|
||||
group: 'navigation',
|
||||
order: 2,
|
||||
when: ContextKeyExpr.and(ChatContextKeys.isRequest, ChatContextKeys.lockedToCodingAgent.negate(), ChatContextKeys.isFirstRequest)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(accessor: ServicesAccessor, ...args: unknown[]) {
|
||||
let item = args[0] as ChatTreeItem | undefined;
|
||||
const chatWidgetService = accessor.get(IChatWidgetService);
|
||||
const widget = (isChatTreeItem(item) && chatWidgetService.getWidgetBySessionResource(item.sessionResource)) || chatWidgetService.lastFocusedWidget;
|
||||
if (!isResponseVM(item) && !isRequestVM(item)) {
|
||||
item = widget?.getFocus();
|
||||
}
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
widget?.viewModel?.model.setCheckpoint(item.id);
|
||||
await restoreSnapshotWithConfirmation(accessor, item);
|
||||
}
|
||||
});
|
||||
|
||||
registerAction2(class RestoreLastCheckpoint extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
|
||||
@@ -709,6 +709,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
|
||||
ChatContextKeys.isResponse.bindTo(templateData.contextKeyService).set(isResponseVM(element));
|
||||
ChatContextKeys.itemId.bindTo(templateData.contextKeyService).set(element.id);
|
||||
ChatContextKeys.isRequest.bindTo(templateData.contextKeyService).set(isRequestVM(element));
|
||||
ChatContextKeys.isFirstRequest.bindTo(templateData.contextKeyService).set(isRequestVM(element) && this.viewModel?.model.getRequests()[0]?.id === element.id);
|
||||
ChatContextKeys.isPendingRequest.bindTo(templateData.contextKeyService).set(isRequestVM(element) && !!element.pendingKind);
|
||||
ChatContextKeys.responseDetectedAgentCommand.bindTo(templateData.contextKeyService).set(isResponseVM(element) && element.agentOrSlashCommandDetected);
|
||||
if (isResponseVM(element)) {
|
||||
|
||||
@@ -30,6 +30,7 @@ export namespace ChatContextKeys {
|
||||
|
||||
export const isResponse = new RawContextKey<boolean>('chatResponse', false, { type: 'boolean', description: localize('chatResponse', "The chat item is a response.") });
|
||||
export const isRequest = new RawContextKey<boolean>('chatRequest', false, { type: 'boolean', description: localize('chatRequest', "The chat item is a request") });
|
||||
export const isFirstRequest = new RawContextKey<boolean>('chatFirstRequest', false, { type: 'boolean', description: localize('chatFirstRequest', "The chat item is the first request in the session.") });
|
||||
export const isPendingRequest = new RawContextKey<boolean>('chatRequestIsPending', false, { type: 'boolean', description: localize('chatRequestIsPending', "True when the chat request item is pending in the queue.") });
|
||||
export const itemId = new RawContextKey<string>('chatItemId', '', { type: 'string', description: localize('chatItemId', "The id of the chat item.") });
|
||||
export const lastItemId = new RawContextKey<string[]>('chatLastItemId', [], { type: 'string', description: localize('chatLastItemId', "The id of the last chat item.") });
|
||||
|
||||
Reference in New Issue
Block a user