Skip to content

Add plugin annotation support to code review diff rendering - #202

Merged
C-Hipple merged 1 commit into
mainfrom
claude/plugin-inline-annotations-dbxd5y
Jul 31, 2026
Merged

Add plugin annotation support to code review diff rendering#202
C-Hipple merged 1 commit into
mainfrom
claude/plugin-inline-annotations-dbxd5y

Conversation

@C-Hipple

Copy link
Copy Markdown
Owner

Summary

Adds support for rendering plugin annotations in the code review diff buffer. Annotations are line-level metadata attached by plugins (e.g., security checks, linting) that anchor to specific lines in the PR's HEAD side. They render as compact <A: plugin> indicators when collapsed, or full annotation blocks when expanded, similar to how comments work.

Changes

  • Annotation data model: New buffer-local variables crs--buffer-annotations and crs--buffer-show-annotations track annotation state; annotations start collapsed by default
  • Annotation rendering:
    • crs--insert-annotations-into-buffer inserts annotations into the washed diff, anchoring to HEAD-side lines
    • Annotations for lines outside visible hunks attach to the file's first hunk header instead
    • Annotations for files not in the diff are dropped (remain visible only in plugin output)
    • Compact indicators carry annotation data in a crs-annotations text property for echo-area preview
  • Toggle UI: New crs-toggle-annotations command (bound to A) expands/collapses all annotations; toggling comments also syncs annotation visibility
  • Echo-area preview: crs--maybe-show-collapsed-comments refactored to preview both comments and annotations when hovering over compact indicators
  • Plugin output: crs--insert-plugin-output-entry (new) centralizes plugin output formatting and lists annotations sorted by file and line
  • Syntax highlighting: New washer faces for annotation indicators and severity tags (washer-annotation-{face,error,warning,info}-face)
  • Documentation: Updated docs/plugins.md with annotation rendering behavior

Test Plan

  • Added 7 new unit tests covering annotation indexing, compact/expanded rendering, position preservation, and minibuffer summaries
  • Existing tests pass; new functions exported in test allowlist
  • Manual verification: toggle annotations in review buffer, verify compact indicators appear on annotated lines, expand to see full blocks, check echo-area preview on hover

https://claude.ai/code/session_01AX28EsRRuZrRKfyR6yHmrT

Plugins can attach line-level annotations to the PR diff via the response
contract, but the Emacs client ignored them. Now the review buffer renders
the GetPR annotations aggregate inline:

- Annotations are inserted after delta-wash (like review comments), so the
  washer's syntax painting is untouched; compact indicators are appended at
  line end without rewriting the line.
- They start collapsed to a right-aligned <A: plugin> indicator. Toggling
  comments open with H expands annotations along with them, and the new
  crs-toggle-annotations command (A) toggles them on their own.
- With the cursor on an annotated line, the echo area previews the
  annotations; the indicator carries them in a crs-annotations text
  property so the post-command hook needs no re-parsing.
- An annotation anchors to its head-side line, matching the web client.
  Lines the diff can't show attach to the file's first hunk header
  (labelled with the target line); files outside the diff are skipped.
- Plugin output buffers now show the parsed contract body instead of raw
  JSON stdout and list each plugin's annotations sorted by file and line,
  via a shared crs--insert-plugin-output-entry helper.
- Severity tags and indicators get their own washer faces.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AX28EsRRuZrRKfyR6yHmrT
@C-Hipple
C-Hipple merged commit 9c2df13 into main Jul 31, 2026
7 checks passed
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.

2 participants