Skip to content

Wrap agent log rendering in collapsible details section#14208

Merged
pelikhan merged 2 commits intomainfrom
copilot/wrap-agent-log-rendering
Feb 6, 2026
Merged

Wrap agent log rendering in collapsible details section#14208
pelikhan merged 2 commits intomainfrom
copilot/wrap-agent-log-rendering

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

Agent markdown logs now render wrapped in HTML <details> sections with the format 🤖 {Parser} CLI Session, open by default.

Changes

  • Added wrapAgentLogInSection() in log_parser_shared.cjs

    • Wraps markdown in <details open> with customizable parser name
    • Returns empty string for undefined/empty content
  • Updated log_parser_bootstrap.cjs

    • Wraps both Copilot CLI style summary and fallback markdown paths
    • Maintains consistent rendering across all parser types (Copilot, Claude, Codex, Custom)
  • Test updates

    • Added 6 test cases covering wrapper function behavior
    • Updated 2 bootstrap tests to expect wrapped output

Example

Before:

Conversation:
Agent: Hello
✓ $ ls -la
Statistics: ...

After:

<details open>
<summary>🤖 Copilot CLI Session</summary>

Conversation:
Agent: Hello
✓ $ ls -la
Statistics: ...
</details>

Applies to GitHub Actions step summaries and safe-output issue bodies.

Original prompt

Wrap the rendering of the agent markdown log in a default section (open by default). See "🤖 Copilot CLI Session" in the javascript files.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Add wrapAgentLogInSection function to log_parser_shared.cjs
- Update log_parser_bootstrap.cjs to wrap agent logs in details/summary
- Add comprehensive tests for the new wrapper function
- Update existing tests to expect wrapped output
- All JavaScript tests passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Wrap agent markdown log rendering in default section Wrap agent log rendering in collapsible details section Feb 6, 2026
Copilot AI requested a review from pelikhan February 6, 2026 18:57
@pelikhan pelikhan marked this pull request as ready for review February 6, 2026 19:01
Copilot AI review requested due to automatic review settings February 6, 2026 19:01
@pelikhan pelikhan merged commit f219cb6 into main Feb 6, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/wrap-agent-log-rendering branch February 6, 2026 19:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GitHub Actions log rendering pipeline so agent markdown logs are wrapped in an HTML <details open> block with a standardized summary label (🤖 {Parser} CLI Session), improving readability in step summaries and safe-output issue bodies.

Changes:

  • Added wrapAgentLogInSection() helper to wrap agent log markdown in a collapsible <details> section.
  • Updated log_parser_bootstrap.cjs to apply wrapping for both Copilot CLI-style summaries and the fallback markdown output path.
  • Updated/added tests to validate wrapper behavior and adjust bootstrap expectations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
actions/setup/js/log_parser_shared.cjs Introduces wrapAgentLogInSection() and exports it for use in bootstrap.
actions/setup/js/log_parser_bootstrap.cjs Wraps step-summary markdown output using the new wrapper function.
actions/setup/js/log_parser_shared.test.cjs Adds unit tests for wrapper behavior.
actions/setup/js/log_parser_bootstrap.test.cjs Updates expectations to match wrapped step-summary output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1432 to +1436
const openAttr = open ? " open" : "";
const emoji = "🤖";
const title = `${emoji} ${parserName} CLI Session`;

return `<details${openAttr}>\n<summary>${title}</summary>\n\n${markdown}\n</details>`;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parserName is interpolated directly into the <summary> HTML without escaping. If it ever contains characters like <, &, or ", it can break the rendered markup (and potentially allow HTML injection in step summaries/issue bodies). Please HTML-escape parserName (and/or the computed title) before embedding it in the <summary> tag.

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +167
// Wrap the agent log in a details/summary section (open by default)
const wrappedAgentLog = wrapAgentLogInSection(copilotCliStyleMarkdown, {
parserName,
open: true,
});

// Add safe outputs preview to step summary
let fullMarkdown = copilotCliStyleMarkdown;
let fullMarkdown = wrappedAgentLog;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapping is applied for the main parsed-markdown paths, but the earlier Copilot conversation.md fast-path still writes result.markdown directly to the step summary (unwrapped). That means Copilot --share output won’t get the collapsible section even though other paths do. Consider wrapping that path too (or update the PR description/behavior to be consistent).

Copilot uses AI. Check for mistakes.
Comment on lines +2138 to +2147
it("should properly escape markdown content", async () => {
const { wrapAgentLogInSection } = await import("./log_parser_shared.cjs");

const markdown = "Content with <tags> and `code`";
const result = wrapAgentLogInSection(markdown, { parserName: "Copilot" });

expect(result).toContain(markdown);
expect(result).toContain("<details open>");
expect(result).toContain("</details>");
});
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test claims the wrapper “properly escape[s] markdown content”, but wrapAgentLogInSection currently injects markdown verbatim and the assertions only check that the raw string is present. Either update the test name/expectations, or implement escaping/sanitization if the intent is to render <tags> literally rather than as HTML.

Copilot uses AI. Check for mistakes.
const { wrapAgentLogInSection } = await import("./log_parser_shared.cjs");

expect(wrapAgentLogInSection("")).toBe("");
expect(wrapAgentLogInSection(" ")).toBe("");
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name says it covers “undefined markdown”, but it never calls wrapAgentLogInSection(undefined). Add an explicit undefined case or adjust the test description to match what’s being tested.

Suggested change
expect(wrapAgentLogInSection(" ")).toBe("");
expect(wrapAgentLogInSection(" ")).toBe("");
expect(wrapAgentLogInSection(undefined)).toBe("");

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants