refactor(ide): replace DetectedIde enum with IDE_DEFINITIONS object (#8698)

This commit is contained in:
Shreya Keshive
2025-09-18 15:23:24 -04:00
committed by GitHub
parent f2a47dec54
commit db5b49b2ca
16 changed files with 129 additions and 229 deletions
+8 -14
View File
@@ -6,7 +6,7 @@
import * as fs from 'node:fs';
import { isSubpath } from '../utils/paths.js';
import { detectIde, type DetectedIde, getIdeInfo } from '../ide/detect-ide.js';
import { detectIde, type IdeInfo } from '../ide/detect-ide.js';
import { ideContextStore } from './ideContext.js';
import {
IdeContextNotificationSchema,
@@ -85,8 +85,7 @@ export class IdeClient {
details:
'IDE integration is currently disabled. To enable it, run /ide enable.',
};
private currentIde: DetectedIde | undefined;
private currentIdeDisplayName: string | undefined;
private currentIde: IdeInfo | undefined;
private ideProcessInfo: { pid: number; command: string } | undefined;
private authToken: string | undefined;
private diffResponses = new Map<string, (result: DiffUpdateResult) => void>();
@@ -108,11 +107,6 @@ export class IdeClient {
const client = new IdeClient();
client.ideProcessInfo = await getIdeProcessInfo();
client.currentIde = detectIde(client.ideProcessInfo);
if (client.currentIde) {
client.currentIdeDisplayName = getIdeInfo(
client.currentIde,
).displayName;
}
return client;
})();
}
@@ -136,7 +130,7 @@ export class IdeClient {
}
async connect(): Promise<void> {
if (!this.currentIde || !this.currentIdeDisplayName) {
if (!this.currentIde) {
this.setState(
IDEConnectionStatus.Disconnected,
`IDE integration is not supported in your current environment. To use this feature, run Gemini CLI in one of these supported IDEs: VS Code or VS Code forks`,
@@ -157,7 +151,7 @@ export class IdeClient {
const { isValid, error } = IdeClient.validateWorkspacePath(
workspacePath,
this.currentIdeDisplayName,
this.currentIde.displayName,
process.cwd(),
);
@@ -203,7 +197,7 @@ export class IdeClient {
this.setState(
IDEConnectionStatus.Disconnected,
`Failed to connect to IDE companion extension in ${this.currentIdeDisplayName}. Please ensure the extension is running. To install the extension, run /ide install.`,
`Failed to connect to IDE companion extension in ${this.currentIde.displayName}. Please ensure the extension is running. To install the extension, run /ide install.`,
true,
);
}
@@ -407,7 +401,7 @@ export class IdeClient {
this.client?.close();
}
getCurrentIde(): DetectedIde | undefined {
getCurrentIde(): IdeInfo | undefined {
return this.currentIde;
}
@@ -416,7 +410,7 @@ export class IdeClient {
}
getDetectedIdeDisplayName(): string | undefined {
return this.currentIdeDisplayName;
return this.currentIde?.displayName;
}
isDiffingEnabled(): boolean {
@@ -636,7 +630,7 @@ export class IdeClient {
}
const { isValid } = IdeClient.validateWorkspacePath(
content.workspacePath,
this.currentIdeDisplayName,
this.currentIde?.displayName,
process.cwd(),
);
return isValid;