Log config.useSmartEdit to Clearcut (#7617)

This commit is contained in:
owenofbrien
2025-09-03 04:58:47 -05:00
committed by GitHub
parent 5c2bb990d8
commit 044c3a0e14
8 changed files with 46 additions and 0 deletions

View File

@@ -304,6 +304,7 @@ describe('Gemini Client (client.ts)', () => {
setFallbackMode: vi.fn(),
getChatCompression: vi.fn().mockReturnValue(undefined),
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
getUseSmartEdit: vi.fn().mockReturnValue(false),
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
storage: {
getProjectTempDir: vi.fn().mockReturnValue('/test/temp'),

View File

@@ -168,6 +168,7 @@ describe('CoreToolScheduler', () => {
authType: 'oauth-personal',
}),
getToolRegistry: () => mockToolRegistry,
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
@@ -202,6 +203,7 @@ describe('CoreToolScheduler', () => {
// Create mocked tool registry
const mockConfig = {
getToolRegistry: () => mockToolRegistry,
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
const mockToolRegistry = {
@@ -267,6 +269,7 @@ describe('CoreToolScheduler with payload', () => {
authType: 'oauth-personal',
}),
getToolRegistry: () => mockToolRegistry,
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
@@ -574,6 +577,7 @@ describe('CoreToolScheduler edit cancellation', () => {
authType: 'oauth-personal',
}),
getToolRegistry: () => mockToolRegistry,
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
@@ -666,6 +670,7 @@ describe('CoreToolScheduler YOLO mode', () => {
authType: 'oauth-personal',
}),
getToolRegistry: () => mockToolRegistry,
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
@@ -757,6 +762,7 @@ describe('CoreToolScheduler request queueing', () => {
authType: 'oauth-personal',
}),
getToolRegistry: () => mockToolRegistry,
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
@@ -874,6 +880,7 @@ describe('CoreToolScheduler request queueing', () => {
model: 'test-model',
authType: 'oauth-personal',
}),
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
@@ -955,6 +962,7 @@ describe('CoreToolScheduler request queueing', () => {
authType: 'oauth-personal',
}),
getToolRegistry: () => mockToolRegistry,
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;
@@ -1015,6 +1023,7 @@ describe('CoreToolScheduler request queueing', () => {
setApprovalMode: (mode: ApprovalMode) => {
approvalMode = mode;
},
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;

View File

@@ -41,6 +41,7 @@ describe('executeToolCall', () => {
model: 'test-model',
authType: 'oauth-personal',
}),
getUseSmartEdit: () => false,
getGeminiClient: () => null, // No client needed for these tests
} as unknown as Config;

View File

@@ -27,6 +27,7 @@ import { UserPromptEvent, makeChatCompressionEvent } from '../types.js';
import { GIT_COMMIT_INFO, CLI_VERSION } from '../../generated/git-commit.js';
import { UserAccountManager } from '../../utils/userAccountManager.js';
import { InstallationManager } from '../../utils/installationManager.js';
import { safeJsonStringify } from '../../utils/safeJsonStringify.js';
interface CustomMatchers<R = unknown> {
toHaveMetadataValue: ([key, value]: [EventMetadataKey, string]) => R;
@@ -208,6 +209,7 @@ describe('ClearcutLogger', () => {
const cli_version = CLI_VERSION;
const git_commit_hash = GIT_COMMIT_INFO;
const prompt_id = 'my-prompt-123';
const user_settings = safeJsonStringify([{ smart_edit_enabled: false }]);
// Setup logger with expected values
const { logger, loggerConfig } = setup({
@@ -258,6 +260,10 @@ describe('ClearcutLogger', () => {
gemini_cli_key: EventMetadataKey.GEMINI_CLI_OS,
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([
{
env: {

View File

@@ -871,6 +871,12 @@ export class ClearcutLogger {
gemini_cli_key: EventMetadataKey.GEMINI_CLI_NODE_VERSION,
value: process.versions.node,
},
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_USER_SETTINGS,
value: safeJsonStringify([
{ smart_edit_enabled: this.config?.getUseSmartEdit() ?? false },
]),
},
];
return [...data, ...defaultLogMetadata];
}

View File

@@ -166,6 +166,9 @@ export enum EventMetadataKey {
// Logs the Gemini CLI OS
GEMINI_CLI_OS = 82,
// Logs active user settings
GEMINI_CLI_USER_SETTINGS = 84,
// ==========================================================================
// Loop Detected Event Keys
// ===========================================================================