Add session id to session summary and /bug template (#6313)
Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
This commit is contained in:
parent
a92299069d
commit
ddbe65e8c3
|
@ -16,6 +16,7 @@ import { formatMemoryUsage } from '../utils/formatters.js';
|
||||||
vi.mock('open');
|
vi.mock('open');
|
||||||
vi.mock('../../utils/version.js');
|
vi.mock('../../utils/version.js');
|
||||||
vi.mock('../utils/formatters.js');
|
vi.mock('../utils/formatters.js');
|
||||||
|
vi.mock('@google/gemini-cli-core');
|
||||||
vi.mock('node:process', () => ({
|
vi.mock('node:process', () => ({
|
||||||
default: {
|
default: {
|
||||||
platform: 'test-platform',
|
platform: 'test-platform',
|
||||||
|
@ -30,6 +31,9 @@ describe('bugCommand', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.mocked(getCliVersion).mockResolvedValue('0.1.0');
|
vi.mocked(getCliVersion).mockResolvedValue('0.1.0');
|
||||||
vi.mocked(formatMemoryUsage).mockReturnValue('100 MB');
|
vi.mocked(formatMemoryUsage).mockReturnValue('100 MB');
|
||||||
|
vi.mock('@google/gemini-cli-core', () => ({
|
||||||
|
sessionId: 'test-session-id',
|
||||||
|
}));
|
||||||
vi.stubEnv('SANDBOX', 'gemini-test');
|
vi.stubEnv('SANDBOX', 'gemini-test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -54,6 +58,7 @@ describe('bugCommand', () => {
|
||||||
const expectedInfo = `
|
const expectedInfo = `
|
||||||
* **CLI Version:** 0.1.0
|
* **CLI Version:** 0.1.0
|
||||||
* **Git Commit:** ${GIT_COMMIT_INFO}
|
* **Git Commit:** ${GIT_COMMIT_INFO}
|
||||||
|
* **Session ID:** test-session-id
|
||||||
* **Operating System:** test-platform v20.0.0
|
* **Operating System:** test-platform v20.0.0
|
||||||
* **Sandbox Environment:** test
|
* **Sandbox Environment:** test
|
||||||
* **Model Version:** gemini-pro
|
* **Model Version:** gemini-pro
|
||||||
|
@ -84,6 +89,7 @@ describe('bugCommand', () => {
|
||||||
const expectedInfo = `
|
const expectedInfo = `
|
||||||
* **CLI Version:** 0.1.0
|
* **CLI Version:** 0.1.0
|
||||||
* **Git Commit:** ${GIT_COMMIT_INFO}
|
* **Git Commit:** ${GIT_COMMIT_INFO}
|
||||||
|
* **Session ID:** test-session-id
|
||||||
* **Operating System:** test-platform v20.0.0
|
* **Operating System:** test-platform v20.0.0
|
||||||
* **Sandbox Environment:** test
|
* **Sandbox Environment:** test
|
||||||
* **Model Version:** gemini-pro
|
* **Model Version:** gemini-pro
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { MessageType } from '../types.js';
|
||||||
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
|
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
|
||||||
import { formatMemoryUsage } from '../utils/formatters.js';
|
import { formatMemoryUsage } from '../utils/formatters.js';
|
||||||
import { getCliVersion } from '../../utils/version.js';
|
import { getCliVersion } from '../../utils/version.js';
|
||||||
|
import { sessionId } from '@google/gemini-cli-core';
|
||||||
|
|
||||||
export const bugCommand: SlashCommand = {
|
export const bugCommand: SlashCommand = {
|
||||||
name: 'bug',
|
name: 'bug',
|
||||||
|
@ -40,6 +41,7 @@ export const bugCommand: SlashCommand = {
|
||||||
const info = `
|
const info = `
|
||||||
* **CLI Version:** ${cliVersion}
|
* **CLI Version:** ${cliVersion}
|
||||||
* **Git Commit:** ${GIT_COMMIT_INFO}
|
* **Git Commit:** ${GIT_COMMIT_INFO}
|
||||||
|
* **Session ID:** ${sessionId}
|
||||||
* **Operating System:** ${osVersion}
|
* **Operating System:** ${osVersion}
|
||||||
* **Sandbox Environment:** ${sandboxEnv}
|
* **Sandbox Environment:** ${sandboxEnv}
|
||||||
* **Model Version:** ${modelVersion}
|
* **Model Version:** ${modelVersion}
|
||||||
|
|
|
@ -24,6 +24,7 @@ const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats);
|
||||||
const renderWithMockedStats = (metrics: SessionMetrics) => {
|
const renderWithMockedStats = (metrics: SessionMetrics) => {
|
||||||
useSessionStatsMock.mockReturnValue({
|
useSessionStatsMock.mockReturnValue({
|
||||||
stats: {
|
stats: {
|
||||||
|
sessionId: 'test-session-id',
|
||||||
sessionStartTime: new Date(),
|
sessionStartTime: new Date(),
|
||||||
metrics,
|
metrics,
|
||||||
lastPromptTokenCount: 0,
|
lastPromptTokenCount: 0,
|
||||||
|
@ -55,7 +56,7 @@ describe('<StatsDisplay />', () => {
|
||||||
const output = lastFrame();
|
const output = lastFrame();
|
||||||
|
|
||||||
expect(output).toContain('Performance');
|
expect(output).toContain('Performance');
|
||||||
expect(output).not.toContain('Interaction Summary');
|
expect(output).toContain('Interaction Summary');
|
||||||
expect(output).not.toContain('Efficiency & Optimizations');
|
expect(output).not.toContain('Efficiency & Optimizations');
|
||||||
expect(output).not.toContain('Model'); // The table header
|
expect(output).not.toContain('Model'); // The table header
|
||||||
expect(output).toMatchSnapshot();
|
expect(output).toMatchSnapshot();
|
||||||
|
@ -289,6 +290,7 @@ describe('<StatsDisplay />', () => {
|
||||||
it('renders the custom title when a title prop is provided', () => {
|
it('renders the custom title when a title prop is provided', () => {
|
||||||
useSessionStatsMock.mockReturnValue({
|
useSessionStatsMock.mockReturnValue({
|
||||||
stats: {
|
stats: {
|
||||||
|
sessionId: 'test-session-id',
|
||||||
sessionStartTime: new Date(),
|
sessionStartTime: new Date(),
|
||||||
metrics: zeroMetrics,
|
metrics: zeroMetrics,
|
||||||
lastPromptTokenCount: 0,
|
lastPromptTokenCount: 0,
|
||||||
|
|
|
@ -197,30 +197,31 @@ export const StatsDisplay: React.FC<StatsDisplayProps> = ({
|
||||||
{renderTitle()}
|
{renderTitle()}
|
||||||
<Box height={1} />
|
<Box height={1} />
|
||||||
|
|
||||||
{tools.totalCalls > 0 && (
|
<Section title="Interaction Summary">
|
||||||
<Section title="Interaction Summary">
|
<StatRow title="Session ID:">
|
||||||
<StatRow title="Tool Calls:">
|
<Text>{stats.sessionId}</Text>
|
||||||
<Text>
|
</StatRow>
|
||||||
{tools.totalCalls} ({' '}
|
<StatRow title="Tool Calls:">
|
||||||
<Text color={Colors.AccentGreen}>✔ {tools.totalSuccess}</Text>{' '}
|
<Text>
|
||||||
<Text color={Colors.AccentRed}>✖ {tools.totalFail}</Text> )
|
{tools.totalCalls} ({' '}
|
||||||
|
<Text color={Colors.AccentGreen}>✔ {tools.totalSuccess}</Text>{' '}
|
||||||
|
<Text color={Colors.AccentRed}>✖ {tools.totalFail}</Text> )
|
||||||
|
</Text>
|
||||||
|
</StatRow>
|
||||||
|
<StatRow title="Success Rate:">
|
||||||
|
<Text color={successColor}>{computed.successRate.toFixed(1)}%</Text>
|
||||||
|
</StatRow>
|
||||||
|
{computed.totalDecisions > 0 && (
|
||||||
|
<StatRow title="User Agreement:">
|
||||||
|
<Text color={agreementColor}>
|
||||||
|
{computed.agreementRate.toFixed(1)}%{' '}
|
||||||
|
<Text color={Colors.Gray}>
|
||||||
|
({computed.totalDecisions} reviewed)
|
||||||
|
</Text>
|
||||||
</Text>
|
</Text>
|
||||||
</StatRow>
|
</StatRow>
|
||||||
<StatRow title="Success Rate:">
|
)}
|
||||||
<Text color={successColor}>{computed.successRate.toFixed(1)}%</Text>
|
</Section>
|
||||||
</StatRow>
|
|
||||||
{computed.totalDecisions > 0 && (
|
|
||||||
<StatRow title="User Agreement:">
|
|
||||||
<Text color={agreementColor}>
|
|
||||||
{computed.agreementRate.toFixed(1)}%{' '}
|
|
||||||
<Text color={Colors.Gray}>
|
|
||||||
({computed.totalDecisions} reviewed)
|
|
||||||
</Text>
|
|
||||||
</Text>
|
|
||||||
</StatRow>
|
|
||||||
)}
|
|
||||||
</Section>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Section title="Performance">
|
<Section title="Performance">
|
||||||
<StatRow title="Wall Time:">
|
<StatRow title="Wall Time:">
|
||||||
|
|
|
@ -5,6 +5,11 @@ exports[`<SessionSummaryDisplay /> > renders the summary display with a title 1`
|
||||||
│ │
|
│ │
|
||||||
│ Agent powering down. Goodbye! │
|
│ Agent powering down. Goodbye! │
|
||||||
│ │
|
│ │
|
||||||
|
│ Interaction Summary │
|
||||||
|
│ Session ID: │
|
||||||
|
│ Tool Calls: 0 ( ✔ 0 ✖ 0 ) │
|
||||||
|
│ Success Rate: 0.0% │
|
||||||
|
│ │
|
||||||
│ Performance │
|
│ Performance │
|
||||||
│ Wall Time: 1h 23m 45s │
|
│ Wall Time: 1h 23m 45s │
|
||||||
│ Agent Active: 50.2s │
|
│ Agent Active: 50.2s │
|
||||||
|
|
|
@ -6,6 +6,7 @@ exports[`<StatsDisplay /> > Conditional Color Tests > renders success rate in gr
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
│ Interaction Summary │
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
│ Tool Calls: 10 ( ✔ 10 ✖ 0 ) │
|
│ Tool Calls: 10 ( ✔ 10 ✖ 0 ) │
|
||||||
│ Success Rate: 100.0% │
|
│ Success Rate: 100.0% │
|
||||||
│ │
|
│ │
|
||||||
|
@ -25,6 +26,7 @@ exports[`<StatsDisplay /> > Conditional Color Tests > renders success rate in re
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
│ Interaction Summary │
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
│ Tool Calls: 10 ( ✔ 5 ✖ 5 ) │
|
│ Tool Calls: 10 ( ✔ 5 ✖ 5 ) │
|
||||||
│ Success Rate: 50.0% │
|
│ Success Rate: 50.0% │
|
||||||
│ │
|
│ │
|
||||||
|
@ -44,6 +46,7 @@ exports[`<StatsDisplay /> > Conditional Color Tests > renders success rate in ye
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
│ Interaction Summary │
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
│ Tool Calls: 10 ( ✔ 9 ✖ 1 ) │
|
│ Tool Calls: 10 ( ✔ 9 ✖ 1 ) │
|
||||||
│ Success Rate: 90.0% │
|
│ Success Rate: 90.0% │
|
||||||
│ │
|
│ │
|
||||||
|
@ -62,6 +65,11 @@ exports[`<StatsDisplay /> > Conditional Rendering Tests > hides Efficiency secti
|
||||||
│ │
|
│ │
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
|
│ Tool Calls: 0 ( ✔ 0 ✖ 0 ) │
|
||||||
|
│ Success Rate: 0.0% │
|
||||||
|
│ │
|
||||||
│ Performance │
|
│ Performance │
|
||||||
│ Wall Time: 1s │
|
│ Wall Time: 1s │
|
||||||
│ Agent Active: 100ms │
|
│ Agent Active: 100ms │
|
||||||
|
@ -82,6 +90,7 @@ exports[`<StatsDisplay /> > Conditional Rendering Tests > hides User Agreement w
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
│ Interaction Summary │
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
│ Tool Calls: 2 ( ✔ 1 ✖ 1 ) │
|
│ Tool Calls: 2 ( ✔ 1 ✖ 1 ) │
|
||||||
│ Success Rate: 50.0% │
|
│ Success Rate: 50.0% │
|
||||||
│ │
|
│ │
|
||||||
|
@ -100,6 +109,11 @@ exports[`<StatsDisplay /> > Title Rendering > renders the custom title when a ti
|
||||||
│ │
|
│ │
|
||||||
│ Agent powering down. Goodbye! │
|
│ Agent powering down. Goodbye! │
|
||||||
│ │
|
│ │
|
||||||
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
|
│ Tool Calls: 0 ( ✔ 0 ✖ 0 ) │
|
||||||
|
│ Success Rate: 0.0% │
|
||||||
|
│ │
|
||||||
│ Performance │
|
│ Performance │
|
||||||
│ Wall Time: 1s │
|
│ Wall Time: 1s │
|
||||||
│ Agent Active: 0s │
|
│ Agent Active: 0s │
|
||||||
|
@ -115,6 +129,11 @@ exports[`<StatsDisplay /> > Title Rendering > renders the default title when no
|
||||||
│ │
|
│ │
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
|
│ Tool Calls: 0 ( ✔ 0 ✖ 0 ) │
|
||||||
|
│ Success Rate: 0.0% │
|
||||||
|
│ │
|
||||||
│ Performance │
|
│ Performance │
|
||||||
│ Wall Time: 1s │
|
│ Wall Time: 1s │
|
||||||
│ Agent Active: 0s │
|
│ Agent Active: 0s │
|
||||||
|
@ -130,6 +149,11 @@ exports[`<StatsDisplay /> > renders a table with two models correctly 1`] = `
|
||||||
│ │
|
│ │
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
|
│ Tool Calls: 0 ( ✔ 0 ✖ 0 ) │
|
||||||
|
│ Success Rate: 0.0% │
|
||||||
|
│ │
|
||||||
│ Performance │
|
│ Performance │
|
||||||
│ Wall Time: 1s │
|
│ Wall Time: 1s │
|
||||||
│ Agent Active: 19.5s │
|
│ Agent Active: 19.5s │
|
||||||
|
@ -155,6 +179,7 @@ exports[`<StatsDisplay /> > renders all sections when all data is present 1`] =
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
│ Interaction Summary │
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
│ Tool Calls: 2 ( ✔ 1 ✖ 1 ) │
|
│ Tool Calls: 2 ( ✔ 1 ✖ 1 ) │
|
||||||
│ Success Rate: 50.0% │
|
│ Success Rate: 50.0% │
|
||||||
│ User Agreement: 100.0% (1 reviewed) │
|
│ User Agreement: 100.0% (1 reviewed) │
|
||||||
|
@ -182,6 +207,11 @@ exports[`<StatsDisplay /> > renders only the Performance section in its zero sta
|
||||||
│ │
|
│ │
|
||||||
│ Session Stats │
|
│ Session Stats │
|
||||||
│ │
|
│ │
|
||||||
|
│ Interaction Summary │
|
||||||
|
│ Session ID: test-session-id │
|
||||||
|
│ Tool Calls: 0 ( ✔ 0 ✖ 0 ) │
|
||||||
|
│ Success Rate: 0.0% │
|
||||||
|
│ │
|
||||||
│ Performance │
|
│ Performance │
|
||||||
│ Wall Time: 1s │
|
│ Wall Time: 1s │
|
||||||
│ Agent Active: 0s │
|
│ Agent Active: 0s │
|
||||||
|
|
|
@ -17,6 +17,7 @@ import {
|
||||||
uiTelemetryService,
|
uiTelemetryService,
|
||||||
SessionMetrics,
|
SessionMetrics,
|
||||||
ModelMetrics,
|
ModelMetrics,
|
||||||
|
sessionId,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
|
|
||||||
// --- Interface Definitions ---
|
// --- Interface Definitions ---
|
||||||
|
@ -24,6 +25,7 @@ import {
|
||||||
export type { SessionMetrics, ModelMetrics };
|
export type { SessionMetrics, ModelMetrics };
|
||||||
|
|
||||||
export interface SessionStatsState {
|
export interface SessionStatsState {
|
||||||
|
sessionId: string;
|
||||||
sessionStartTime: Date;
|
sessionStartTime: Date;
|
||||||
metrics: SessionMetrics;
|
metrics: SessionMetrics;
|
||||||
lastPromptTokenCount: number;
|
lastPromptTokenCount: number;
|
||||||
|
@ -64,6 +66,7 @@ export const SessionStatsProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
const [stats, setStats] = useState<SessionStatsState>({
|
const [stats, setStats] = useState<SessionStatsState>({
|
||||||
|
sessionId,
|
||||||
sessionStartTime: new Date(),
|
sessionStartTime: new Date(),
|
||||||
metrics: uiTelemetryService.getMetrics(),
|
metrics: uiTelemetryService.getMetrics(),
|
||||||
lastPromptTokenCount: 0,
|
lastPromptTokenCount: 0,
|
||||||
|
|
|
@ -223,11 +223,11 @@ export enum EventMetadataKey {
|
||||||
// Kitty Sequence Overflow Event Keys
|
// Kitty Sequence Overflow Event Keys
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
// Logs the length of the kitty sequence that overflowed.
|
|
||||||
GEMINI_CLI_KITTY_SEQUENCE_LENGTH = 53,
|
|
||||||
|
|
||||||
// Logs the truncated kitty sequence.
|
// Logs the truncated kitty sequence.
|
||||||
GEMINI_CLI_KITTY_TRUNCATED_SEQUENCE = 52,
|
GEMINI_CLI_KITTY_TRUNCATED_SEQUENCE = 52,
|
||||||
|
|
||||||
|
// Logs the length of the kitty sequence that overflowed.
|
||||||
|
GEMINI_CLI_KITTY_SEQUENCE_LENGTH = 53,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getEventMetadataKey(
|
export function getEventMetadataKey(
|
||||||
|
|
Loading…
Reference in New Issue