mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-16 09:01:17 -07:00
refactor(ide): replace DetectedIde enum with IDE_DEFINITIONS object (#8698)
This commit is contained in:
@@ -31,7 +31,7 @@ import { MessageType, StreamingState } from './types.js';
|
||||
import {
|
||||
type EditorType,
|
||||
type Config,
|
||||
type DetectedIde,
|
||||
type IdeInfo,
|
||||
type IdeContext,
|
||||
type UserTierId,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
@@ -717,7 +717,7 @@ Logging in with Google... Please restart Gemini CLI to continue.
|
||||
]);
|
||||
|
||||
const [idePromptAnswered, setIdePromptAnswered] = useState(false);
|
||||
const [currentIDE, setCurrentIDE] = useState<DetectedIde | null>(null);
|
||||
const [currentIDE, setCurrentIDE] = useState<IdeInfo | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const getIde = async () => {
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type { DetectedIde } from '@google/gemini-cli-core';
|
||||
import { getIdeInfo } from '@google/gemini-cli-core';
|
||||
import type { IdeInfo } from '@google/gemini-cli-core';
|
||||
import { Box, Text } from 'ink';
|
||||
import type { RadioSelectItem } from './components/shared/RadioButtonSelect.js';
|
||||
import { RadioButtonSelect } from './components/shared/RadioButtonSelect.js';
|
||||
@@ -18,7 +17,7 @@ export type IdeIntegrationNudgeResult = {
|
||||
};
|
||||
|
||||
interface IdeIntegrationNudgeProps {
|
||||
ide: DetectedIde;
|
||||
ide: IdeInfo;
|
||||
onComplete: (result: IdeIntegrationNudgeResult) => void;
|
||||
}
|
||||
|
||||
@@ -38,7 +37,7 @@ export function IdeIntegrationNudge({
|
||||
{ isActive: true },
|
||||
);
|
||||
|
||||
const { displayName: ideName } = getIdeInfo(ide);
|
||||
const { displayName: ideName } = ide;
|
||||
// Assume extension is already installed if the env variables are set.
|
||||
const isExtensionPreInstalled =
|
||||
!!process.env['GEMINI_CLI_IDE_SERVER_PORT'] &&
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { MockInstance } from 'vitest';
|
||||
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { ideCommand } from './ideCommand.js';
|
||||
import { type CommandContext } from './types.js';
|
||||
import { DetectedIde } from '@google/gemini-cli-core';
|
||||
import { IDE_DEFINITIONS } from '@google/gemini-cli-core';
|
||||
import * as core from '@google/gemini-cli-core';
|
||||
|
||||
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
@@ -36,11 +36,14 @@ describe('ideCommand', () => {
|
||||
disconnect: vi.fn(),
|
||||
connect: vi.fn(),
|
||||
getCurrentIde: vi.fn(),
|
||||
getDetectedIdeDisplayName: vi.fn(),
|
||||
getConnectionStatus: vi.fn(),
|
||||
getDetectedIdeDisplayName: vi.fn(),
|
||||
} as unknown as core.IdeClient;
|
||||
|
||||
vi.mocked(core.IdeClient.getInstance).mockResolvedValue(mockIdeClient);
|
||||
vi.mocked(mockIdeClient.getDetectedIdeDisplayName).mockReturnValue(
|
||||
'VS Code',
|
||||
);
|
||||
|
||||
mockContext = {
|
||||
ui: {
|
||||
@@ -66,9 +69,8 @@ describe('ideCommand', () => {
|
||||
});
|
||||
|
||||
it('should return the ide command', async () => {
|
||||
vi.mocked(mockIdeClient.getCurrentIde).mockReturnValue(DetectedIde.VSCode);
|
||||
vi.mocked(mockIdeClient.getDetectedIdeDisplayName).mockReturnValue(
|
||||
'VS Code',
|
||||
vi.mocked(mockIdeClient.getCurrentIde).mockReturnValue(
|
||||
IDE_DEFINITIONS.vscode,
|
||||
);
|
||||
vi.mocked(mockIdeClient.getConnectionStatus).mockReturnValue({
|
||||
status: core.IDEConnectionStatus.Disconnected,
|
||||
@@ -83,9 +85,8 @@ describe('ideCommand', () => {
|
||||
});
|
||||
|
||||
it('should show disable command when connected', async () => {
|
||||
vi.mocked(mockIdeClient.getCurrentIde).mockReturnValue(DetectedIde.VSCode);
|
||||
vi.mocked(mockIdeClient.getDetectedIdeDisplayName).mockReturnValue(
|
||||
'VS Code',
|
||||
vi.mocked(mockIdeClient.getCurrentIde).mockReturnValue(
|
||||
IDE_DEFINITIONS.vscode,
|
||||
);
|
||||
vi.mocked(mockIdeClient.getConnectionStatus).mockReturnValue({
|
||||
status: core.IDEConnectionStatus.Connected,
|
||||
@@ -100,10 +101,7 @@ describe('ideCommand', () => {
|
||||
describe('status subcommand', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(mockIdeClient.getCurrentIde).mockReturnValue(
|
||||
DetectedIde.VSCode,
|
||||
);
|
||||
vi.mocked(mockIdeClient.getDetectedIdeDisplayName).mockReturnValue(
|
||||
'VS Code',
|
||||
IDE_DEFINITIONS.vscode,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -177,10 +175,7 @@ describe('ideCommand', () => {
|
||||
const mockInstall = vi.fn();
|
||||
beforeEach(() => {
|
||||
vi.mocked(mockIdeClient.getCurrentIde).mockReturnValue(
|
||||
DetectedIde.VSCode,
|
||||
);
|
||||
vi.mocked(mockIdeClient.getDetectedIdeDisplayName).mockReturnValue(
|
||||
'VS Code',
|
||||
IDE_DEFINITIONS.vscode,
|
||||
);
|
||||
vi.mocked(mockIdeClient.getConnectionStatus).mockReturnValue({
|
||||
status: core.IDEConnectionStatus.Disconnected,
|
||||
@@ -211,7 +206,7 @@ describe('ideCommand', () => {
|
||||
await vi.runAllTimersAsync();
|
||||
await actionPromise;
|
||||
|
||||
expect(core.getIdeInstaller).toHaveBeenCalledWith('vscode');
|
||||
expect(core.getIdeInstaller).toHaveBeenCalledWith(IDE_DEFINITIONS.vscode);
|
||||
expect(mockInstall).toHaveBeenCalled();
|
||||
expect(mockContext.ui.addItem).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -249,7 +244,7 @@ describe('ideCommand', () => {
|
||||
'',
|
||||
);
|
||||
|
||||
expect(core.getIdeInstaller).toHaveBeenCalledWith('vscode');
|
||||
expect(core.getIdeInstaller).toHaveBeenCalledWith(IDE_DEFINITIONS.vscode);
|
||||
expect(mockInstall).toHaveBeenCalled();
|
||||
expect(mockContext.ui.addItem).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -135,7 +135,7 @@ async function setIdeModeAndSyncConnection(
|
||||
export const ideCommand = async (): Promise<SlashCommand> => {
|
||||
const ideClient = await IdeClient.getInstance();
|
||||
const currentIDE = ideClient.getCurrentIde();
|
||||
if (!currentIDE || !ideClient.getDetectedIdeDisplayName()) {
|
||||
if (!currentIDE) {
|
||||
return {
|
||||
name: 'ide',
|
||||
description: 'manage IDE integration',
|
||||
|
||||
@@ -21,7 +21,7 @@ import type {
|
||||
IdeContext,
|
||||
ApprovalMode,
|
||||
UserTierId,
|
||||
DetectedIde,
|
||||
IdeInfo,
|
||||
FallbackIntent,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { DOMElement } from 'ink';
|
||||
@@ -104,7 +104,7 @@ export interface UIState {
|
||||
terminalWidth: number;
|
||||
terminalHeight: number;
|
||||
mainControlsRef: React.MutableRefObject<DOMElement | null>;
|
||||
currentIDE: DetectedIde | null;
|
||||
currentIDE: IdeInfo | null;
|
||||
updateInfo: UpdateObject | null;
|
||||
showIdeRestartPrompt: boolean;
|
||||
isRestarting: boolean;
|
||||
|
||||
Reference in New Issue
Block a user