mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
[ide-mode] Update installation logic and nudge (#6068)
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user