Skip to content

Risk bars on the files and lines a High or Medium risk names - #3886

Merged
backnotprop merged 28 commits into
mainfrom
feat/review-risk-bars
Nov 23, 2026
Merged

backnotprop merged 28 commits into
mainfrom
feat/review-risk-bars

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Approved record: "review-risk-bars" (risk bars in the file tree and the diff), with the owner's later decision q-070bc2a3: "a card on the bars; no row in the diff".

What it does

  • The risk check now returns places (file + lines) for High and Medium. Low still returns none. The prompt change is one sentence (see below). Old stored Medium results with no places still load and show no bars.
  • On a PR's layer review, a three-bar mark is shown exactly twice. High fills all three bars. Medium fills two and draws the third faint. The bars are 2px wide, 2px apart, 6/9/12px tall, on whole pixels, in an orange-red mixed from --destructive and --warning:
    • once before each named file's icon in the rail's tree (Changes and All files), 5px clear of the icon, drawn over the indent so no row moves. A marked file at the tree's root has only the row's padding there, so the tree gets data-lead-room and every row starts 8px further in;
    • once in the diff, at the right edge of each named range's first line.
  • No row under the code. The "Risk · High · reason" row that was drawn under a named line is gone. The reason is now a card on the bars:
    • Hover the bars or give them keyboard focus: the card opens after the ref hover cards' delay and closes when you leave (the pointer can move into it).
    • Click or tap: the card is pinned. Escape, a press outside or a second press closes it.
    • Escape closes the card only when the key comes from the bars, the card, or nowhere with its own Escape. Typing in a comment box, a dialog, another popover or a modal keeps its own Escape.
    • A card closes when its bars scroll out of the diff, or when the diff lets the file go (the bars are made again when it comes back). Scrolled back, no card opens until you ask. A line the diff draws again keeps its bars, so its card stays.
    • The card is never taller than the room beside the bars or the screen; long reasons scroll inside it.
    • The card says what the old row said when open: the risk gauge, "Risk", the level ("High" / "Medium"), "your rule “…”" when the place named one, and the place's reason. Two places that start on one line share a mark, and the card lists both. A Medium place with no reason shows the level only.
    • The header's "N places" (and "See the N places") still steps to each place and scrolls it into view, and now opens that place's card (pinned) and closes the one before. It counts and steps High places only, as on main. A Medium judgment's bars have no stepper: you reach them with the pointer or with Tab. This PR does not change that.
    • The card is ui's Popover (Base UI), anchored to the bars, portaled into the Inbox. Nothing in the diff moves. On a phone it fits the screen (max 320px, 12px from the edges).
  • The diff mark is a real button. It is the marked line's last child inside the file's shadow root (review-editor hostLineMarks.ts, keepHostLineMarks). Its accessible name says what its card says: "High risk: " / "Medium risk: ", and when the place named the person's rule, the rule as the card words it ("High risk · your rule “…”: "). It has aria-haspopup="dialog" and aria-expanded. Pierre has no slot for an element at a line's end: its line annotations are rows under the line (what this removes), and its gutter utility is one element that follows the hovered line. So the view keeps one button per marked line and puts the same button back each time Pierre draws the line again. A press on it never reaches the diff's line selection. The same CSS as before places it, so it never covers code:
    • Wrapped: the line keeps 24px free, so its text wraps first.
    • Scrolling sideways: the mark sticks to the visible edge. On that line the code ends where the mark begins. The mark also adds its width to the line, so when you scroll to the end, the last character is clear of it.
    • This works in split and unified views, on removed (old) and added (new) lines. The mark is filled with the line's own colour.
  • @plannotator/ui's PopoverContent gets a small seam: anchor, collisionPadding and a portal container pass through. Existing callers are unchanged. packages/ui/HANDOFF.md has the entry: backward compatible, and a host needs the next ui version after 0.64.0.
  • A range whose lines the diff on screen does not draw gets no diff mark. Its file keeps its tree mark.
  • Nothing beside the +N/−N counts, nothing in headers, no legend. Classic code review: unchanged.

Risk prompt, before → after

  • A high answer adds "where": … → A high or medium answer adds "where": …
  • Low and medium answers have no "where". → A low answer has no "where".

Tests

  • packages/server/inbox-pull-risk.test.ts: Medium keeps places and Low does not. An old Medium result without places loads with no new run.
  • packages/inbox/pulls/riskBars.test.ts: tree files and diff ranges per judgment, each range's reasons (two places on one line share a mark), and the accessible name (with the rule when the place named one). Low, none and no places draw nothing. An off-diff range falls back to the tree mark only. Medium's third bar is faint.
  • DOM packages/inbox/pulls/riskBarsCard.test.tsx, on the real mark buttons in a shadow root: the accessible name; hover opens the card with the old row's words and leaving closes it; keyboard focus opens it and blur closes it; a press pins it, and a second press, Escape and a press outside close it; the stepper opens each place's card in turn; Medium with and without a reason; the card closes when its bars are taken away and none opens on the bars made again, while a line drawn again keeps its card; Escape typed in a comment box reaches the box and leaves the card, Escape from the bars closes it; aria-haspopup / aria-expanded.
  • DOM packages/review-editor/components/hostLineMarks.test.ts: the button lands on the named line on its side in split and unified views; the same button comes back when the line is drawn again; it goes when its mark does; hover, keyboard focus and press reach the host; a press does not reach the line.
  • DOM packages/inbox/guide/pullChangesTreeRisk.test.tsx: the tree mark shows once per named file and not on others, with none when there is no result. A marked root file makes room; one inside a folder does not.
  • Browser tests/e2e/inbox-review-risk-bars.spec.ts (CI only): no overlap on long lines (split and unified, both sides, scrolling and wrapped), and the end of the line is reachable; no risk row in the diff; the card on hover, keyboard focus, press (pinned), second press, outside press and Escape; the stepper opens each place's card; a pinned card whose bars scroll out of the diff closes, and scrolled back no card opens; the card is wholly on screen, on top, and moves nothing; a phone's tap opens it inside the screen. It also checks the tree gap (4–6px) and that rows line up, at the root too, and writes the tone's contrast to contrast.json. Screenshots in review-risk-bars/: 01-high-card-dark.png, 02-medium-card-dark.png, 03-closeup-tree-light.png, 03-closeup-diff-card-light.png, 04-low-no-marks-dark.png, 05-long-line-split-card-dark.png, 06-long-line-unified-card-dark.png, 07-root-file-tree-dark.png, 08-phone-card-dark.png, 09-scrolled-away-no-card-dark.png (new: the bars scrolled out, no card left floating). To scroll, src/charges/client.ts in the fixture has 80 more unchanged lines; no earlier screenshot shows that file.

Typecheck note

  • packages/inbox/guide/pullChangesTreeRisk.test.tsx stays in packages/inbox/tsconfig.json's exclude. It renders guide/PullChangesTree.tsx, which main already excludes there: through it the strict config reaches review-editor's ReviewStateContext and AllFilesCodeView, which give 48 errors under those settings, none in the test. Taking the test out of the exclude makes tsc -p packages/inbox/tsconfig.json fail. tsconfig.guide.json checks both files with no errors in them. The reason is now a comment in the tsconfig.

The risk check now returns places for Medium as well as High (Low none).
On a PR's review, each named file gets a three-bar mark before its icon in
the file tree, and each named range one at the right edge of its first line
in the diff.
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 22, 2026
… tree's root

The diff mark is now drawn by the marked line itself (review-editor's host line
marks: CSS in the file's shadow root), 24px at the column's visible right edge in
the line's own colour. Wrapped, the line keeps that room free; scrolling, the mark
sticks to the edge and adds its width to the line, so the end of the line can be
scrolled clear of it. Bars are 2px wide, 2px apart, 6/9/12px tall on whole pixels;
Medium's third bar is faint. The tree mark keeps 5px from the icon, and a marked
file at the root gives the tree 8px of room so the mark stays in its row.
…h (Pierre sets its column variables only with annotations)
The diff's mark is now a real button at the end of the named line (kept by
review-editor's hostLineMarks on the file's shadow root), named "High risk:
<reason>". Hovering it, focusing it or pressing it opens a card on ui's
Popover with what the old risk row said; a press pins it, Escape, a press
outside or a second press close it. The header's places stepper opens each
place's card. The risk rows under the code are gone.
…pe only when it is the card's; the bars' name says the rule; HANDOFF for PopoverContent's new props
@backnotprop
backnotprop marked this pull request as ready for review November 23, 2026 17:23
@backnotprop backnotprop removed the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 23, 2026
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 23, 2026
@backnotprop
backnotprop merged commit 42c23c3 into main Nov 23, 2026
60 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run the full browser suite (Inbox window e2e) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant