mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
feat: add file change tracking to session metrics (#6094)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -121,6 +121,10 @@ describe('computeSessionStats', () => {
|
||||
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
||||
byName: {},
|
||||
},
|
||||
files: {
|
||||
totalLinesAdded: 0,
|
||||
totalLinesRemoved: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const result = computeSessionStats(metrics);
|
||||
@@ -137,6 +141,8 @@ describe('computeSessionStats', () => {
|
||||
agreementRate: 0,
|
||||
totalPromptTokens: 0,
|
||||
totalCachedTokens: 0,
|
||||
totalLinesAdded: 0,
|
||||
totalLinesRemoved: 0,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -163,6 +169,10 @@ describe('computeSessionStats', () => {
|
||||
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
||||
byName: {},
|
||||
},
|
||||
files: {
|
||||
totalLinesAdded: 0,
|
||||
totalLinesRemoved: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const result = computeSessionStats(metrics);
|
||||
@@ -197,6 +207,10 @@ describe('computeSessionStats', () => {
|
||||
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
||||
byName: {},
|
||||
},
|
||||
files: {
|
||||
totalLinesAdded: 0,
|
||||
totalLinesRemoved: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const result = computeSessionStats(metrics);
|
||||
@@ -215,6 +229,10 @@ describe('computeSessionStats', () => {
|
||||
totalDecisions: { accept: 6, reject: 2, modify: 2 },
|
||||
byName: {},
|
||||
},
|
||||
files: {
|
||||
totalLinesAdded: 0,
|
||||
totalLinesRemoved: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const result = computeSessionStats(metrics);
|
||||
@@ -234,6 +252,10 @@ describe('computeSessionStats', () => {
|
||||
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
||||
byName: {},
|
||||
},
|
||||
files: {
|
||||
totalLinesAdded: 0,
|
||||
totalLinesRemoved: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const result = computeSessionStats(metrics);
|
||||
@@ -244,4 +266,27 @@ describe('computeSessionStats', () => {
|
||||
expect(result.successRate).toBe(0);
|
||||
expect(result.agreementRate).toBe(0);
|
||||
});
|
||||
|
||||
it('should correctly include line counts', () => {
|
||||
const metrics: SessionMetrics = {
|
||||
models: {},
|
||||
tools: {
|
||||
totalCalls: 0,
|
||||
totalSuccess: 0,
|
||||
totalFail: 0,
|
||||
totalDurationMs: 0,
|
||||
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
||||
byName: {},
|
||||
},
|
||||
files: {
|
||||
totalLinesAdded: 42,
|
||||
totalLinesRemoved: 18,
|
||||
},
|
||||
};
|
||||
|
||||
const result = computeSessionStats(metrics);
|
||||
|
||||
expect(result.totalLinesAdded).toBe(42);
|
||||
expect(result.totalLinesRemoved).toBe(18);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ export function calculateCacheHitRate(metrics: ModelMetrics): number {
|
||||
export const computeSessionStats = (
|
||||
metrics: SessionMetrics,
|
||||
): ComputedSessionStats => {
|
||||
const { models, tools } = metrics;
|
||||
const { models, tools, files } = metrics;
|
||||
const totalApiTime = Object.values(models).reduce(
|
||||
(acc, model) => acc + model.api.totalLatencyMs,
|
||||
0,
|
||||
@@ -80,5 +80,7 @@ export const computeSessionStats = (
|
||||
agreementRate,
|
||||
totalCachedTokens,
|
||||
totalPromptTokens,
|
||||
totalLinesAdded: files.totalLinesAdded,
|
||||
totalLinesRemoved: files.totalLinesRemoved,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user