fix(diff): wrap multiline review comments#287
Merged
forketyfork merged 2 commits intomainfrom Apr 13, 2026
Merged
Conversation
Issue: Long comments in the diff overlay were squeezed into a single line while editing and after saving, which broke the expected multiline behavior and made review notes hard to read. Solution: Reworked diff comment layout so wrapped text drives comment height instead of fixed boxes. Updated rendering, cursor placement, hit testing, and submit animation sizing to use the same wrapped layout logic. Added a regression test that now runs under zig build test and documented the multiline comment behavior in the README.
Issue: The PR started failing in CI because the diff comment regression test was imported through diff_overlay, which also pulled an unrelated failing scrollbar test into the default zig build test target. Solution: Moved the pure diff comment wrapping and height logic into a dedicated helper module with its own regression test. Updated the overlay to use that shared helper and switched the main test import to the helper so the intended regression test still runs without broadening the CI test surface.
There was a problem hiding this comment.
Pull request overview
Updates the diff overlay’s inline review comments to render and edit as wrapped multiline text, keeping layout-dependent behavior (rendering, cursor placement, scrolling math, hit testing, button placement, and submit animations) aligned with the wrapped layout. This addresses issue #285 where long comments were previously rendered as a single squashed line.
Changes:
- Introduces wrapped-line iteration and multiline layout/height calculation for saved and editing diff comments.
- Reworks rendering, cursor positioning, hit testing, and animation sizing to use wrapped comment metrics.
- Adds a regression test for height expansion and updates README copy to mention multiline wrapping.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/ui/components/diff_overlay.zig |
Implements wrapped comment layout/rendering + height math and adds a regression test for multiline height expansion. |
src/main.zig |
Imports the diff overlay module in the test build so its new test is included. |
README.md |
Updates the “Diff review comments” feature description to note multiline wrapping. |
Comments suppressed due to low confidence (2)
src/ui/components/diff_overlay.zig:1112
renderWrappedCommentTextcreates and destroys an SDL texture for every wrapped line on every frame (makeTextTextureinside the per-line callback). With multiline wrapping and the removal of the previous 200/500-char render truncation, a large pasted comment can trigger many allocations/texture creations per frame and noticeably degrade UI performance. Consider caching rendered line textures per comment until the text or wrap_cols changes, or enforcing a reasonable maximum render length/line count for the interactive overlay to keep frame time bounded.
const clamped = @max(@as(i64, 0), elapsed);
const t = @min(1.0, @as(f32, @floatFromInt(clamped)) / @as(f32, @floatFromInt(duration)));
return switch (anim) {
.editor_opening => easing.easeOutCubic(t),
.editor_closing => easing.easeInOutCubic(t),
src/ui/components/diff_overlay.zig:2676
totalCommentPixelHeighthard-codesFullscreenOverlay.overlayRect(host)when computing wrapped comment heights, but comment height now depends on available text width (savedCommentTextWidth/editingCommentTextWidth). InrenderFn, the viewport usesanimatedOverlayRect, so during open/close animations (or any future width animation) scroll metrics/max_scroll can desync from the actual rendered layout. Consider threading the samerectused for rendering intototalCommentPixelHeight(and callers likesyncScrollMetrics) so scroll math stays consistent with wrapped layout.
var agent_cmd: ?[]const u8 = null;
if (agent_name) |name| {
agent_cmd = std.fmt.allocPrint(self.allocator, "{s}\n", .{name}) catch {
self.allocator.free(comments_text);
return;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #285
Solution
The diff overlay was treating comment text as a single rendered line and then squeezing that texture into the available width. This change moves diff comments to a wrapped multiline layout and uses that same layout data for rendering, cursor placement, scroll math, hit testing, button placement, and submit animations, so the editor and saved comments stay in sync. It also adds a regression test for wrapped comment height expansion and updates the README to reflect the multiline comment behavior.
Automated checks:
zig buildjust lintzig build teststill reports an existing unrelated failure insrc/ui/components/scrollbar.zigTest plan
Cmd+Din a repo with changes