mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
support terminal chat acessible view actions, fix content (#229448)
fix #210256
This commit is contained in:
@@ -139,7 +139,7 @@ class AccessibleViewGoToSymbolAction extends Action2 {
|
||||
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Period],
|
||||
weight: KeybindingWeight.WorkbenchContrib + 10
|
||||
},
|
||||
icon: Codicon.symbolField,
|
||||
icon: Codicon.symbolMisc,
|
||||
menu: [
|
||||
commandPalette,
|
||||
{
|
||||
|
||||
@@ -9,15 +9,32 @@ import { ITerminalService } from '../../../terminal/browser/terminal.js';
|
||||
import { TerminalChatController } from './terminalChatController.js';
|
||||
import { IAccessibleViewImplentation } from '../../../../../platform/accessibility/browser/accessibleViewRegistry.js';
|
||||
import { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';
|
||||
import { TerminalChatContextKeys } from './terminalChat.js';
|
||||
import { IMenuService, MenuItemAction } from '../../../../../platform/actions/common/actions.js';
|
||||
import { MENU_TERMINAL_CHAT_WIDGET_STATUS, TerminalChatContextKeys } from './terminalChat.js';
|
||||
import { IAction } from '../../../../../base/common/actions.js';
|
||||
|
||||
export class TerminalInlineChatAccessibleView implements IAccessibleViewImplentation {
|
||||
readonly priority = 105;
|
||||
readonly name = 'terminalInlineChat';
|
||||
readonly type = AccessibleViewType.View;
|
||||
readonly when = TerminalChatContextKeys.focused;
|
||||
|
||||
getProvider(accessor: ServicesAccessor) {
|
||||
const terminalService = accessor.get(ITerminalService);
|
||||
const menuService = accessor.get(IMenuService);
|
||||
const actions: IAction[] = [];
|
||||
const contextKeyService = TerminalChatController.activeChatController?.scopedContextKeyService;
|
||||
if (contextKeyService) {
|
||||
const menuActions = menuService.getMenuActions(MENU_TERMINAL_CHAT_WIDGET_STATUS, contextKeyService);
|
||||
for (const action of menuActions) {
|
||||
for (const a of action[1]) {
|
||||
if (a instanceof MenuItemAction) {
|
||||
actions.push(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const controller: TerminalChatController | undefined = terminalService.activeInstance?.getContribution(TerminalChatController.ID) ?? undefined;
|
||||
if (!controller?.lastResponseContent) {
|
||||
return;
|
||||
@@ -31,6 +48,8 @@ export class TerminalInlineChatAccessibleView implements IAccessibleViewImplenta
|
||||
controller.focus();
|
||||
},
|
||||
AccessibilityVerbositySettingId.InlineChat,
|
||||
undefined,
|
||||
actions
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +175,7 @@ registerActiveXtermAction({
|
||||
id: TerminalChatCommandId.InsertCommand,
|
||||
title: localize2('insertCommand', 'Insert Chat Command'),
|
||||
shortTitle: localize2('insert', 'Insert'),
|
||||
icon: Codicon.insert,
|
||||
precondition: ContextKeyExpr.and(
|
||||
ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.terminalHasBeenCreated),
|
||||
TerminalChatContextKeys.requestActive.negate(),
|
||||
|
||||
@@ -250,8 +250,10 @@ export class TerminalChatController extends Disposable implements ITerminalContr
|
||||
}));
|
||||
}
|
||||
await responsePromise.p;
|
||||
this._lastResponseContent = response?.response.toMarkdown();
|
||||
return response;
|
||||
} catch {
|
||||
this._lastResponseContent = undefined;
|
||||
return;
|
||||
} finally {
|
||||
store.dispose();
|
||||
|
||||
Reference in New Issue
Block a user