fix: prevent log.writeSummary from overwriting reportProgress content (#87)
* fix: prevent log.writeSummary from overwriting reportProgress content The run summary was showing logs instead of the final reportProgress content because log.writeSummary() was called after reportProgress. Now log.writeSummary() checks if the summary was already overwritten by reportProgress and skips if so. Fixes #86 * refactor: replace dynamic import with static import in cli.ts Replace unnecessary dynamic import of wasSummaryOverwritten with static import. No circular dependency exists since comment.ts doesn't import from cli.ts. * Fix run summary writing --------- Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com> Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
This commit is contained in:
committed by
pullfrog[bot]
parent
6e2a15c195
commit
71feba0a76
+1
-1
@@ -170,7 +170,7 @@ const messageHandlers: SDKMessageHandlers = {
|
||||
const outputTokens = usage?.output_tokens || 0;
|
||||
const totalInput = inputTokens + cacheRead + cacheWrite;
|
||||
|
||||
await log.summaryTable([
|
||||
log.table([
|
||||
[
|
||||
{ data: "Cost", header: true },
|
||||
{ data: "Input", header: true },
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ const messageHandlers: {
|
||||
// No logging needed
|
||||
},
|
||||
"turn.completed": async (event) => {
|
||||
await log.summaryTable([
|
||||
log.table([
|
||||
[
|
||||
{ data: "Input Tokens", header: true },
|
||||
{ data: "Cached Input Tokens", header: true },
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ const messageHandlers = {
|
||||
String(stats.duration_ms || 0),
|
||||
],
|
||||
];
|
||||
await log.summaryTable(rows);
|
||||
log.table(rows);
|
||||
} else if (event.status === "error") {
|
||||
log.error(`Gemini CLI failed: ${JSON.stringify(event)}`);
|
||||
}
|
||||
|
||||
+2
-2
@@ -167,7 +167,7 @@ export const opencode = agent({
|
||||
// 8. log tokens if they weren't logged yet (fallback if result event wasn't emitted)
|
||||
if (!tokensLogged && (accumulatedTokens.input > 0 || accumulatedTokens.output > 0)) {
|
||||
const totalTokens = accumulatedTokens.input + accumulatedTokens.output;
|
||||
await log.summaryTable([
|
||||
log.table([
|
||||
[
|
||||
{ data: "Input Tokens", header: true },
|
||||
{ data: "Output Tokens", header: true },
|
||||
@@ -571,7 +571,7 @@ const messageHandlers = {
|
||||
);
|
||||
|
||||
if ((inputTokens > 0 || outputTokens > 0) && !tokensLogged) {
|
||||
await log.summaryTable([
|
||||
log.table([
|
||||
[
|
||||
{ data: "Input Tokens", header: true },
|
||||
{ data: "Output Tokens", header: true },
|
||||
|
||||
Reference in New Issue
Block a user