Skip to content

Commit 2f74213

Browse files
authored
Wrap token usage step summary in a details section (#24375)
1 parent cfa22cb commit 2f74213

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

actions/setup/js/parse_mcp_gateway_log.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ function generateTokenUsageSummary(summary) {
124124
if (!summary || summary.totalRequests === 0) return "";
125125

126126
const lines = [];
127-
lines.push("### 📊 Token Usage\n");
128127
lines.push("| Model | Input | Output | Cache Read | Cache Write | ET | Requests | Duration |");
129128
lines.push("|-------|------:|-------:|-----------:|------------:|---:|---------:|---------:|");
130129

@@ -162,6 +161,8 @@ function generateTokenUsageSummary(summary) {
162161
lines.push(`<sub>ET weights: input=${w.input} · cached_input=${w.cached_input} · output=${w.output} · reasoning=${w.reasoning} · cache_write=${w.cache_write}</sub>`);
163162
}
164163

164+
lines.push("");
165+
165166
return lines.join("\n") + "\n";
166167
}
167168

@@ -183,7 +184,7 @@ function writeStepSummaryWithTokenUsage(coreObj) {
183184
const parsedSummary = parseTokenUsageJsonl(content);
184185
const markdown = generateTokenUsageSummary(parsedSummary);
185186
if (markdown.length > 0) {
186-
coreObj.summary.addRaw(markdown);
187+
coreObj.summary.addDetails("Token Usage", "\n\n" + markdown);
187188
}
188189
// Export total effective tokens as a GitHub Actions env var for use in
189190
// generated footers (GH_AW_EFFECTIVE_TOKENS is read by messages_footer.cjs)

actions/setup/js/parse_mcp_gateway_log.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ Some content here.`;
288288
setFailed: vi.fn(),
289289
summary: {
290290
addRaw: vi.fn().mockReturnThis(),
291+
addDetails: vi.fn().mockReturnThis(),
291292
write: vi.fn(),
292293
},
293294
};
@@ -1004,7 +1005,6 @@ not-json
10041005
test("renders header and table columns", () => {
10051006
const summary = parseTokenUsageJsonl(JSON.stringify({ model: "claude-sonnet-4-6", provider: "anthropic", input_tokens: 100, output_tokens: 200, cache_read_tokens: 5000, cache_write_tokens: 3000, duration_ms: 2500 }));
10061007
const md = generateTokenUsageSummary(summary);
1007-
expect(md).toContain("### 📊 Token Usage");
10081008
expect(md).toContain("| Model | Input | Output | Cache Read | Cache Write | ET | Requests | Duration |");
10091009
expect(md).toContain("claude-sonnet-4-6");
10101010
});

0 commit comments

Comments
 (0)