fix(session): render requested review patches - #957
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR renders resolved unified patches in human-readable session-review output, suppresses empty note headings, and adds formatter regression coverage plus a patch changeset.
Confidence Score: 3/5This PR is not safe to merge until human-readable patch output is sanitized against terminal control-sequence injection. Resolved patches contain repository-derived raw text and now flow unchanged into stdout, bypassing the terminal sanitization used by analogous diff-rendering paths. Files Needing Attention: src/session/agent/cliClient.ts
|
| Filename | Overview |
|---|---|
| src/session/agent/cliClient.ts | Adds patch rendering and empty-note suppression, but sends untrusted patch bodies to terminal output without control-sequence sanitization. |
| src/session/agent/cliClient.test.ts | Adds useful regression coverage for patch preservation and conditional note headings, but does not cover terminal-control input. |
| .changeset/quiet-patches-speak.md | Correctly records the formatter behavior changes as a patch release. |
Prompt To Fix All With AI
### Issue 1
src/session/agent/cliClient.ts:512
**Patch output bypasses sanitization**
When a reviewed text patch contains terminal control sequences, `formatReviewOutput` writes them unchanged to stdout, allowing the patch to clear, reposition, or overwrite terminal content and spoof the displayed review. **How this was verified:** The raw patch was traced from resource decoding through the unchanged text-output branch to the direct stdout write, while the analogous diff renderer sanitizes the same class of content.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(session): render requested review pa..." | Re-trigger Greptile
| ...review.files.flatMap((file) => [ | ||
| ` - ${formatSessionPath(file.path)} (+${file.additions} -${file.deletions}, hunks: ${file.hunkCount})`, | ||
| ...file.hunks.map((hunk) => ` hunk ${hunk.index + 1}: ${hunk.header}`), | ||
| ...(file.patch === undefined ? [] : [" patch:", file.patch]), |
There was a problem hiding this comment.
Patch output bypasses sanitization
When a reviewed text patch contains terminal control sequences, formatReviewOutput writes them unchanged to stdout, allowing the patch to clear, reposition, or overwrite terminal content and spoof the displayed review. How this was verified: The raw patch was traced from resource decoding through the unchanged text-output branch to the direct stdout write, while the analogous diff renderer sanitizes the same class of content.
Knowledge Base Used: Agent command orchestration
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/session/agent/cliClient.ts
Line: 512
Comment:
**Patch output bypasses sanitization**
When a reviewed text patch contains terminal control sequences, `formatReviewOutput` writes them unchanged to stdout, allowing the patch to clear, reposition, or overwrite terminal content and spoof the displayed review. **How this was verified:** The raw patch was traced from resource decoding through the unchanged text-output branch to the direct stdout write, while the analogous diff renderer sanitizes the same class of content.
**Knowledge Base Used:** [Agent command orchestration](https://app.greptile.com/modem/-/custom-context/knowledge-base/modem-dev/hunk/-/docs/agent-command-orchestration.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Fixed in 462bbc8. Human-readable patch output now passes through sanitizeTerminalText, which strips terminal control sequences while preserving patch newlines and tabs. Added a regression test covering a terminal-clear sequence and diff layout preservation.
Responded by Pi using openai/gpt-5.6-sol.
This comment was generated by Pi using gpt-5.6-sol
Summary
hunk session review --include-patchoutputNotes:heading when--include-notesfinds no notesVerification
bun run typecheckbun run lintbun test src/session/agent/cliClient.test.ts src/session/agent/commands.test.ts src/session/broker/projections.test.ts src/session/broker/reviewResources.integration.test.tsbunx oxfmt --check src/session/agent/cliClient.ts src/session/agent/cliClient.test.ts .changeset/quiet-patches-speak.mdThis PR description was generated by Pi using gpt-5.6-sol