Update comment-memory rendering to use six-backtick code regions#28115
Update comment-memory rendering to use six-backtick code regions#28115
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c58aea4c-9179-42ff-b29b-9bbb205e5f9b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… region Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c58aea4c-9179-42ff-b29b-9bbb205e5f9b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c58aea4c-9179-42ff-b29b-9bbb205e5f9b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c58aea4c-9179-42ff-b29b-9bbb205e5f9b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c58aea4c-9179-42ff-b29b-9bbb205e5f9b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ence lines Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c58aea4c-9179-42ff-b29b-9bbb205e5f9b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c58aea4c-9179-42ff-b29b-9bbb205e5f9b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
🧪 Test Quality Sentinel ReportTest Quality Score: 97/100✅ Excellent test quality
Test Classification DetailsView All Test Classifications (11 tests)
Analysis NotesThis PR adds a
Minor observation: 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: §24844716189
|
There was a problem hiding this comment.
Pull request overview
Updates managed comment-memory formatting to wrap stored memory content in six-backtick Markdown code fences, and adds parsing support to strip those fences (while remaining compatible with legacy unfenced entries).
Changes:
- Render managed comment-memory bodies with six-backtick fenced regions.
- Strip six-backtick fences when extracting managed memory entries back into local files, with edge-case handling.
- Expand/adjust Vitest coverage for fenced, legacy unfenced, and malformed fence scenarios.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/spec_test.go | Formatting-only alignment change in a table-driven test struct. |
| actions/setup/js/comment_memory.cjs | Wraps managed memory content with the exported six-backtick fence marker during rendering. |
| actions/setup/js/comment_memory_helpers.cjs | Adds fence constants + stripCommentMemoryCodeFence() and uses it in extraction. |
| actions/setup/js/comment_memory_helpers.test.cjs | Adds unit tests for fence stripping and malformed/legacy cases. |
| actions/setup/js/comment_memory.test.cjs | Asserts rendered comment bodies include the new fence marker. |
| actions/setup/js/setup_comment_memory_files.test.cjs | Updates tests to use the new fenced managed comment format. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/6 changed files
- Comments generated: 2
| const openingTag = `<${COMMENT_MEMORY_TAG} id="${memoryID}">`; | ||
| const closingTag = `</${COMMENT_MEMORY_TAG}>`; | ||
| core.info(`comment_memory: building managed body for memory_id='${memoryID}'`); | ||
| let body = `${MANAGED_COMMENT_HEADER}\n\n${openingTag}\n${sanitizeContent(rawBody)}\n${closingTag}`; | ||
| let body = `${MANAGED_COMMENT_HEADER}\n\n${openingTag}\n${COMMENT_MEMORY_CODE_FENCE}\n${sanitizeContent(rawBody)}\n${COMMENT_MEMORY_CODE_FENCE}\n${closingTag}`; | ||
|
|
There was a problem hiding this comment.
Wrapping memory content with a fixed six-backtick fence will break Markdown rendering if the memory itself contains a line equal to the same six-backtick sequence (it will prematurely close the outer fence and corrupt the rest of the comment). Consider selecting a fence length that is longer than any backtick-run present in the sanitized memory content (minimum 6), and update the stripping/parser logic to accept that variable fence length so round-tripping remains reliable.
| function stripCommentMemoryCodeFence(content) { | ||
| const trimmed = typeof content === "string" ? content.trim() : ""; | ||
| if (trimmed.length === 0) { | ||
| return ""; | ||
| } | ||
| if (!trimmed.startsWith(COMMENT_MEMORY_CODE_FENCE)) { | ||
| return trimmed; | ||
| } | ||
| const match = trimmed.match(new RegExp(`^${ESCAPED_COMMENT_MEMORY_CODE_FENCE}[^\\n]*\\n([\\s\\S]*)\\n${ESCAPED_COMMENT_MEMORY_CODE_FENCE}$`)); | ||
| if (!match) { |
There was a problem hiding this comment.
stripCommentMemoryCodeFence() constructs a new RegExp on every call. This helper runs in a loop while scanning many comments/pages, so repeatedly compiling the same regex is unnecessary overhead. Consider precompiling the fence-stripping regex once at module scope and reusing it inside the function.
Summary
Validation
npx vitest run comment_memory.test.cjs comment_memory_helpers.test.cjs setup_comment_memory_files.test.cjs(fromactions/setup/js)make fmt-cjsmake agent-finish(currently fails due to pre-existing workflow package test failures:TestCopilotDetectionDefaultModelandTestWasmGolden_CompileFixturesinpkg/workflow)