mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
Enhance debug profiler to track tree framerate and dispatch errors (#10502)
This commit is contained in:
@@ -4,6 +4,17 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
vi.mock('../ui/commands/profileCommand.js', async () => {
|
||||
const { CommandKind } = await import('../ui/commands/types.js');
|
||||
return {
|
||||
profileCommand: {
|
||||
name: 'profile',
|
||||
description: 'Profile command',
|
||||
kind: CommandKind.BUILT_IN,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('../ui/commands/aboutCommand.js', async () => {
|
||||
const { CommandKind } = await import('../ui/commands/types.js');
|
||||
return {
|
||||
@@ -177,3 +188,34 @@ describe('BuiltinCommandLoader', () => {
|
||||
expect(modelCmd).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('BuiltinCommandLoader profile', () => {
|
||||
let mockConfig: Config;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
mockConfig = {
|
||||
getFolderTrust: vi.fn().mockReturnValue(false),
|
||||
getUseModelRouter: () => false,
|
||||
getCheckpointingEnabled: () => false,
|
||||
} as unknown as Config;
|
||||
});
|
||||
|
||||
it('should not include profile command when isDevelopment is false', async () => {
|
||||
process.env['NODE_ENV'] = 'production';
|
||||
const { BuiltinCommandLoader } = await import('./BuiltinCommandLoader.js');
|
||||
const loader = new BuiltinCommandLoader(mockConfig);
|
||||
const commands = await loader.loadCommands(new AbortController().signal);
|
||||
const profileCmd = commands.find((c) => c.name === 'profile');
|
||||
expect(profileCmd).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should include profile command when isDevelopment is true', async () => {
|
||||
process.env['NODE_ENV'] = 'development';
|
||||
const { BuiltinCommandLoader } = await import('./BuiltinCommandLoader.js');
|
||||
const loader = new BuiltinCommandLoader(mockConfig);
|
||||
const commands = await loader.loadCommands(new AbortController().signal);
|
||||
const profileCmd = commands.find((c) => c.name === 'profile');
|
||||
expect(profileCmd).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { isDevelopment } from '../utils/installationInfo.js';
|
||||
import type { ICommandLoader } from './types.js';
|
||||
import type { SlashCommand } from '../ui/commands/types.js';
|
||||
import type { Config } from '@google/gemini-cli-core';
|
||||
@@ -27,6 +28,7 @@ import { memoryCommand } from '../ui/commands/memoryCommand.js';
|
||||
import { modelCommand } from '../ui/commands/modelCommand.js';
|
||||
import { permissionsCommand } from '../ui/commands/permissionsCommand.js';
|
||||
import { privacyCommand } from '../ui/commands/privacyCommand.js';
|
||||
import { profileCommand } from '../ui/commands/profileCommand.js';
|
||||
import { quitCommand } from '../ui/commands/quitCommand.js';
|
||||
import { restoreCommand } from '../ui/commands/restoreCommand.js';
|
||||
import { statsCommand } from '../ui/commands/statsCommand.js';
|
||||
@@ -73,6 +75,7 @@ export class BuiltinCommandLoader implements ICommandLoader {
|
||||
...(this.config?.getUseModelRouter() ? [modelCommand] : []),
|
||||
...(this.config?.getFolderTrust() ? [permissionsCommand] : []),
|
||||
privacyCommand,
|
||||
...(isDevelopment ? [profileCommand] : []),
|
||||
quitCommand,
|
||||
restoreCommand(this.config),
|
||||
statsCommand,
|
||||
|
||||
Reference in New Issue
Block a user