Skip to content

fix(session): render requested review patches - #957

Open
benvinegar wants to merge 2 commits into
mainfrom
fix/session-review-patch-output
Open

fix(session): render requested review patches#957
benvinegar wants to merge 2 commits into
mainfrom
fix/session-review-patch-output

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • render resolved unified diff bodies in human-readable hunk session review --include-patch output
  • omit the dangling Notes: heading when --include-notes finds no notes
  • add formatter regression coverage and a patch changeset

Verification

  • bun run typecheck
  • bun run lint
  • bun 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.ts
  • bunx oxfmt --check src/session/agent/cliClient.ts src/session/agent/cliClient.test.ts .changeset/quiet-patches-speak.md

This PR description was generated by Pi using gpt-5.6-sol

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hunk-web Ignored Ignored Preview Aug 31, 2026 7:01pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR renders resolved unified patches in human-readable session-review output, suppresses empty note headings, and adds formatter regression coverage plus a patch changeset.

  • Adds optional patch bodies beneath each review file.
  • Emits the Notes: section only when notes are present.
  • Covers patch and note formatting behavior in colocated tests.

Confidence Score: 3/5

This 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

Security Review

Human-readable patch output is emitted without terminal sanitization, allowing terminal control sequences from reviewed content to alter or spoof the displayed review. How this was verified: The raw patch was traced from resource decoding through the formatter’s unchanged text branch to the direct stdout write, while the analogous diff renderer sanitizes the same class of content.

Important Files Changed

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

Comment thread src/session/agent/cliClient.ts Outdated
...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]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 security 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

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.

1 participant