mirror of
https://github.com/coder/coder.git
synced 2026-06-05 14:08:20 +00:00
2ad0e74e67
## 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 - Added `diff-comment` type to `ChatInputPart` and `ChatMessagePart` in `codersdk/chats.go` with `FileName`, `StartLine`, `EndLine`, `Side` fields ### Frontend - **`DiffCommentContext`**: React context/provider managing pending diff comments with `addReference`, `removeComment`, `restoreComment`, `clearComments` - **`DiffCommentNode`**: Lexical `DecoratorNode` rendering 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 tracking - **`InlinePromptInput`**: 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 editor - **`AgentDetail`**: Bidirectional sync between DiffCommentContext and Lexical editor. Comments are sent as `diff-comment` parts on message submit - **`ConversationTimeline`**: Renders `diff-comment` message parts with file:line labels ## How it works 1. Click a line number in the diff → inline textarea appears below that line 2. Type a comment and press Enter → reference chip appears in chat input with your text after it 3. Send the message → diff-comment parts are included alongside the message text