summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/ui/App.tsx14
-rw-r--r--packages/cli/src/ui/IdeIntegrationNudge.tsx50
-rw-r--r--packages/cli/src/ui/commands/ideCommand.ts4
3 files changed, 50 insertions, 18 deletions
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) => {
</Box>
)}
- {shouldShowIdePrompt ? (
+ {shouldShowIdePrompt && currentIDE ? (
<IdeIntegrationNudge
- ideName={config.getIdeClient().getDetectedIdeDisplayName()}
+ ide={currentIDE}
onComplete={handleIdePromptComplete}
/>
) : 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<RadioSelectItem<IdeIntegrationNudgeResult>> = [
{
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 (
<Box
flexDirection="column"
@@ -54,11 +84,9 @@ export function IdeIntegrationNudge({
<Box marginBottom={1} flexDirection="column">
<Text>
<Text color="yellow">{'> '}</Text>
- {`Do you want to connect your ${ideName ?? 'your'} editor to Gemini CLI?`}
+ {`Do you want to connect ${ideName ?? 'your'} editor to Gemini CLI?`}
</Text>
- <Text
- dimColor
- >{`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'}.`}</Text>
+ <Text dimColor>{installText}</Text>
</Box>
<RadioButtonSelect
items={OPTIONS}
diff --git a/packages/cli/src/ui/commands/ideCommand.ts b/packages/cli/src/ui/commands/ideCommand.ts
index f53047ef..23af2e48 100644
--- a/packages/cli/src/ui/commands/ideCommand.ts
+++ b/packages/cli/src/ui/commands/ideCommand.ts
@@ -8,7 +8,7 @@ import {
Config,
DetectedIde,
IDEConnectionStatus,
- getIdeDisplayName,
+ getIdeInfo,
getIdeInstaller,
IdeClient,
type File,
@@ -132,7 +132,7 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
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,
};