Skip to content

Commit

Permalink
Fix enablement of Terminal AI support
Browse files Browse the repository at this point in the history
Due to recent changes, the Terminal AI support didn't show up anymore, even if the experimental AI support was enabled via the preferences. Neither the context menu nor the keyboard shortcut (Ctrl-I) was working.

This change fixes that by removing the context key constraints. The context menu and the keyboard shortcut are enabled/disabled with the AI experimental support setting via the `AICommandHandlerFactory` anyway, as it seems.
  • Loading branch information
planger committed Sep 15, 2024
1 parent e1aeb7c commit e700392
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/ai-terminal/src/browser/ai-terminal-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { EXPERIMENTAL_AI_CONTEXT_KEY } from '@theia/ai-core/lib/browser';
import { AICommandHandlerFactory } from '@theia/ai-core/lib/browser/ai-command-handler-factory';
import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core';
import { KeybindingContribution, KeybindingRegistry } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
import { TerminalMenus } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
import { TerminalWidgetImpl } from '@theia/terminal/lib/browser/terminal-widget-impl';
import { AiTerminalAgent } from './ai-terminal-agent';
import { AICommandHandlerFactory } from '@theia/ai-core/lib/browser/ai-command-handler-factory';

const AI_TERMINAL_COMMAND = {
id: 'ai-terminal:open',
label: 'Ask the AI'
label: 'Ask the AI',
};

@injectable()
Expand All @@ -45,12 +44,11 @@ export class AiTerminalCommandContribution implements CommandContribution, MenuC
keybindings.registerKeybinding({
command: AI_TERMINAL_COMMAND.id,
keybinding: 'ctrlcmd+i',
when: `terminalFocus && ${EXPERIMENTAL_AI_CONTEXT_KEY}`
when: 'terminalFocus'
});
}
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction([...TerminalMenus.TERMINAL_CONTEXT_MENU, '_5'], {
when: EXPERIMENTAL_AI_CONTEXT_KEY,
commandId: AI_TERMINAL_COMMAND.id
});
}
Expand Down

0 comments on commit e700392

Please sign in to comment.