Align JavaScript MCP scripts log renderer with Copilot output style#26692
Align JavaScript MCP scripts log renderer with Copilot output style#26692
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d387cfe-919b-455a-914b-fcd9a6aea46d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d387cfe-919b-455a-914b-fcd9a6aea46d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d387cfe-919b-455a-914b-fcd9a6aea46d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d387cfe-919b-455a-914b-fcd9a6aea46d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d387cfe-919b-455a-914b-fcd9a6aea46d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d387cfe-919b-455a-914b-fcd9a6aea46d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d387cfe-919b-455a-914b-fcd9a6aea46d Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the JavaScript MCP scripts log renderer to output Copilot-style tool activity lines (with args and an indented result preview), while retaining a fallback mode for non-tool logs and updating tests to match the new formatting.
Changes:
- Refactors
generatePlainTextSummaryto detect tool invocations/results and render them as Copilot-style lines. - Adds a fallback renderer for runs with no recognized tool calls (capped output).
- Updates
parse_mcp_scripts_logs.test.cjsexpectations to match the new output format and truncation behavior.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/parse_mcp_scripts_logs.cjs | Implements Copilot-style rendering for MCP tool calls/results and a capped fallback renderer. |
| actions/setup/js/parse_mcp_scripts_logs.test.cjs | Updates unit tests to assert the new renderer output format and fallback truncation. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (3)
actions/setup/js/parse_mcp_scripts_logs.cjs:261
- The fallback path truncates and whitespace-normalizes every raw log line to 150 chars (
replace(/\s+/g, " ")). This can remove important troubleshooting detail (e.g., long error messages, structured blobs) even though this mode is intended to preserve non-tool logs. Consider avoiding whitespace normalization in fallback mode and/or increasing the per-line limit (or making it configurable) so diagnostics aren’t unintentionally lost.
if (renderedCalls.length === 0) {
// Fallback to raw logs when no recognizable tool calls exist.
let lineCount = 0;
for (const entry of logEntries) {
if (lineCount >= 200) {
lines.push(`... (truncated, showing first 200 lines of ${logEntries.length} total entries)`);
break;
}
if (entry.raw) {
lines.push(truncate(entry.message, 150));
} else {
const server = entry.serverName ? `[${entry.serverName}] ` : "";
lines.push(truncate(`${server}${entry.message}`.trim(), 150));
}
actions/setup/js/parse_mcp_scripts_logs.cjs:226
- The backend-tool parsing ignores the
serverID=...field present in the log line and usesentry.serverNamefor the(MCP: ...)label. This can mislabel the MCP server being invoked (e.g., logs emitted by a gateway would showMCP: mcp-gatewayinstead ofmcpscripts). Consider extractingserverIDfrom the message and using that for the MCP label (falling back toentry.serverNameonly whenserverIDis absent).
// Parse: "callBackendTool ... toolName=gh, args=map[args:pr view ...]"
const backendToolPrefix = "toolName=";
const backendArgsPrefix = "args=map[args:";
const backendToolIndex = message.indexOf(backendToolPrefix);
const backendArgsIndex = message.indexOf(backendArgsPrefix);
if (backendToolIndex !== -1 && backendArgsIndex !== -1 && backendArgsIndex > backendToolIndex) {
const toolPart = message.slice(backendToolIndex + backendToolPrefix.length, backendArgsIndex);
const tool = toolPart.replace(",", "").trim();
const argsStart = backendArgsIndex + backendArgsPrefix.length;
const argsEnd = message.indexOf("]", argsStart);
const argsRaw = argsEnd === -1 ? message.slice(argsStart) : message.slice(argsStart, argsEnd);
const argsDisplay = ` · args: "${truncate(argsRaw, 90)}"`;
const callIndex = renderedCalls.push({
tool,
serverName: entry.serverName || "mcpscripts",
argsDisplay,
resultPreview: "",
});
addPending(tool, callIndex - 1);
continue;
actions/setup/js/parse_mcp_scripts_logs.cjs:272
- When at least one tool call is recognized, the summary renders only
renderedCalls(plus limitederror|faileddiagnostics) and drops all other non-tool log lines entirely. That means startup/config/warning/info lines are lost in the most common case (tool usage present), which undermines the stated goal of preserving fallback diagnostics. Consider appending a small “Additional logs” section with a capped number of unmatched lines (or always including a capped raw-log tail) so important context isn’t discarded.
for (const call of renderedCalls) {
lines.push(`● ${call.tool} (MCP: ${call.serverName || "mcpscripts"})${call.argsDisplay}`);
if (call.resultPreview) {
lines.push(` └ ${call.resultPreview}`);
}
}
- Files reviewed: 2/2 changed files
- Comments generated: 2
|
|
||
| expect(summary).toContain("Total entries: 2"); | ||
| expect(summary).toContain("Tool registrations: 2"); | ||
| expect(summary).toContain('● gh (MCP: mcp-gateway) · args: "pr view 26450 --repo github/gh-aw --json number"'); |
There was a problem hiding this comment.
This backend-tool test expects MCP: mcp-gateway, but the sample log line includes serverID=mcpscripts (likely the MCP server being invoked). If the renderer intends (MCP: ...) to reflect the target server, this expectation should be updated (and/or the renderer should extract and use serverID).
| expect(summary).toContain('● gh (MCP: mcp-gateway) · args: "pr view 26450 --repo github/gh-aw --json number"'); | |
| expect(summary).toContain('● gh (MCP: mcpscripts) · args: "pr view 26450 --repo github/gh-aw --json number"'); |
| const parsedArgs = parseJSON(invokingPayload.payload); | ||
| let argsDisplay = ""; | ||
| if (parsedArgs && typeof parsedArgs === "object" && parsedArgs !== null) { | ||
| if (typeof parsedArgs.args === "string" && parsedArgs.args.trim()) { | ||
| argsDisplay = ` · args: "${truncate(parsedArgs.args, 90)}"`; | ||
| } else { | ||
| argsDisplay = ` · args: "${truncate(JSON.stringify(parsedArgs), 90)}"`; | ||
| } | ||
| } else { | ||
| argsDisplay = ` · args: "${truncate(invokingPayload.payload, 90)}"`; | ||
| } |
There was a problem hiding this comment.
argsDisplay wraps the argument string in double quotes without escaping. If the underlying command/args contain " (common for shell/CLI invocations), the rendered line becomes ambiguous/broken (e.g. · args: "foo" bar"). Consider producing the quoted value via JSON.stringify(truncatedArgs) (or equivalent escaping) so embedded quotes/backslashes are rendered safely.
This issue also appears in the following locations of the same file:
- line 207
- line 248
- line 267
🧪 Test Quality Sentinel ReportTest Quality Score: 88/100✅ Excellent test quality
Test Classification DetailsView all 28 test classifications
Flagged Tests — Requires ReviewNo tests require review. All 28 tests are classified as design tests. Notable Strengths
Minor Observation (non-blocking)The Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §24522996412
|
Summary
Update the JavaScript MCP scripts log renderer to match Copilot-style tool output formatting.
Changes
● <tool> (MCP: <server>) · args: "..."└parse_mcp_scripts_logs.test.cjsexpectations for the new renderer format and fallback behavior.github/mcp.jsonfrom this branchValidation
npx vitest run parse_mcp_scripts_logs.test.cjs✅make agent-finishpkg/stats/spec_test.go(float-compare suggestions)pkg/testutil/spec_test.go(require-error suggestion)These lint failures were present before this task and are not caused by this change.