Skip to content

AI reviews brief the user, with real diagrams in reviews and Chat - #360

Merged
frenchie4111 merged 6 commits into
mainfrom
pr-review-explainer
Nov 5, 2026
Merged

frenchie4111 merged 6 commits into
mainfrom
pr-review-explainer

Conversation

@frenchie4111

Copy link
Copy Markdown
Collaborator

What this does

AI reviews used to be a verdict and summary written for the author agent. A reviewer now also writes a briefing for you: what the change does and why, how it works (with a diagram), the critique with blockers kept separate from non-blocking notes, and a recommendation. It shows in the Review tab. The author agent never receives it.

Diagrams are real now: a ```mermaid block renders as a themed diagram in review markdown and in Chat tabs.

sequenceDiagram
    participant R as Reviewer agent
    participant N as Ness
    participant A as Author agent
    participant U as You
    R->>N: submit_review(verdict, summary, briefing)
    N->>A: verdict + summary + comments
    N-->>U: Review tab: briefing card
Loading

Changes

Briefing

  • ReviewSubmission.briefing (optional). It's accepted by submit_review (mcp-bridge.js → control-server.ts → review-service.ts) and stripped on load if it's malformed.
  • The Review tab shows it in a "Briefing for you" card. When a briefing exists, the author summary collapses under "What the author agent receives".
  • The default reviewer prompt and the "Open PR as worktree" prompt ask the agent to explain, diagram, critique and recommend. The PR prompt used to say "skip restating what the PR does". These defaults only apply to users who haven't customised their prompts.
  • The reviewer footer's wording changed. The old wording is kept as a retired footer so it's still stripped from transcripts already on disk.

Mermaid

  • MermaidDiagram is shared by ReviewMarkdown and JsonModeChat.
    • It loads mermaid on the first diagram, serializes renders, and caches them by theme + source.
    • Strict security mode; clicking a link inside a diagram does nothing.
    • On a parse error it shows the source plus the error.
    • A hover toggle shows the source.
    • Text size follows uiScale. Wide diagrams shrink to 65% at most, then scroll.
  • remarkMermaid only marks a block once its closing fence has arrived, so a diagram that's still streaming stays a code block and never re-renders per token. It matches blocks by their body, not their position, because remarkInsight re-parses Insight cards.
  • Theme-aware node classes: :::added, :::changed, :::removed and :::focus map to success, warning, danger and accent, so agents don't have to guess hex colours.
  • The Ness system prompt tells Chat agents that Mermaid renders and when ASCII is still the better choice.

Testing

  • npm run typecheck, npx electron-vite build, npx vitest run (165 files / 2262 tests). New tests cover the briefing in review-service, the retired footer, the bridge forwarding the briefing, and remarkMermaid (fences closed vs. still streaming, fence matching, blocks inside Insight cards).
  • Checked by hand in a headless instance with a throwaway data dir:
    • Mermaid themed rendering, sizing and node classes in the Review tab, using a hand-written sample review.
    • A live Chat agent drew a sequence diagram unprompted, and chose ASCII for a git graph.

Known gaps

  • Reviews from "Open PR as worktree" run in a plain Chat tab without submit_review, so their explanation appears in chat rather than as a briefing card.
  • You can't edit a briefing on a draft review.
  • Mermaid adds ~1MB to the app download. It's split into its own chunk, so startup isn't affected.
  • Not checked in the light theme.

🤖 Generated with Claude Code

frenchie4111 and others added 6 commits November 4, 2026 13:47
A reviewer's submit_review now takes a `briefing`: markdown written for
the user rather than the author agent — what the change does and why,
how it works (with ASCII diagrams), the critique with blockers kept apart
from non-blocking notes, and a merge recommendation. It is stored on the
submission and shown in the Review tab above the summary, but never
delivered to the author, who wrote the change and only needs the summary
and comments.

The default reviewer and PR-review prompts now ask for that explanation
instead of telling the agent to skip restating what the PR does. The
review-request footer changed with it, so the previous wording is kept as
a retired footer that transcripts on disk still strip cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The summary is what the author agent receives; next to the briefing it
read as a second, redundant verdict. It now sits behind a disclosure, and
submit_review tells the reviewer to keep it a terse to-do list for the
author rather than restate the briefing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ```mermaid block in review markdown or a Chat message now draws as a
diagram, themed from the Ness color variables and sized from the root
font-size so it follows uiScale. Mermaid loads lazily on the first
diagram, renders are serialized and cached by theme + source, and a
parse error falls back to the code block with the error underneath.
A hover toggle shows the source.

In Chat, remarkMermaid only marks a block once its closing fence has
arrived, so a diagram streaming in stays a code block instead of
re-running mermaid on every token. It matches blocks by body rather than
position because remarkInsight re-parses Insight cards.

The reviewer prompts, submit_review's briefing description and the Ness
system prompt now tell agents mermaid renders, keeping ASCII for tiny
sketches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agents can't see the user's theme, so hex colors they pick often vanish
against it. A node marked :::added, :::changed, :::removed or :::focus
is now colored from the success/warning/danger/accent theme variables
(removed is also struck through), in flowcharts, state and class
diagrams. The rules use !important because mermaid's own style block is
scoped by the svg id. The system prompt and reviewer prompts point agents
at these classes instead of raw colors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- remarkMermaid compares bodies line-trimmed and strips blockquote
  markers, so a fence nested under a list item or inside a blockquote is
  marked closed. remark strips the container indent from code.value, so
  the raw-source key never matched and those diagrams stayed as source.
- Reset the cached theme key when the last diagram unmounts. Otherwise a
  theme switch with no diagram on screen went unseen and the next diagram
  hit a cached SVG in the old colors.
- Word the shipped review prompts neutrally. "Visual learner" and "wants
  to merge" described one user, and the latter nudged every reviewer
  toward softer verdicts.
- Test that a malformed briefing is dropped on load; formatting nit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frenchie4111
frenchie4111 merged commit 89fa6b9 into main Nov 5, 2026
1 check 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.

1 participant