feat(site): add diff line reference and annotation system for agents chat#22697
Merged
feat(site): add diff line reference and annotation system for agents chat#22697
Conversation
Contributor
Documentation CheckNew Documentation Needed
Automated review via Coder Tasks |
DanielleMaywood
approved these changes
Mar 6, 2026
Contributor
DanielleMaywood
left a comment
There was a problem hiding this comment.
We have a syncing useEffect which might be able to be replaced but that can be a future fix
d3ef533 to
8f1538a
Compare
Users can click line numbers in the Git diff panel to open an inline prompt input, type a comment, and have a reference chip + text added to the Lexical chat input. Comments are sent as diff-comment parts alongside the message. The diff-comment part includes the actual code content from the diff lines that were commented on, giving the LLM full context of what the user is referencing. - Add DiffCommentContext for managing comment state - Add DiffCommentNode (Lexical DecoratorNode) for inline chips - Add InlinePromptInput for annotation-based comment entry - Add diff-comment handling in backend (coderd/chats.go) - Add diff-comment rendering in ConversationTimeline - Add diff-comment parsing in messageParsing.ts - Extract actual diff code content via extractDiffContent helper - Sync diff comments bidirectionally between context and Lexical
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a line-reference and annotation system for diffs in the Agents UI. Users can click line numbers in the Git diff panel to open an inline prompt input, type a comment, and have a reference chip + text added to the chat message input.
Changes
Backend
diff-commenttype toChatInputPartandChatMessagePartincodersdk/chats.gowithFileName,StartLine,EndLine,SidefieldsFrontend
DiffCommentContext: React context/provider managing pending diff comments withaddReference,removeComment,restoreComment,clearCommentsDiffCommentNode: LexicalDecoratorNoderendering inline chips in the chat input showing file:line references. Chips are clickable (scroll to line in diff), removable, and support undo/redo via mutation trackingInlinePromptInput: Textarea annotation rendered inline under clicked lines in the diff. Supports multiline (Shift+Enter), submit (Enter), cancel (Escape)FilesChangedPanel: Line click/drag-select handlers open the inline input. On submit, a badge chip + plain text are inserted into the Lexical editorAgentDetail: Bidirectional sync between DiffCommentContext and Lexical editor. Comments are sent asdiff-commentparts on message submitConversationTimeline: Rendersdiff-commentmessage parts with file:line labelsHow it works