Skip to content

feat: add line comments to the diff that go back to the agent as one message - #122

Merged
abhishekgahlot2 merged 4 commits into
useagenthq:mainfrom
Asymtode712:feat/line-comments-in-diff
Nov 6, 2026
Merged

abhishekgahlot2 merged 4 commits into
useagenthq:mainfrom
Asymtode712:feat/line-comments-in-diff

Conversation

@Asymtode712

@Asymtode712 Asymtode712 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #89

What

Comment on lines of the agent's diff, like a pull request review, and send all the comments back as the next message.

  • Click a line or drag across a few in the Diff pane, write a comment, and it is kept as a draft under those lines.
  • Keyboard: arrow keys move between lines (one tab stop per change), Shift+Arrow extends, Enter opens the comment box, Ctrl/Cmd+Enter saves, Escape cancels.
  • A bar above the diff counts the drafts and offers Discard and Send comments.
  • Send comments builds one message (each file path, line numbers, the quoted code as a diff block, then the comment) and puts it in the reply composer, focused, using the same prefill path as "Ask agent to redo". The drafts are then cleared.
  • Drafts are kept per thread outside the pane, so they survive collapsing a file and switching rail tabs.

How

  • session-ui/diff-review.ts: the draft store (useSyncExternalStore, keyed by thread id) and buildReviewMessage, a pure function. The quoted code's fence grows past any backticks inside it.
  • session-ui/diff-line-comments.tsx: CommentableHunk (selection, comment form, saved comments) and ReviewBar.
  • file-diff-view.tsx: diff lines now carry oldLine / newLine when the recorded payload has them (a numbered @@ header, or a Write's whole body), shown in a gutter. Edit-tool changes record no position, so they stay unnumbered and the message says so instead of guessing. Comments are on only when a review target is passed in.
  • diff-pane.tsx: passes the thread id and the composer prefill. The lab page and anything without a composer render the diff as before.

Notes

  • Dragging over diff rows now selects lines instead of text.
  • Drafts live in memory, so reloading the page drops them.
  • session-view.tsx is unchanged.

Testing

  • diff-review.test.ts: building the follow-up message (paths, line ranges, quoted code, ordering, singular wording, fence escaping) and the new line numbering.
  • file-diff-view.test.tsx: lines take comments only when a review target exists.
  • bun run typecheck, bun run lint and bun test components pass, except the existing terminal-parser test that also fails on main.

Screenshots

Screenshot 2026-10-11 at 10 32 59 PM Screenshot 2026-10-11 at 10 33 28 PM Screenshot 2026-10-11 at 10 35 13 PM

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@abhishekgahlot2

Copy link
Copy Markdown
Contributor

recheck

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Asymtode712

Copy link
Copy Markdown
Contributor Author

@abhishekgahlot2 I have updated the branch, can you please review this PR now

Send comments used the composer prefill, which replaces the draft, so a
reply the user had started (and its saved draft) was overwritten by the
review message. The prefill now takes an append option: the Diff pane asks
for it and the composer adds the review under a non-empty draft. Ask agent
to redo still replaces the draft.
@abhishekgahlot2
abhishekgahlot2 merged commit 8d110ef into useagenthq:main Nov 6, 2026
21 checks passed
@abhishekgahlot2

Copy link
Copy Markdown
Contributor

Merged, thanks @Asymtode712. Commenting on diff lines and sending them back as one review message is a great workflow. I added a small follow-up so Send comments adds the review under a half-written reply instead of replacing it.

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment on lines of the agent's diff and send them back as one message

2 participants