Add a chunk generator for rendered text in diffs.
Review Request #15533 — Created Nov. 16, 2026 and updated
The text review UI can diff the rendered view of file attachments, such
as rendered Markdown, butFileDiffs could only be diffed as plain
text. This change addsRenderedDiffChunkGenerator, which brings the
rendered view to FileDiffs.It loads both sides of the file just like
DiffChunkGenerator,
including baseFileDiffsand interdiffs. It then renders each side
into rows with a text review UI, and diffs the rows using that review
UI's comparison rules.
TextBasedReviewUIhas two new classmethods for this:
-
render_text_rows()renders text into rows.The default
generate_render()now uses this, so a review UI that
implements it supports the rendered view for both file attachments
and diffs.MarkdownReviewUIimplements it with
render_markdown_blocks(). -
get_rendered_diff_chunk_generator_cls()returns a chunk generator
that uses the review UI.
This can't do interdiff filtering, since that operates specifically on
source lines, which do not necessarily map to rendered rows.
This is not yet connected to the diff viewer.
- Ran unit tests.
- Used in conjunction with other changes.
- Commits:
-
Summary ID pnkmrwwyoolusqtpvsqnskwvuwvuymtt pnkmrwwyoolusqtpvsqnskwvuwvuymtt
Checks run (2 succeeded)
-
-
In the
MarkdownReviewUIwe catch any errors fromrender_markdown_blocks()and log and show an error message as the rendered lines. We should probably do something similar here, otherwise users just see an ugly traceback in the diff fragment box. Might even be better to raise aUserVisibleErrorinstead of putting the error in the row text.On a related note, the user wouldn't be able to switch back to the source view if the rendered view fails. Would be nice to allow that.