mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
Add session subtask in /stats command (#13750)
This commit is contained in:
@@ -13,12 +13,7 @@ import {
|
|||||||
CommandKind,
|
CommandKind,
|
||||||
} from './types.js';
|
} from './types.js';
|
||||||
|
|
||||||
export const statsCommand: SlashCommand = {
|
function defaultSessionView(context: CommandContext) {
|
||||||
name: 'stats',
|
|
||||||
altNames: ['usage'],
|
|
||||||
description: 'Check session stats. Usage: /stats [model|tools]',
|
|
||||||
kind: CommandKind.BUILT_IN,
|
|
||||||
action: (context: CommandContext) => {
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const { sessionStartTime } = context.session.stats;
|
const { sessionStartTime } = context.session.stats;
|
||||||
if (!sessionStartTime) {
|
if (!sessionStartTime) {
|
||||||
@@ -39,8 +34,25 @@ export const statsCommand: SlashCommand = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
context.ui.addItem(statsItem, Date.now());
|
context.ui.addItem(statsItem, Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
export const statsCommand: SlashCommand = {
|
||||||
|
name: 'stats',
|
||||||
|
altNames: ['usage'],
|
||||||
|
description: 'Check session stats. Usage: /stats [session|model|tools]',
|
||||||
|
kind: CommandKind.BUILT_IN,
|
||||||
|
action: (context: CommandContext) => {
|
||||||
|
defaultSessionView(context);
|
||||||
},
|
},
|
||||||
subCommands: [
|
subCommands: [
|
||||||
|
{
|
||||||
|
name: 'session',
|
||||||
|
description: 'Show session-specific usage statistics',
|
||||||
|
kind: CommandKind.BUILT_IN,
|
||||||
|
action: (context: CommandContext) => {
|
||||||
|
defaultSessionView(context);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'model',
|
name: 'model',
|
||||||
description: 'Show model-specific usage statistics',
|
description: 'Show model-specific usage statistics',
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ describe('useSlashCompletion', () => {
|
|||||||
createTestCommand({
|
createTestCommand({
|
||||||
name: 'stats',
|
name: 'stats',
|
||||||
altNames: ['usage'],
|
altNames: ['usage'],
|
||||||
description: 'check session stats. Usage: /stats [model|tools]',
|
description:
|
||||||
|
'check session stats. Usage: /stats [session|model|tools]',
|
||||||
}),
|
}),
|
||||||
createTestCommand({ name: 'clear', description: 'Clear the screen' }),
|
createTestCommand({ name: 'clear', description: 'Clear the screen' }),
|
||||||
createTestCommand({
|
createTestCommand({
|
||||||
@@ -282,7 +283,8 @@ describe('useSlashCompletion', () => {
|
|||||||
createTestCommand({
|
createTestCommand({
|
||||||
name: 'stats',
|
name: 'stats',
|
||||||
altNames: ['usage'],
|
altNames: ['usage'],
|
||||||
description: 'check session stats. Usage: /stats [model|tools]',
|
description:
|
||||||
|
'check session stats. Usage: /stats [session|model|tools]',
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
let result: {
|
let result: {
|
||||||
@@ -307,7 +309,8 @@ describe('useSlashCompletion', () => {
|
|||||||
{
|
{
|
||||||
label: 'stats',
|
label: 'stats',
|
||||||
value: 'stats',
|
value: 'stats',
|
||||||
description: 'check session stats. Usage: /stats [model|tools]',
|
description:
|
||||||
|
'check session stats. Usage: /stats [session|model|tools]',
|
||||||
commandKind: CommandKind.BUILT_IN,
|
commandKind: CommandKind.BUILT_IN,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -360,7 +363,8 @@ describe('useSlashCompletion', () => {
|
|||||||
createTestCommand({
|
createTestCommand({
|
||||||
name: 'stats',
|
name: 'stats',
|
||||||
altNames: ['usage'],
|
altNames: ['usage'],
|
||||||
description: 'check session stats. Usage: /stats [model|tools]',
|
description:
|
||||||
|
'check session stats. Usage: /stats [session|model|tools]',
|
||||||
action: vi.fn(),
|
action: vi.fn(),
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user