Skip to content

feat(review): the comment box opens next to the lines it is about - #195

Merged
backnotprop merged 7 commits into
mainfrom
feat/comment-near-selection
Nov 24, 2026
Merged

backnotprop merged 7 commits into
mainfrom
feat/comment-near-selection

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What changes

The comment box in plannotator-tui review opened along the bottom of the diff, centred and up to 84 columns wide, wherever the lines were. Now it opens next to what it is about, as a document's comment box does.

  • Lines (c, s, the toolbar after a drag, e on a line note in the rail): directly under the last row that shows the lines. In a split diff it sits over the lines' side, as wide as that pane (at most 84). It never covers the lines while there is room, and they stay shaded while you type.
  • No room below (lines on the last rows): above the first row.
  • Lines taller than the pane: over them, next to the end the cursor is at (the end last moved to).
  • C: under the file's heading (its own heading, or the one kept on the top row), else at the top of the pane. M: centred in the diff pane.
  • The box grows with the text up to eight rows on the side it opened on. Out of room there, it scrolls inside rather than jump over the lines.

The view stays still

  • Opening, typing, saving and Esc never moved the diff before this change: the box only draws over it. The tests now lock that in by comparing every pane row and the cursor before opening, while typing, after Esc and after a save.
  • The one thing that moves after the first save is not the box. The notes panel opens with the first note and narrows the diff. The viewer keeps the noted lines on their screen rows, but at about 120 columns the narrower diff can switch from split to unified. That behaviour is unchanged here; a test checks that the lines keep their rows.

Mouse while the box is open

  • A click on the box's text moves the text cursor there (new Compose::click).
  • Every other mouse report does nothing: clicks outside, the Send button, the wheel over the diff, drags and moves. A stray click never loses the draft, and the wheel never scrolls the lines out from under the box.
  • The result is the same whether the reports come one per frame or 100 before a frame.

Notes

  • No new colours: the box keeps the comment border colour on both themes.
  • The document screen is unchanged. Its box already opens at the selection.
  • The comment box's text rows now follow the height it is given. The document screen passes the same height as before, so it draws the same.

Tests

review/tests/compose_near.rs (placement) and review/tests/compose_still.rs (view, cursor, mouse), against the real Screen:

  • placement: top and middle of a split diff, both sides; unified; wrap on; lines on the last rows (box above); the suggest box; lines taller than the pane, dragged down and up; growth then inner scroll; 60x12; C and M; editing from the rail
  • the view and cursor unchanged on open, while typing, after Esc and after a save; the first note keeps its rows when the rail opens
  • 100 stray mouse reports in a burst and one per frame keep the draft, the box and the view, and end the same
  • a click on the box's text moves the text cursor

Fixes from review

  • Scrolled box: the box keeps the row it scrolled to while the cursor is in view. A click or an arrow key inside the box no longer shifts the text, and the next click lands on the clicked line.
  • Tiny boxes: a box too short for its borders shows its text alone, inside its rectangle. It never draws outside it, and the draft is kept.
  • Suggestions keep their code: a suggestion keeps its code exactly, including carriage returns, tabs and trailing spaces. Only a new line typed after the last line is dropped. Comments are still trimmed.
  • Tabs: tabs draw as four columns in the box and stay tabs in the saved text.

backnotprop and others added 7 commits November 23, 2026 18:32
A drag past the diff pane's top or bottom moved the cursor a line for
every mouse report, with no limit on the rate and no stop at the hunk
the selection is kept in. Terminals in a window can report every pixel
the pointer moves, so a drag that touched the footer row scrolled
hundreds of lines in a moment, through the other files to the end of
the diff. Several reports also arrive between two frames, and each
click after a scroll was hit-tested against the stale frame, so a
burst ended on other lines than the same reports one per frame.

Now a report for the cell already reported does nothing, only a line
of code takes the drag's click, and no report scrolls. Held past an
edge, the view scrolls a line per 50 ms on the event loop's tick, and
only while the anchor's hunk has lines that way.
…sense mouse reports are ignored

The document screen scrolled one row for every drag report past the
text's top or bottom, so a terminal that reports each pixel raced the
document to its end. It now follows the review: a report for the cell
already reported does nothing, no report scrolls, and held past an
edge the document scrolls a row per 50 ms on the loop's tick until it
ends. The edge timer moves to ui::drag, shared by both screens.

Both screens now ignore a mouse report for a cell outside the terminal
(pixel positions, a broken encoding) instead of reading it as the
pointer past the bottom. A release there still ends a drag, at the
nearest cell.
The box for a comment or a suggestion opens right under the selected lines, or above them
at the bottom of the diff, over their side of a split diff, and never over them while there
is room. A file note opens under the file's heading, a note on the whole change in the
middle, an edit under the note's lines. It grows on the side it opened on and scrolls
inside. While it is open a click on its text moves the text cursor and every other mouse
report does nothing, so a stray click keeps the draft and the wheel keeps the lines under
the box.
…ide, a suggestion keeps its code

The box keeps the row it scrolled to while the cursor stays in view, so a click or an arrow
inside it no longer shifts the text. A box too short for its borders draws its text alone,
inside its rectangle. A suggestion keeps its code exactly (carriage returns, tabs, trailing
spaces), losing only a new line typed after the last one, and tabs draw as four columns.
@backnotprop
backnotprop added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 43078e9 Nov 24, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/comment-near-selection branch November 24, 2026 01:03
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