diff options
| author | Shreya Keshive <[email protected]> | 2025-08-05 18:52:58 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-05 22:52:58 +0000 |
| commit | 268627469b384ba3fa8dfe2e05b5186248013070 (patch) | |
| tree | 27d6421c6d7cc7986d284fa8f7bf0fece9c607e3 /packages/core/src/config/config.ts | |
| parent | 6a72cd064bccb5fda4618671c2da63c4e22c1ef9 (diff) | |
Refactor IDE client state management, improve user-facing error messages, and add logging of connection events (#5591)
Co-authored-by: matt korwel <[email protected]>
Diffstat (limited to 'packages/core/src/config/config.ts')
| -rw-r--r-- | packages/core/src/config/config.ts | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 22996f3e..fa51a6af 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -48,6 +48,8 @@ import { shouldAttemptBrowserLaunch } from '../utils/browser.js'; import { MCPOAuthConfig } from '../mcp/oauth-provider.js'; import { IdeClient } from '../ide/ide-client.js'; import type { Content } from '@google/genai'; +import { logIdeConnection } from '../telemetry/loggers.js'; +import { IdeConnectionEvent, IdeConnectionType } from '../telemetry/types.js'; // Re-export OAuth config type export type { MCPOAuthConfig }; @@ -187,7 +189,6 @@ export interface ConfigParameters { summarizeToolOutput?: Record<string, SummarizeToolOutputSettings>; ideModeFeature?: boolean; ideMode?: boolean; - ideClient: IdeClient; loadMemoryFromIncludeDirectories?: boolean; } @@ -305,7 +306,11 @@ export class Config { this.summarizeToolOutput = params.summarizeToolOutput; this.ideModeFeature = params.ideModeFeature ?? false; this.ideMode = params.ideMode ?? false; - this.ideClient = params.ideClient; + this.ideClient = IdeClient.getInstance(); + if (this.ideMode && this.ideModeFeature) { + this.ideClient.connect(); + logIdeConnection(this, new IdeConnectionEvent(IdeConnectionType.START)); + } this.loadMemoryFromIncludeDirectories = params.loadMemoryFromIncludeDirectories ?? false; @@ -633,10 +638,6 @@ export class Config { return this.ideModeFeature; } - getIdeClient(): IdeClient { - return this.ideClient; - } - getIdeMode(): boolean { return this.ideMode; } @@ -645,12 +646,18 @@ export class Config { this.ideMode = value; } - setIdeClientDisconnected(): void { - this.ideClient.setDisconnected(); + async setIdeModeAndSyncConnection(value: boolean): Promise<void> { + this.ideMode = value; + if (value) { + await this.ideClient.connect(); + logIdeConnection(this, new IdeConnectionEvent(IdeConnectionType.SESSION)); + } else { + this.ideClient.disconnect(); + } } - setIdeClientConnected(): void { - this.ideClient.reconnect(this.ideMode && this.ideModeFeature); + getIdeClient(): IdeClient { + return this.ideClient; } async getGitService(): Promise<GitService> { |
