Skip to content

fix(review): give the collapsed-thread bubble its gutter slot back - #202

Merged
nplez1 merged 4 commits into
nplez1/mainfrom
nplez1/bug-the-collapsed-comment-expand-bubble-and-the
Oct 28, 2026
Merged

nplez1 merged 4 commits into
nplez1/mainfrom
nplez1/bug-the-collapsed-comment-expand-bubble-and-the

Conversation

@nplez1

@nplez1 nplez1 commented Oct 28, 2026

Copy link
Copy Markdown
Owner

What

Fixes #190. In a diff surface, the add-note "+" (a DOM button at left: 4px, z-index 5, inside Monaco's glyph-margin column) and a collapsed review thread's bubble decoration (glyph margin) wanted the same gutter slot for the same line. The "+" was drawn on top and swallowed the click, so hovering a commented line offered "add a note" and hid "there is a conversation here".

Now: one control per line, and the conversation wins.

How

  • usePRCommentInlineDecorator returns gutterOccupiedLines — the lines it draws as collapsed-thread bubbles. It is derived from the same gutterMarks list the bubbles are drawn from, so the two cannot drift.
  • useDiffCommentDecorator takes gutterOccupiedLineNumbers, and the overlay's canCommentOnLine refuses those lines (diff-comment-add-button-overlay.ts). A line with a thread shows only the bubble; a line without one shows the "+" exactly as before.
  • Wired on all three surfaces that mount both decorators: DiffViewer.tsx (worktree diff tab), DiffSectionItem.tsx (combined / PR-files diff), and MonacoEditor.tsx through useMonacoMarkdownAnnotations (a markdown file with live review threads). The thread decorator runs first on each so its handle is available.

Two notes on the decision, recorded rather than dropped:

  • The capability is displaced, not removed. c (Add Review Note) reads the editor selection, so a note can still be started on a threaded line from the keyboard, and dragging down the line-number column still starts a range that can include it. docs/site/content/docs/review/annotate-ai-diff.mdx says so, and the CSS comment in main.css records why the overlap is safe now.
  • Pushing the occupied set does not rebuild the overlay. It changes identity on every review refresh and every thread toggle anywhere, and a reinstall would re-park the button under a stationary pointer and drop a gutter drag in flight (rangeDrag.dispose() ends the drag without committing). So the running overlay is told through setGutterOccupiedLines, which also hides a parked "+" whose line just gained a thread, and the scroll handler hides rather than repositions a parked line that stopped being ours.

Two fork-owned files were split rather than growing past the 400-line oxlint max-lines budget: the commentable/occupied line-set derivation (use-diff-comment-line-sets.ts) and the overlay's own install effect (useDiffCommentAddButtonOverlay).

Tests

Changed/added:

  • usePRCommentInlineDecorator.test.tsx (new): a collapsed thread owns its line (0 visible "+"), the line beside it still offers one, the glyph-margin bubble decoration is really on that line, a thread opening does not rebuild the running button (same DOM node), and collapsing under a parked "+" hides it.
  • use-monaco-markdown-annotations.test.tsx (new): the plain editor's marker path forwards the occupied lines, and the filter is the parameter rather than a blanket suppression.
  • diff-comment-editor-test-fixture.ts: the fake keeps one decoration record per collection (clearing one no longer erases another's) and applies initial decorations, so decoration assertions are faithful.

Run locally on dbe4f2b9f2 (clean tree, rebased onto nplez1/main @ 6587eefcb8):

  • pnpm test src/renderer/src/components/diff-comments src/renderer/src/components/pr-comment-inline src/renderer/src/components/editor — 412 files, 3196 passed, 3 skipped
  • pnpm tc — clean
  • pnpm run check:code-quality:changed — 0 new findings
  • pnpm run check:max-lines-ratchet — OK, no new bypass
  • orca-queue node local/gate-lint.mjs — PASS — 38 green, 1 failing: 2 known red, 0 new; 100.9 s

One unrelated commit is included. The base commit 941acb70e0 (#198) lands two check:flaky-test-pattern-ratchet findings in its own test files, so the lint gate fails on any branch cut from it. dbe4f2b9f2 records them in local/lint-known-red.json with one narrow match per file — a new finding in either file still fails the gate — plus the LOCAL-PATCHES.md evidence line the file requires. The fix belongs to the checks-panel work (fake timers or a fixed timestamp), not here; pruning wins when it lands.

Not run: the full unit suite. This diff touches no global input (package.json, lockfiles, config/**, root tsconfigs, src/packages/**, src/shared/**), so it is gated by the change-scope tests above; the full suite runs on the nightly fork-main-tests.yml lane and again at release.

Review

Reviewed by Opus 5.5, high: R1 (2 SHOULD-FIX fixed), delta re-check on R2 (both resolved; 3 MINOR + 1 NIT newly noted), those fixed in R3 without a third round.

Open NIT, listed rather than fixed: moving the thread decorator ahead of the note decorator changes which effect adds view zones first, so a local note and an expanded thread on the same line may order vertically differently on first mount. Harmless; no fixture pins it.

The add-note "+" overlay and a collapsed PR review thread's bubble both
claim the same gutter slot, so the "+" was drawn on top of the bubble and
swallowed the click. Hovering a commented line therefore offered "add a
note" and hid "there is a conversation here".

The thread decorator now reports the lines it draws as bubbles and the
note decorator's overlay skips them: one slot, one affordance, and the
conversation wins. The Add Review Note chord still reads the editor
selection, so a note can still be left on a threaded line from the
keyboard — displaced, not dropped.

Two fork-owned files split instead of growing past the max-lines budget:
the line-set derivation and the overlay's own install effect move into
their own modules.

Closes #190.
Review round 1 on 68d29feb3e found the fix incomplete and the overlay
fragile:

- MonacoEditor's markdown annotations mount the same add-note decorator
  on the editor that carries the thread bubbles, so a markdown file with
  a collapsed thread still showed the "+" over the bubble. The thread
  decorator now runs first there and hands its occupied lines down.
- Handing the occupied set in as an install dependency rebuilt the
  overlay whenever any thread anywhere was toggled or PR comments were
  refetched. That reinstall drops a gutter drag in flight and re-parks
  the button under a stationary pointer, so the running overlay is told
  through its handle instead, and the set is value-keyed like the
  commentable one.
- A parked line that stops being ours (its thread collapsed) now hides
  the "+" instead of drawing it back over the bubble on the next scroll.
- The test asserts the bubble decoration is really on the line, and that
  a thread opening does not rebuild the running button.
…e rest

Delta re-check of d0e5714983 left three small gaps and two test holes:

- the scroll handler skipped the "+" on a line that stopped being ours
  instead of hiding it, leaving a button parked at the wrong pixels for
  the wrong line; it now hides and clears the hovered line.
- the occupied-line setter could hide the "+" mid-drag, where that
  button is the only sign the gesture is live; it stands down there.
- the line-sets comment claimed a new set rebuilds the overlay, which
  the previous commit stopped doing.
- the test now also covers a thread collapsing under a parked "+", the
  markdown editor's forwarding of the occupied lines, and the fake
  keeps one decoration record per collection so a clear by one
  collection cannot erase another's.
The base commit 941acb7 lands two `check:flaky-test-pattern-ratchet`
findings in its own test files, so the lint gate on any branch cut from it
fails on work that branch never touched. Neither file is in this branch's
diff, and both are static ast-grep findings rather than a bad run.

Recorded with one narrow `match` per file, so a new finding in either still
fails the gate, plus the evidence line LOCAL-PATCHES.md requires. The fix
belongs to the checks-panel work: fake timers or a fixed timestamp.
@nplez1
nplez1 merged commit 3e65fab into nplez1/main Oct 28, 2026
@nplez1
nplez1 deleted the nplez1/bug-the-collapsed-comment-expand-bubble-and-the branch October 28, 2026 05:30
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.

[Bug]: The collapsed-comment expand bubble and the add-note "+" occupy the same gutter slot, so one swallows the other

1 participant