mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-01 07:24:38 -07:00
Log config.useSmartEdit to Clearcut (#7617)
This commit is contained in:
@@ -207,6 +207,7 @@ describe('useGeminiStream', () => {
|
|||||||
getContentGeneratorConfig: vi
|
getContentGeneratorConfig: vi
|
||||||
.fn()
|
.fn()
|
||||||
.mockReturnValue(contentGeneratorConfig),
|
.mockReturnValue(contentGeneratorConfig),
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
mockOnDebugMessage = vi.fn();
|
mockOnDebugMessage = vi.fn();
|
||||||
mockHandleSlashCommand = vi.fn().mockResolvedValue(false);
|
mockHandleSlashCommand = vi.fn().mockResolvedValue(false);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ const mockConfig = {
|
|||||||
model: 'test-model',
|
model: 'test-model',
|
||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ describe('Gemini Client (client.ts)', () => {
|
|||||||
setFallbackMode: vi.fn(),
|
setFallbackMode: vi.fn(),
|
||||||
getChatCompression: vi.fn().mockReturnValue(undefined),
|
getChatCompression: vi.fn().mockReturnValue(undefined),
|
||||||
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
||||||
|
getUseSmartEdit: vi.fn().mockReturnValue(false),
|
||||||
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
||||||
storage: {
|
storage: {
|
||||||
getProjectTempDir: vi.fn().mockReturnValue('/test/temp'),
|
getProjectTempDir: vi.fn().mockReturnValue('/test/temp'),
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ describe('CoreToolScheduler', () => {
|
|||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
getToolRegistry: () => mockToolRegistry,
|
getToolRegistry: () => mockToolRegistry,
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -202,6 +203,7 @@ describe('CoreToolScheduler', () => {
|
|||||||
// Create mocked tool registry
|
// Create mocked tool registry
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
getToolRegistry: () => mockToolRegistry,
|
getToolRegistry: () => mockToolRegistry,
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
const mockToolRegistry = {
|
const mockToolRegistry = {
|
||||||
@@ -267,6 +269,7 @@ describe('CoreToolScheduler with payload', () => {
|
|||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
getToolRegistry: () => mockToolRegistry,
|
getToolRegistry: () => mockToolRegistry,
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -574,6 +577,7 @@ describe('CoreToolScheduler edit cancellation', () => {
|
|||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
getToolRegistry: () => mockToolRegistry,
|
getToolRegistry: () => mockToolRegistry,
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -666,6 +670,7 @@ describe('CoreToolScheduler YOLO mode', () => {
|
|||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
getToolRegistry: () => mockToolRegistry,
|
getToolRegistry: () => mockToolRegistry,
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -757,6 +762,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
getToolRegistry: () => mockToolRegistry,
|
getToolRegistry: () => mockToolRegistry,
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -874,6 +880,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|||||||
model: 'test-model',
|
model: 'test-model',
|
||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -955,6 +962,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
getToolRegistry: () => mockToolRegistry,
|
getToolRegistry: () => mockToolRegistry,
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -1015,6 +1023,7 @@ describe('CoreToolScheduler request queueing', () => {
|
|||||||
setApprovalMode: (mode: ApprovalMode) => {
|
setApprovalMode: (mode: ApprovalMode) => {
|
||||||
approvalMode = mode;
|
approvalMode = mode;
|
||||||
},
|
},
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ describe('executeToolCall', () => {
|
|||||||
model: 'test-model',
|
model: 'test-model',
|
||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
|
getUseSmartEdit: () => false,
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { UserPromptEvent, makeChatCompressionEvent } from '../types.js';
|
|||||||
import { GIT_COMMIT_INFO, CLI_VERSION } from '../../generated/git-commit.js';
|
import { GIT_COMMIT_INFO, CLI_VERSION } from '../../generated/git-commit.js';
|
||||||
import { UserAccountManager } from '../../utils/userAccountManager.js';
|
import { UserAccountManager } from '../../utils/userAccountManager.js';
|
||||||
import { InstallationManager } from '../../utils/installationManager.js';
|
import { InstallationManager } from '../../utils/installationManager.js';
|
||||||
|
import { safeJsonStringify } from '../../utils/safeJsonStringify.js';
|
||||||
|
|
||||||
interface CustomMatchers<R = unknown> {
|
interface CustomMatchers<R = unknown> {
|
||||||
toHaveMetadataValue: ([key, value]: [EventMetadataKey, string]) => R;
|
toHaveMetadataValue: ([key, value]: [EventMetadataKey, string]) => R;
|
||||||
@@ -208,6 +209,7 @@ describe('ClearcutLogger', () => {
|
|||||||
const cli_version = CLI_VERSION;
|
const cli_version = CLI_VERSION;
|
||||||
const git_commit_hash = GIT_COMMIT_INFO;
|
const git_commit_hash = GIT_COMMIT_INFO;
|
||||||
const prompt_id = 'my-prompt-123';
|
const prompt_id = 'my-prompt-123';
|
||||||
|
const user_settings = safeJsonStringify([{ smart_edit_enabled: false }]);
|
||||||
|
|
||||||
// Setup logger with expected values
|
// Setup logger with expected values
|
||||||
const { logger, loggerConfig } = setup({
|
const { logger, loggerConfig } = setup({
|
||||||
@@ -258,6 +260,10 @@ describe('ClearcutLogger', () => {
|
|||||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_OS,
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_OS,
|
||||||
value: process.platform,
|
value: process.platform,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_USER_SETTINGS,
|
||||||
|
value: user_settings,
|
||||||
|
},
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -287,6 +293,24 @@ describe('ClearcutLogger', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('logs the value of config.useSmartEdit', () => {
|
||||||
|
const user_settings = safeJsonStringify([{ smart_edit_enabled: true }]);
|
||||||
|
|
||||||
|
const { logger } = setup({
|
||||||
|
config: { useSmartEdit: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.stubEnv('TERM_PROGRAM', 'vscode');
|
||||||
|
vi.stubEnv('SURFACE', 'ide-1234');
|
||||||
|
|
||||||
|
const event = logger?.createLogEvent(EventNames.TOOL_CALL, []);
|
||||||
|
|
||||||
|
expect(event?.event_metadata[0]).toContainEqual({
|
||||||
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_USER_SETTINGS,
|
||||||
|
value: user_settings,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
{
|
{
|
||||||
env: {
|
env: {
|
||||||
|
|||||||
@@ -871,6 +871,12 @@ export class ClearcutLogger {
|
|||||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_NODE_VERSION,
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_NODE_VERSION,
|
||||||
value: process.versions.node,
|
value: process.versions.node,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_USER_SETTINGS,
|
||||||
|
value: safeJsonStringify([
|
||||||
|
{ smart_edit_enabled: this.config?.getUseSmartEdit() ?? false },
|
||||||
|
]),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
return [...data, ...defaultLogMetadata];
|
return [...data, ...defaultLogMetadata];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,9 @@ export enum EventMetadataKey {
|
|||||||
// Logs the Gemini CLI OS
|
// Logs the Gemini CLI OS
|
||||||
GEMINI_CLI_OS = 82,
|
GEMINI_CLI_OS = 82,
|
||||||
|
|
||||||
|
// Logs active user settings
|
||||||
|
GEMINI_CLI_USER_SETTINGS = 84,
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Loop Detected Event Keys
|
// Loop Detected Event Keys
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user