mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Send accepted/removed lines with ACCEPT_FILE telemetry. (#19670)
This commit is contained in:
committed by
GitHub
parent
ce03156c9f
commit
788a40c445
@@ -316,6 +316,14 @@ describe('telemetry', () => {
|
|||||||
prompt_id: 'p1',
|
prompt_id: 'p1',
|
||||||
traceId: 'trace-1',
|
traceId: 'trace-1',
|
||||||
},
|
},
|
||||||
|
response: {
|
||||||
|
resultDisplay: {
|
||||||
|
diffStat: {
|
||||||
|
model_added_lines: 5,
|
||||||
|
model_removed_lines: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
outcome: ToolConfirmationOutcome.ProceedOnce,
|
outcome: ToolConfirmationOutcome.ProceedOnce,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
} as unknown as CompletedToolCall,
|
} as unknown as CompletedToolCall,
|
||||||
@@ -327,6 +335,8 @@ describe('telemetry', () => {
|
|||||||
traceId: 'trace-1',
|
traceId: 'trace-1',
|
||||||
status: ActionStatus.ACTION_STATUS_NO_ERROR,
|
status: ActionStatus.ACTION_STATUS_NO_ERROR,
|
||||||
interaction: ConversationInteractionInteraction.ACCEPT_FILE,
|
interaction: ConversationInteractionInteraction.ACCEPT_FILE,
|
||||||
|
acceptedLines: '5',
|
||||||
|
removedLines: '3',
|
||||||
isAgentic: true,
|
isAgentic: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ import { EDIT_TOOL_NAMES } from '../tools/tool-names.js';
|
|||||||
import { getErrorMessage } from '../utils/errors.js';
|
import { getErrorMessage } from '../utils/errors.js';
|
||||||
import type { CodeAssistServer } from './server.js';
|
import type { CodeAssistServer } from './server.js';
|
||||||
import { ToolConfirmationOutcome } from '../tools/tools.js';
|
import { ToolConfirmationOutcome } from '../tools/tools.js';
|
||||||
|
import {
|
||||||
|
computeModelAddedAndRemovedLines,
|
||||||
|
getFileDiffFromResultDisplay,
|
||||||
|
} from '../utils/fileDiffUtils.js';
|
||||||
|
|
||||||
export async function recordConversationOffered(
|
export async function recordConversationOffered(
|
||||||
server: CodeAssistServer,
|
server: CodeAssistServer,
|
||||||
@@ -110,6 +114,8 @@ function summarizeToolCalls(
|
|||||||
|
|
||||||
// Treat file edits as ACCEPT_FILE and everything else as unknown.
|
// Treat file edits as ACCEPT_FILE and everything else as unknown.
|
||||||
let isEdit = false;
|
let isEdit = false;
|
||||||
|
let acceptedLines = 0;
|
||||||
|
let removedLines = 0;
|
||||||
|
|
||||||
// Iterate the tool calls and summarize them into a single conversation
|
// Iterate the tool calls and summarize them into a single conversation
|
||||||
// interaction so that the ConversationOffered and ConversationInteraction
|
// interaction so that the ConversationOffered and ConversationInteraction
|
||||||
@@ -136,7 +142,18 @@ function summarizeToolCalls(
|
|||||||
|
|
||||||
// Edits are ACCEPT_FILE, everything else is UNKNOWN.
|
// Edits are ACCEPT_FILE, everything else is UNKNOWN.
|
||||||
if (EDIT_TOOL_NAMES.has(toolCall.request.name)) {
|
if (EDIT_TOOL_NAMES.has(toolCall.request.name)) {
|
||||||
isEdit ||= true;
|
isEdit = true;
|
||||||
|
|
||||||
|
if (toolCall.status === 'success') {
|
||||||
|
const fileDiff = getFileDiffFromResultDisplay(
|
||||||
|
toolCall.response.resultDisplay,
|
||||||
|
);
|
||||||
|
if (fileDiff?.diffStat) {
|
||||||
|
const lines = computeModelAddedAndRemovedLines(fileDiff.diffStat);
|
||||||
|
acceptedLines += lines.addedLines;
|
||||||
|
removedLines += lines.removedLines;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,6 +166,8 @@ function summarizeToolCalls(
|
|||||||
isEdit
|
isEdit
|
||||||
? ConversationInteractionInteraction.ACCEPT_FILE
|
? ConversationInteractionInteraction.ACCEPT_FILE
|
||||||
: ConversationInteractionInteraction.UNKNOWN,
|
: ConversationInteractionInteraction.UNKNOWN,
|
||||||
|
isEdit ? String(acceptedLines) : undefined,
|
||||||
|
isEdit ? String(removedLines) : undefined,
|
||||||
)
|
)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
@@ -157,15 +176,18 @@ function createConversationInteraction(
|
|||||||
traceId: string,
|
traceId: string,
|
||||||
status: ActionStatus,
|
status: ActionStatus,
|
||||||
interaction: ConversationInteractionInteraction,
|
interaction: ConversationInteractionInteraction,
|
||||||
|
acceptedLines?: string,
|
||||||
|
removedLines?: string,
|
||||||
): ConversationInteraction {
|
): ConversationInteraction {
|
||||||
return {
|
return {
|
||||||
traceId,
|
traceId,
|
||||||
status,
|
status,
|
||||||
interaction,
|
interaction,
|
||||||
|
acceptedLines,
|
||||||
|
removedLines,
|
||||||
isAgentic: true,
|
isAgentic: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function includesCode(resp: GenerateContentResponse): boolean {
|
function includesCode(resp: GenerateContentResponse): boolean {
|
||||||
if (!resp.candidates) {
|
if (!resp.candidates) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ export interface ConversationInteraction {
|
|||||||
status?: ActionStatus;
|
status?: ActionStatus;
|
||||||
interaction?: ConversationInteractionInteraction;
|
interaction?: ConversationInteractionInteraction;
|
||||||
acceptedLines?: string;
|
acceptedLines?: string;
|
||||||
|
removedLines?: string;
|
||||||
language?: string;
|
language?: string;
|
||||||
isAgentic?: boolean;
|
isAgentic?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { FileDiff } from '../tools/tools.js';
|
import type { DiffStat, FileDiff } from '../tools/tools.js';
|
||||||
import type { ToolCallRecord } from '../services/chatRecordingService.js';
|
import type { ToolCallRecord } from '../services/chatRecordingService.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,17 +23,14 @@ export function getFileDiffFromResultDisplay(
|
|||||||
typeof resultDisplay.diffStat === 'object' &&
|
typeof resultDisplay.diffStat === 'object' &&
|
||||||
resultDisplay.diffStat !== null
|
resultDisplay.diffStat !== null
|
||||||
) {
|
) {
|
||||||
const diffStat = resultDisplay.diffStat as FileDiff['diffStat'];
|
if (resultDisplay.diffStat) {
|
||||||
if (diffStat) {
|
|
||||||
return resultDisplay;
|
return resultDisplay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function computeModelAddedAndRemovedLines(
|
export function computeModelAddedAndRemovedLines(stats: DiffStat | undefined): {
|
||||||
stats: FileDiff['diffStat'] | undefined,
|
|
||||||
): {
|
|
||||||
addedLines: number;
|
addedLines: number;
|
||||||
removedLines: number;
|
removedLines: number;
|
||||||
} {
|
} {
|
||||||
|
|||||||
Reference in New Issue
Block a user