mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 23:31:13 -07:00
fix(ide companion extension): Don't show the installation confirmation message in Firebase Studio (#8097)
Co-authored-by: Roman Nurik <roman@nurik.net>
This commit is contained in:
@@ -16,7 +16,7 @@ export {
|
|||||||
DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
||||||
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
||||||
} from './src/config/config.js';
|
} from './src/config/config.js';
|
||||||
export { getIdeInfo } from './src/ide/detect-ide.js';
|
export { detectIdeFromEnv, getIdeInfo } from './src/ide/detect-ide.js';
|
||||||
export { logIdeConnection } from './src/telemetry/loggers.js';
|
export { logIdeConnection } from './src/telemetry/loggers.js';
|
||||||
export {
|
export {
|
||||||
IdeConnectionEvent,
|
IdeConnectionEvent,
|
||||||
|
|||||||
@@ -7,6 +7,15 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { activate } from './extension.js';
|
import { activate } from './extension.js';
|
||||||
|
import { DetectedIde, detectIdeFromEnv } from '@google/gemini-cli-core';
|
||||||
|
|
||||||
|
vi.mock('@google/gemini-cli-core', async () => {
|
||||||
|
const actual = await vi.importActual('@google/gemini-cli-core');
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
detectIdeFromEnv: vi.fn(() => DetectedIde.VSCode),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
vi.mock('vscode', () => ({
|
vi.mock('vscode', () => ({
|
||||||
window: {
|
window: {
|
||||||
@@ -187,6 +196,23 @@ describe('activate', () => {
|
|||||||
expect(showInformationMessageMock).not.toHaveBeenCalled();
|
expect(showInformationMessageMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
{
|
||||||
|
ide: DetectedIde.CloudShell,
|
||||||
|
},
|
||||||
|
{ ide: DetectedIde.FirebaseStudio },
|
||||||
|
])('does not show the notification for $ide', async ({ ide }) => {
|
||||||
|
vi.mocked(detectIdeFromEnv).mockReturnValue(ide);
|
||||||
|
vi.mocked(context.globalState.get).mockReturnValue(undefined);
|
||||||
|
const showInformationMessageMock = vi.mocked(
|
||||||
|
vscode.window.showInformationMessage,
|
||||||
|
);
|
||||||
|
|
||||||
|
await activate(context);
|
||||||
|
|
||||||
|
expect(showInformationMessageMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('should not show an update notification if the version is older', async () => {
|
it('should not show an update notification if the version is older', async () => {
|
||||||
vi.spyOn(global, 'fetch').mockResolvedValue({
|
vi.spyOn(global, 'fetch').mockResolvedValue({
|
||||||
ok: true,
|
ok: true,
|
||||||
|
|||||||
@@ -9,11 +9,22 @@ import { IDEServer } from './ide-server.js';
|
|||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import { DiffContentProvider, DiffManager } from './diff-manager.js';
|
import { DiffContentProvider, DiffManager } from './diff-manager.js';
|
||||||
import { createLogger } from './utils/logger.js';
|
import { createLogger } from './utils/logger.js';
|
||||||
|
import { detectIdeFromEnv, DetectedIde } from '@google/gemini-cli-core';
|
||||||
|
|
||||||
const CLI_IDE_COMPANION_IDENTIFIER = 'Google.gemini-cli-vscode-ide-companion';
|
const CLI_IDE_COMPANION_IDENTIFIER = 'Google.gemini-cli-vscode-ide-companion';
|
||||||
const INFO_MESSAGE_SHOWN_KEY = 'geminiCliInfoMessageShown';
|
const INFO_MESSAGE_SHOWN_KEY = 'geminiCliInfoMessageShown';
|
||||||
export const DIFF_SCHEME = 'gemini-diff';
|
export const DIFF_SCHEME = 'gemini-diff';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IDE environments where the installation greeting is hidden. In these
|
||||||
|
* environments we either are pre-installed and the installation message is
|
||||||
|
* confusing or we just want to be quiet.
|
||||||
|
*/
|
||||||
|
const HIDE_INSTALLATION_GREETING_IDES: ReadonlySet<DetectedIde> = new Set([
|
||||||
|
DetectedIde.FirebaseStudio,
|
||||||
|
DetectedIde.CloudShell,
|
||||||
|
]);
|
||||||
|
|
||||||
let ideServer: IDEServer;
|
let ideServer: IDEServer;
|
||||||
let logger: vscode.OutputChannel;
|
let logger: vscode.OutputChannel;
|
||||||
|
|
||||||
@@ -133,7 +144,10 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||||||
log(`Failed to start IDE server: ${message}`);
|
log(`Failed to start IDE server: ${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.globalState.get(INFO_MESSAGE_SHOWN_KEY)) {
|
const infoMessageEnabled =
|
||||||
|
!HIDE_INSTALLATION_GREETING_IDES.has(detectIdeFromEnv());
|
||||||
|
|
||||||
|
if (!context.globalState.get(INFO_MESSAGE_SHOWN_KEY) && infoMessageEnabled) {
|
||||||
void vscode.window.showInformationMessage(
|
void vscode.window.showInformationMessage(
|
||||||
'Gemini CLI Companion extension successfully installed.',
|
'Gemini CLI Companion extension successfully installed.',
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user