Skip to content

feat(web): notes on a diff, sent to an agent as one message - #242

Closed
waterbang wants to merge 2 commits into
mainfrom
feat/diff-line-notes
Closed

waterbang wants to merge 2 commits into
mainfrom
feat/diff-line-notes

Conversation

@waterbang

Copy link
Copy Markdown
Collaborator

What

In the workspace Changes view, a user can now leave notes on diff lines and send them to an agent as one message, instead of describing each location by hand.

  • Click a line number to add a note on that line; Shift-click another line in the same hunk to cover a range. Notes are shown under their last line and can be edited or deleted.
  • A bar under the diff collects the notes of every file. After choosing an agent, Send notes sends them all as one message. Each entry is path:line (or path:12-18), the diff snippet and the note. References reuse the existing message path linking, so they become clickable file links in chat.
  • Drafts are kept in browser storage per Group and workspace, so switching files or reloading keeps them. They are cleared when the message is accepted and kept, with the reason, when sending fails. A note whose lines are no longer in the current diff stays in the list and is still sent.
  • Changes still never writes to Git.

The second commit fixes two issues found against a real repository: a file at the workspace root is written as ./added.md:4 so chat links it (the path parser needs a directory), and each snippet line is cut to 240 characters with a note of how many were left out, so a 5,000-character line no longer produces a 5.8 KB message.

New logic lives in web/src/features/diffNotes/ (model, store, widgets, bar, hook); WorkspaceDiffViewer.tsx only gains the wiring.

Verification

  • 27 tests across diffNotesModel, diffNotesStore and WorkspaceDiffViewer.notes. The viewer tests fail without the wiring; the root-path and long-line tests fail on the first commit.
  • scripts/quality_gate.sh fast on this branch passes; the diff-notes and workspace test files pass on this base (204 tests).
  • Checked against a real Git repository through the real /workspace/changes and /workspace/diff endpoints in an isolated instance: two hunks in one file, an added (staged) file, a deleted file, a rename with edits, a 5,000-character line and a Chinese file name. Every reference in the sent message was compared with the file on disk (and with HEAD for the deleted file) and matched. Sending was also done from a 390 px phone layout.
  • Not covered: a pure rename without edits, binary files, conflicted files and patches over the size limit.

Changes showed a diff but gave no way to say anything about it: feedback on a
change meant retyping the path, the line and the code into the composer.

Select a line number in a diff to write a note on that line; Shift-select a
second number in the same hunk to cover the lines between. Notes stay under
their last line, can be edited and deleted, and collect across files in a bar
under the diff. Send notes writes all of them into one message for the chosen
agent: the file and line in the form messages already link (`src/a.ts:12`),
the diff lines, and the comment.

Notes are kept in the browser per workspace, so opening another file or
reloading does not lose them. They are cleared when the message is accepted
and kept when sending fails. A note whose lines have left the diff stays in
the list and is still sent with the lines it was written on.

Changes still never writes to Git.
…ng lines

Checked against a real repository, a note on a file at the workspace root was
written as `README.md:12`, which a message does not take for a path, so it
was not a link. Such a file is now written as `./README.md:12`.

A note on a minified or generated line put the whole line into the message.
A snippet line is now cut at 240 characters and says how many were left out.
@waterbang waterbang closed this Dec 1, 2026
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