From 74fd0841d0d7148127e586fce4c550a01ff40e90 Mon Sep 17 00:00:00 2001 From: christine betts Date: Tue, 12 Aug 2025 20:08:47 +0000 Subject: [ide-mode] Update installation logic and nudge (#6068) --- packages/cli/src/ui/App.tsx | 14 +++++--- packages/cli/src/ui/IdeIntegrationNudge.tsx | 50 ++++++++++++++++++++++------- packages/cli/src/ui/commands/ideCommand.ts | 4 +-- 3 files changed, 50 insertions(+), 18 deletions(-) (limited to 'packages/cli/src/ui') diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index e952d6b2..ab30b730 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -576,14 +576,18 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => { const handleIdePromptComplete = useCallback( (result: IdeIntegrationNudgeResult) => { - if (result === 'yes') { - handleSlashCommand('/ide install'); + if (result.userSelection === 'yes') { + if (result.isExtensionPreInstalled) { + handleSlashCommand('/ide enable'); + } else { + handleSlashCommand('/ide install'); + } settings.setValue( SettingScope.User, 'hasSeenIdeIntegrationNudge', true, ); - } else if (result === 'dismiss') { + } else if (result.userSelection === 'dismiss') { settings.setValue( SettingScope.User, 'hasSeenIdeIntegrationNudge', @@ -942,9 +946,9 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => { )} - {shouldShowIdePrompt ? ( + {shouldShowIdePrompt && currentIDE ? ( ) : isFolderTrustDialogOpen ? ( diff --git a/packages/cli/src/ui/IdeIntegrationNudge.tsx b/packages/cli/src/ui/IdeIntegrationNudge.tsx index f0c6172d..13f70a75 100644 --- a/packages/cli/src/ui/IdeIntegrationNudge.tsx +++ b/packages/cli/src/ui/IdeIntegrationNudge.tsx @@ -4,44 +4,74 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { DetectedIde, getIdeInfo } from '@google/gemini-cli-core'; import { Box, Text, useInput } from 'ink'; import { RadioButtonSelect, RadioSelectItem, } from './components/shared/RadioButtonSelect.js'; -export type IdeIntegrationNudgeResult = 'yes' | 'no' | 'dismiss'; +export type IdeIntegrationNudgeResult = { + userSelection: 'yes' | 'no' | 'dismiss'; + isExtensionPreInstalled: boolean; +}; interface IdeIntegrationNudgeProps { - ideName?: string; + ide: DetectedIde; onComplete: (result: IdeIntegrationNudgeResult) => void; } export function IdeIntegrationNudge({ - ideName, + ide, onComplete, }: IdeIntegrationNudgeProps) { useInput((_input, key) => { if (key.escape) { - onComplete('no'); + onComplete({ + userSelection: 'no', + isExtensionPreInstalled: false, + }); } }); + const { displayName: ideName } = getIdeInfo(ide); + // Assume extension is already installed if the env variables are set. + const isExtensionPreInstalled = + !!process.env.GEMINI_CLI_IDE_SERVER_PORT && + !!process.env.GEMINI_CLI_IDE_WORKSPACE_PATH; + const OPTIONS: Array> = [ { label: 'Yes', - value: 'yes', + value: { + userSelection: 'yes', + isExtensionPreInstalled, + }, }, { label: 'No (esc)', - value: 'no', + value: { + userSelection: 'no', + isExtensionPreInstalled, + }, }, { label: "No, don't ask again", - value: 'dismiss', + value: { + userSelection: 'dismiss', + isExtensionPreInstalled, + }, }, ]; + const installText = isExtensionPreInstalled + ? `If you select Yes, the CLI will have access to your open files and display diffs directly in ${ + ideName ?? 'your editor' + }.` + : `If you select Yes, we'll install an extension that allows the CLI to access your open files and display diffs directly in ${ + ideName ?? 'your editor' + }.`; + return ( {'> '} - {`Do you want to connect your ${ideName ?? 'your'} editor to Gemini CLI?`} + {`Do you want to connect ${ideName ?? 'your'} editor to Gemini CLI?`} - {`If you select Yes, we'll install an extension that allows the CLI to access your open files and display diffs directly in ${ideName ?? 'your editor'}.`} + {installText} { content: `IDE integration is not supported in your current environment. To use this feature, run Gemini CLI in one of these supported IDEs: ${Object.values( DetectedIde, ) - .map((ide) => getIdeDisplayName(ide)) + .map((ide) => getIdeInfo(ide).displayName) .join(', ')}`, }) as const, }; -- cgit v1.2.3