feat(ide): improve IDE installation UX and feedback (#6677)
This commit is contained in:
parent
80ff3cd25e
commit
0e9b06d5c2
|
@ -227,7 +227,7 @@ describe('ideCommand', () => {
|
||||||
}),
|
}),
|
||||||
expect.any(Number),
|
expect.any(Number),
|
||||||
);
|
);
|
||||||
});
|
}, 10000);
|
||||||
|
|
||||||
it('should show an error if installation fails', async () => {
|
it('should show an error if installation fails', async () => {
|
||||||
mockInstall.mockResolvedValue({
|
mockInstall.mockResolvedValue({
|
||||||
|
|
|
@ -187,10 +187,6 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await installer.install();
|
const result = await installer.install();
|
||||||
if (result.success) {
|
|
||||||
config.setIdeMode(true);
|
|
||||||
context.services.settings.setValue(SettingScope.User, 'ideMode', true);
|
|
||||||
}
|
|
||||||
context.ui.addItem(
|
context.ui.addItem(
|
||||||
{
|
{
|
||||||
type: result.success ? 'info' : 'error',
|
type: result.success ? 'info' : 'error',
|
||||||
|
@ -198,6 +194,39 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
|
||||||
},
|
},
|
||||||
Date.now(),
|
Date.now(),
|
||||||
);
|
);
|
||||||
|
if (result.success) {
|
||||||
|
context.services.settings.setValue(SettingScope.User, 'ideMode', true);
|
||||||
|
// Poll for up to 5 seconds for the extension to activate.
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
await config.setIdeModeAndSyncConnection(true);
|
||||||
|
if (
|
||||||
|
ideClient.getConnectionStatus().status ===
|
||||||
|
IDEConnectionStatus.Connected
|
||||||
|
) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
|
}
|
||||||
|
|
||||||
|
const { messageType, content } = getIdeStatusMessage(ideClient);
|
||||||
|
if (messageType === 'error') {
|
||||||
|
context.ui.addItem(
|
||||||
|
{
|
||||||
|
type: messageType,
|
||||||
|
text: `Failed to automatically enable IDE integration. To fix this, run the CLI in a new terminal window.`,
|
||||||
|
},
|
||||||
|
Date.now(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
context.ui.addItem(
|
||||||
|
{
|
||||||
|
type: messageType,
|
||||||
|
text: content,
|
||||||
|
},
|
||||||
|
Date.now(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -104,8 +104,13 @@ export class IdeClient {
|
||||||
|
|
||||||
this.setState(IDEConnectionStatus.Connecting);
|
this.setState(IDEConnectionStatus.Connecting);
|
||||||
|
|
||||||
|
const ideInfoFromFile = await this.getIdeInfoFromFile();
|
||||||
|
const workspacePath =
|
||||||
|
ideInfoFromFile.workspacePath ??
|
||||||
|
process.env['GEMINI_CLI_IDE_WORKSPACE_PATH'];
|
||||||
|
|
||||||
const { isValid, error } = IdeClient.validateWorkspacePath(
|
const { isValid, error } = IdeClient.validateWorkspacePath(
|
||||||
process.env['GEMINI_CLI_IDE_WORKSPACE_PATH'],
|
workspacePath,
|
||||||
this.currentIdeDisplayName,
|
this.currentIdeDisplayName,
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
);
|
);
|
||||||
|
@ -115,7 +120,7 @@ export class IdeClient {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const portFromFile = await this.getPortFromFile();
|
const portFromFile = ideInfoFromFile.port;
|
||||||
if (portFromFile) {
|
if (portFromFile) {
|
||||||
const connected = await this.establishConnection(portFromFile);
|
const connected = await this.establishConnection(portFromFile);
|
||||||
if (connected) {
|
if (connected) {
|
||||||
|
@ -311,7 +316,10 @@ export class IdeClient {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getPortFromFile(): Promise<string | undefined> {
|
private async getIdeInfoFromFile(): Promise<{
|
||||||
|
port?: string;
|
||||||
|
workspacePath?: string;
|
||||||
|
}> {
|
||||||
try {
|
try {
|
||||||
const ideProcessId = await getIdeProcessId();
|
const ideProcessId = await getIdeProcessId();
|
||||||
const portFile = path.join(
|
const portFile = path.join(
|
||||||
|
@ -319,10 +327,13 @@ export class IdeClient {
|
||||||
`gemini-ide-server-${ideProcessId}.json`,
|
`gemini-ide-server-${ideProcessId}.json`,
|
||||||
);
|
);
|
||||||
const portFileContents = await fs.promises.readFile(portFile, 'utf8');
|
const portFileContents = await fs.promises.readFile(portFile, 'utf8');
|
||||||
const port = JSON.parse(portFileContents).port;
|
const ideInfo = JSON.parse(portFileContents);
|
||||||
return port.toString();
|
return {
|
||||||
|
port: ideInfo?.port?.toString(),
|
||||||
|
workspacePath: ideInfo?.workspacePath,
|
||||||
|
};
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return undefined;
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue