From 4dbe662aba217db372ba147c3a6cc7269ba67780 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Tue, 17 Dec 2024 10:40:17 -0600 Subject: [PATCH 1/3] fix #236368 --- .../src/terminalSuggestMain.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/extensions/terminal-suggest/src/terminalSuggestMain.ts b/extensions/terminal-suggest/src/terminalSuggestMain.ts index 5071c4c79ce96..4acd5b59f8a00 100644 --- a/extensions/terminal-suggest/src/terminalSuggestMain.ts +++ b/extensions/terminal-suggest/src/terminalSuggestMain.ts @@ -328,16 +328,6 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon } } } - const shouldShowCommands = !terminalContext.commandLine.substring(0, terminalContext.cursorPosition).trimStart().includes(' '); - if (shouldShowCommands && (filesRequested === foldersRequested)) { - // Include builitin/available commands in the results - const labels = new Set(items.map(i => i.label)); - for (const command of availableCommands) { - if (!labels.has(command)) { - items.push(createCompletionItem(terminalContext.cursorPosition, prefix, command)); - } - } - } const shouldShowResourceCompletions = ( @@ -351,6 +341,17 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon // and neither files nor folders are going to be requested (for a specific spec's argument) && (!filesRequested && !foldersRequested); + const shouldShowCommands = !terminalContext.commandLine.substring(0, terminalContext.cursorPosition).trimStart().includes(' '); + if (shouldShowCommands && (filesRequested === foldersRequested)) { + // Include builitin/available commands in the results + const labels = new Set(items.map(i => i.label)); + for (const command of availableCommands) { + if (!labels.has(command)) { + items.push(createCompletionItem(terminalContext.cursorPosition, prefix, command)); + } + } + } + if (shouldShowResourceCompletions) { filesRequested = true; foldersRequested = true; From 8f7fa310047bc6681d5929fa27a87fbc52038e0e Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Tue, 17 Dec 2024 12:03:56 -0600 Subject: [PATCH 2/3] wip https://github.com/microsoft/vscode-copilot/issues/5732 --- .../chat/browser/terminalChat.ts | 1 + .../chat/browser/terminalChatActions.ts | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.ts b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.ts index b182074753e8b..5f16923d086b7 100644 --- a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.ts +++ b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.ts @@ -17,6 +17,7 @@ export const enum TerminalChatCommandId { InsertCommand = 'workbench.action.terminal.chat.insertCommand', InsertFirstCommand = 'workbench.action.terminal.chat.insertFirstCommand', ViewInChat = 'workbench.action.terminal.chat.viewInChat', + RerunRequest = 'workbench.action.terminal.chat.rerunRequest', } export const MENU_TERMINAL_CHAT_WIDGET_INPUT_SIDE_TOOLBAR = MenuId.for('terminalChatWidget'); diff --git a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts index 38bb507fe3b63..deeb48f48c792 100644 --- a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts +++ b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.ts @@ -8,6 +8,9 @@ import { KeyCode, KeyMod } from '../../../../../base/common/keyCodes.js'; import { localize2 } from '../../../../../nls.js'; import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js'; import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js'; +import { IChatWidgetService } from '../../../chat/browser/chat.js'; +import { ChatAgentLocation } from '../../../chat/common/chatAgents.js'; +import { IChatService } from '../../../chat/common/chatService.js'; import { AbstractInlineChatAction } from '../../../inlineChat/browser/inlineChatActions.js'; import { isDetachedTerminalInstance } from '../../../terminal/browser/terminal.js'; import { registerActiveXtermAction } from '../../../terminal/browser/terminalActions.js'; @@ -209,6 +212,48 @@ registerActiveXtermAction({ } }); +registerActiveXtermAction({ + id: TerminalChatCommandId.RerunRequest, + title: localize2('chat.rerun.label', "Rerun Request"), + f1: false, + icon: Codicon.refresh, + category: AbstractInlineChatAction.category, + precondition: ContextKeyExpr.and( + ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.terminalHasBeenCreated), + TerminalChatContextKeys.requestActive.negate(), + ), + keybinding: { + weight: KeybindingWeight.WorkbenchContrib, + primary: KeyMod.CtrlCmd | KeyCode.KeyR + }, + menu: { + id: MENU_TERMINAL_CHAT_WIDGET_STATUS, + group: '0_main', + order: 5, + when: ContextKeyExpr.and(TerminalChatContextKeys.inputHasText.toNegated(), TerminalChatContextKeys.requestActive.negate()) + }, + run: async (_xterm, _accessor, activeInstance) => { + const chatService = _accessor.get(IChatService); + const chatWidgetService = _accessor.get(IChatWidgetService); + const contr = TerminalChatController.activeChatController; + const model = contr?.terminalChatWidget?.inlineChatWidget.chatWidget.viewModel?.model; + if (!model) { + return; + } + + const lastRequest = model.getRequests().at(-1); + if (lastRequest) { + const widget = chatWidgetService.getWidgetBySessionId(model.sessionId); + await chatService.resendRequest(lastRequest, { + noCommandDetection: false, + attempt: lastRequest.attempt + 1, + location: ChatAgentLocation.Terminal, + userSelectedModelId: widget?.input.currentLanguageModel + }); + } + } +}); + registerActiveXtermAction({ id: TerminalChatCommandId.ViewInChat, title: localize2('viewInChat', 'View in Chat'), From 0e534796e40dce204420b77e4809d935a17e3e4f Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Tue, 17 Dec 2024 12:40:34 -0600 Subject: [PATCH 3/3] fix issue --- .../contrib/terminalContrib/chat/browser/terminalChatWidget.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.ts b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.ts index b668b55abc5dc..d1a310aae2914 100644 --- a/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.ts +++ b/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.ts @@ -127,6 +127,8 @@ export class TerminalChatWidget extends Disposable { menu: MENU_TERMINAL_CHAT_WIDGET_STATUS, options: { buttonConfigProvider: action => ({ + showLabel: action.id !== TerminalChatCommandId.RerunRequest, + showIcon: action.id === TerminalChatCommandId.RerunRequest, isSecondary: action.id !== TerminalChatCommandId.RunCommand && action.id !== TerminalChatCommandId.RunFirstCommand }) }