Skip to content

feat(artifacts): line-anchored comments on code blocks via Pierre primitives - #8360

Merged
iamwhatever merged 2 commits into
mainfrom
feat/artifact-code-comments
Oct 22, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
feat/artifact-code-comments

Conversation

@helenastafford

@helenastafford helenastafford commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A reviewer can leave an anchored comment on specific lines of a code block in a markdown artifact, through the same composer, thread popover and sidebar prose comments use.

Selecting code inside a fence and trying to comment silently does nothing. Code fences render inside Pierre's shadow DOM, so the page's light-DOM selection capture cannot read the selection, and the highlight overlay's TreeWalker never descends into the shadow root. Code is often exactly what a reviewer wants to discuss.

Why it matters

Review conversations about implementation details have no home today. Reviewers fall back to document-level comments that lose the link to the lines, or paste code into prose comments by hand.

Not a goal

  • Commenting on fences nested inside blockquotes or lists (their block-relative positions do not map to a document line; they stay non-commentable).
  • Code chips in the chat side panel (ArtifactPanel); it only stops painting code threads on prose.
  • Character-level anchors inside code: code comments are line-anchored.
  • Comments on chat diff lines (that is feat(website): draft review comments on chat diff lines via Pierre #9453; the two PRs touch the same Pierre wrapper props but different surfaces).
  • Chips for a line the comment store redacted. The store redacts credential-like text in quote/prefix/suffix; such a code thread no longer matches the source, so it shows in the sidebar without a chip. Prose anchors degrade the same way today. Accepted.
  • An explicit anchor kind field. It would need a CommentAnchor schema change on the backend, the provider sync and the agent-facing tools, for a fact the stored raw-source prefix already decides. The two spaces and the rule for any future writer are recorded in docs/system-specs/modules/artifacts.md.

What changed (motivation → approach → change)

Goal: comment on code with the same thread machinery prose uses.

Approach: ride Pierre's own primitives (enableLineSelection / onLineSelected, renderGutterUtility, lineAnnotations / renderAnnotation) instead of piercing the shadow boundary. Line anchors are the natural unit for code.

  • codeComments.ts (new): derives fence spans from parseBlocks (the renderer's own block positions), builds code anchors, and routes stored anchors to fences. A code anchor stores SOURCE offsets, the source slice as quote, and raw-source prefix/suffix. Routing is offset-pinned first, then a prefix-gated drift search after an edit. Prose anchors carry no raw-source prefix, so they are never claimed. A chip sits under the range's last line. proseOverlayComments drops code threads from a prose overlay.
  • CodeBlock.tsx: drag line numbers to pick a range; the gutter button comments on it (or on the hovered line). Routed threads render as count chips, filled while unread or active; a chip click passes its box so the thread popover opens beside it. The button copies Pierre's own z-index/offset so it is clickable and leaves the digits free for a drag, and keeps a picked range when pressed. Prose fences keep soft-wrap.
  • EditableCodeBlock.tsx / MarkdownRenderer.tsx: pass sourceStartLine to CodeBlock, only on artifact pages.
  • pierre/index.tsx / PierreImpl.tsx: pass annotation and gutter props through.
  • ArtifactDetailPageBody.tsx: CodeCommentsScope mounts the context; a gutter click stages the anchor into the existing composer via its external-selection channel (useArtifactDetailPageComments.ts now returns stageIframeSelection). Code threads are routed on every markdown view, so a historical version never paints them on prose.
  • ArtifactPanel.tsx: the side panel's overlay drops code threads too.
  • SelectionToolbar.tsx: a press inside the container that itself opens an external selection (a touch tap on the gutter button) no longer closes the box it just opened.
  • CommentThreadPopover.tsx: re-clicking a chip (shadow DOM, read via composedPath) no longer closes the popover and its unsent reply. The 360px card also clamps to narrow viewports (320px phones), prose threads included.
  • docs/system-specs/modules/artifacts.md: records the two anchor offset spaces and that the rescan never rewrites offsets or context.
  • website/src/i18n/locales/*.json: codeBlock.add_comment, codeBlock.comment_thread.
  • website/capture/artifact-code-comments.* / website/scripts/capture-artifact-code-comments.mjs: real-browser capture of the page.

Backwards compatibility

Compatible: every new prop is optional and the context defaults to null, so chat and preview code blocks render as before.
Removes nothing: no field, prop, key or path is removed or tightened.

Tests

  • codeComments.test.ts (25): fence spans, prose never claimed, replies and resolved threads skipped, drift after an edit, server-capped quote, EOF anchor, line mapping, round-trip, multi-line chip on the last line, proseOverlayComments.
  • CodeBlock.comments.test.tsx (6): gutter button sends the hovered line or the range; chips pass their box on click; inert without context; prose fence keeps wrap.
  • MarkdownRenderer.codeSourcepos.test.tsx (2): sourceStartLine only for artifact markdown.
  • ArtifactDetailPage.codeComments.test.tsx (3): gutter → page composer → source-offset post; stored anchor → chip → popover; prose anchor not claimed.
  • CommentThreadPopover.dismiss.test.tsx (+1): a chip press inside a shadow root keeps the popover; another shadow press closes it.
  • SelectionToolbar.composer.test.tsx (+1, fake timers): an open handed over during the same press survives; red on main's toolbar.
  • Determinism: the touched files ran shuffled 3 times, 149/149 green each. (ArtifactDetailPage.anchoredComments "text artifact" fails under shuffle on main too; not touched here.)
  • Nearby suites green: ArtifactDetailPage.*, CodeBlock.*, SelectionToolbar.*, ArtifactPanel.*, all of src/i18n. tsc -p tsconfig.app.json and eslint clean.

Manual verification

node website/scripts/capture-artifact-code-comments.mjs mounts the real ArtifactDetailPage and Pierre in headless Chromium, both themes, and asserts each step: read chip outlined and unread chip filled; a drag over line numbers 3..5 shows the gutter button; a real mouse click opens the composer; Enter posts an anchor whose quote is exactly source lines 3..5 and a third chip appears under line 5. All checks OK. This run found and fixed three bugs the jsdom tests could not see: the button sat under the line numbers, a press on it dropped the range, and a fast tap closed the composer. The last pair of shots (chip opens its thread) comes from one more step on the same harness that clicks a chip and asserts the popover shows that thread within 80px of the chip; it is not in the committed script yet.

Screenshots / video

Dark theme. Read thread outlined (line 2), unread filled (line 6):

dark: read and unread chips

Lines 3..5 dragged; the gutter add-comment button on the range:

dark: range selected with gutter button

The button opens the page's comment composer:

dark: composer open over the code

Posted: a third chip under line 5, a third sidebar entry:

dark: posted thread chip

Clicking the line-6 chip opens its thread right beside it, with the reply box focused; the sidebar card lights up too:

dark: chip opens its thread popover

Light theme, same steps:

light: read and unread chips

light: range selected with gutter button

light: composer open over the code

light: posted thread chip

light: chip opens its thread popover

Related Issues

Closes #8339

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@helenastafford
helenastafford requested review from a team and Zedmor September 4, 2026 03:07
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of d5ba0a16cd32f2c9389265039a5b4148f7d903ea — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The rendered evidence covers both themes, the PR removes nothing, and the design uses Pierre's own line primitives instead of reaching into its shadow DOM.

Notes

  • Telling the two anchor spaces apart by whether the raw-source prefix matches, with no kind field, is a durable convention. Any future writer that rewrites prefix/start_offset, such as a provider sync, will silently move threads between prose and code. The spec now records this, but nothing enforces it. A backend test that round-trips a code anchor through the rescan and the sync would pin it.
  • The chip-to-popover capture step is not in the committed script. Commit it so the screenshot of that step can be reproduced.

[DESIGN-REVIEWED] d5ba0a1

Description read

[DESCRIPTION-READ] 88d02eb380ec6bc5859c99650234e613c6889b23aae34ccc70239941b51b4137

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of d5ba0a16cd32f2c9389265039a5b4148f7d903ea — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Every item serves the frozen Goal (#8339). Nothing blocks. The narrow-viewport popover clamp rides along at almost no cost.

What this change ships

Inventory (10 items) — 9 justified

Intent: let a reviewer comment on specific lines of a code block in a markdown artifact, through the same composer, popover and sidebar that prose comments use. This is an ADDITION; the description calls the current behaviour a silent failure.

  1. Dragging line numbers in an artifact code fence picks a line range, and a gutter button on hover opens the comment composer — justified
  2. Code threads show as count chips under the range's last line, filled while unread or active — justified
  3. The prose overlay no longer paints code threads on prose text, on the artifact page and in the chat side panel — justified
  4. Clicking a chip opens its popover beside it, and clicking it again keeps the unsent reply — justified
  5. The thread popover shrinks to fit 320px viewports, for prose threads too — rides along
  6. A touch tap on the gutter button no longer closes the composer it just opened — justified
  7. Historical versions route code threads without showing chips, so they are never highlighted as prose — justified
  8. The artifacts spec records the two anchor offset spaces and that the rescan never rewrites offsets — justified
  9. New i18n strings codeBlock.add_comment and codeBlock.comment_thread in every locale — justified
  10. A real-browser capture script for the page, matching the repo's existing website/capture/ pattern — justified

[FIRST-PRINCIPLES-REVIEWED] d5ba0a1

Description read

[DESCRIPTION-READ] a690c3ddebf2f5905489a55c939b5c7a265225185a01104a5122e738d54fc811

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of d5ba0a16cd32f2c9389265039a5b4148f7d903ea — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

No primary control was misread. The blind reader correctly guessed what the gutter button, the chips, the composer and the popover each do, and would use all of them. Every new state appears in both themes.

Notes

  • The reader could not tell the outlined chip from the filled one ("can't tell what the difference means"). Change the chip title from "Comment thread (1)" to something that says the state, e.g. "1 unread comment" or "1 comment".
  • In shot-04, lines 3–5 stay highlighted after the comment posts, and the reader couldn't tell whether that was still a selection or a mark for the commented lines. Clear the Pierre line selection once the post succeeds.
  • The thread popover in shot-05 covers lines 2–5, including the chip that was just added. Place it below the chip when there's room, so the commented lines stay visible.

[UX-REVIEWED] d5ba0a1

Description read

[DESCRIPTION-READ] 3696c0ea3e631fc48c4c0ddc736d310d1151fcf388ac4074b4a711188c156334

That sha256 names everything this verdict read: the PR description, plus the 13 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed d5ba0a16cd32f2c9389265039a5b4148f7d903ea — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] d5ba0a1

Verdict parsed from the review's SHA-scoped output markers for commit d5ba0a16cd32f2c9389265039a5b4148f7d903ea.

False positive or not applicable? A repository writer can comment:
/ai-review override fable d5ba0a16cd32f2c9389265039a5b4148f7d903ea: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of d5ba0a16cd32f2c9389265039a5b4148f7d903ea and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d5ba0a1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt d5ba0a16cd32f2c9389265039a5b4148f7d903ea: <one-sentence reason>

@helenastafford
helenastafford force-pushed the feat/artifact-code-comments branch from 6d3af43 to a3eb1f0 Compare September 4, 2026 03:28
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 4, 2026
@helenastafford

helenastafford commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

span=0ca69ffbf75f

Disposition: fixed — GPT finding "Resolved code threads bypass the anchor-visibility guard" (codeComments.ts:155).

routeCodeComments now skips c.status === 'resolved' roots alongside replies, so resolving a code thread removes its gutter chip — the same visibility contract as the prose overlay (InlineCommentOverlay filters status !== 'resolved'; review stays visible in both surfaces). The guard sits before both routing tiers, so neither the exact nor the drift tier can claim a resolved thread, and a resolved code thread cannot leak back into the prose overlay because that surface filters resolved independently. Regression test: "does not route a resolved thread (chip disappears, matching the prose overlay)" in codeComments.test.ts. Fix lands on head a66861d.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 4, 2026
@helenastafford
helenastafford force-pushed the feat/artifact-code-comments branch from a3eb1f0 to a66861d Compare September 4, 2026 03:44
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 4, 2026
@helenastafford
helenastafford force-pushed the feat/artifact-code-comments branch from a66861d to c813024 Compare September 4, 2026 04:01
@helenastafford

Copy link
Copy Markdown
Contributor Author

span=2f715e40b5e4
Disposition: FIXED (head c813024)

Finding: at a 320px viewport, activating a code annotation opened the fixed 360px CommentThreadPopover with the close/reply controls clipped off-screen.

Fix applied at the root cause in the shared popover (the same component prose bubble clicks and sidebar activation open via the same openThreadHandler): the card width now clamps to the viewport (max-w-[calc(100vw-16px)] plus matching JS position clamps cardW(vw) = min(360, vw-16) in both reposition branches, with the left bound floored at the 8px gap). At 320px the card renders 304px wide fully inside the viewport with all controls reachable; at ≥376px behavior is unchanged. This fixes the flagged code-annotation path and the pre-existing identical clipping on prose threads. Verified read-only by a model-pinned reviewer: bounds [8, 312] at vw=320, no card child exceeds 304px, no other consumer assumes 360px.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 4, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 20, 2026
@iamwhatever
iamwhatever force-pushed the feat/artifact-code-comments branch from b89daec to a49d9ec Compare October 20, 2026 02:46
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 20, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

span=cc8af0798bf3
Disposition: accepted-and-deferred — UX Watch "No keyboard path to comment on code".

Legitimate: Pierre's line selection and gutter utility are pointer-only, so a keyboard user cannot pick code lines here.
Out of this PR's goal (the pointer flow on Pierre's own primitives); keyboard users can still comment on the document from the sidebar.
Deferred to #22402 (deferred-finding, assignee iamwhatever, Due 2026-11-20).

@iamwhatever

Copy link
Copy Markdown
Contributor

span=b668e4e38484
Disposition: accepted-and-deferred — UX Watch "The highlight stays after posting".

Legitimate: the range stays shaded after a post because the block uses Pierre's uncontrolled selection.
Clearing it needs a controlled selectedLines wiring; the comment itself is stored and its chip shows under the range's last line (shot 4).
Deferred to #22402 (deferred-finding, assignee iamwhatever, Due 2026-11-20).

@iamwhatever

Copy link
Copy Markdown
Contributor

span=05a4ef9e3ab3
Disposition: accepted-and-deferred — UX Watch "Filled vs outlined chips are unexplained".

The chips copy the prose overlay's bubble language (filled while unread or active, outlined once read), so code and prose threads read alike today.
Naming the state in the tooltip/aria-label needs a new i18n key in all 13 locales; better done once for both surfaces.
Deferred to #22402 (deferred-finding, assignee iamwhatever, Due 2026-11-20).

@iamwhatever

Copy link
Copy Markdown
Contributor

span=38567192db44
Disposition: accepted-and-deferred — UX Suggestion "Name the range in the gutter button's label".

Good idea; it needs a new interpolated i18n key in all 13 locales.
Deferred to #22402 (deferred-finding, assignee iamwhatever, Due 2026-11-20).

@iamwhatever

Copy link
Copy Markdown
Contributor

span=cc5a18751f0f
Disposition: rebutted — First Principles item 7 "the popover clamp rides along".

The clamp is needed by this PR's own surface: a code chip opens the shared CommentThreadPopover, and at 320px its fixed 360px card put Close and Reply off-screen (an earlier GPT finding on this PR).
The popover is one component for prose and code, so the smallest complete fix is in it; splitting it by surface would add code to keep prose clipped.
The change is 3 lines (cardW and max-w-[calc(100vw-16px)]); at 376px and wider nothing moves.

@iamwhatever

iamwhatever commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

span=3d5162e3e77b
Disposition: accepted-and-deferred — Opus finding "sidebar click on a code thread does not scroll to it".

Legitimate and advisory: activateFromSidebar scrolls by data-mc-cid, which cannot see a chip inside Pierre's shadow DOM, so the popover opens at its fallback spot. The thread still opens and works; chip clicks pass a rect and open beside the chip.
Deferred to #22402 (deferred-finding, assignee iamwhatever, Due 2026-11-20).

@iamwhatever

Copy link
Copy Markdown
Contributor

Answers to the two PASS asks on 84a19be:

Design (_format_anchor "chars X:Y"): the agent gets the quote first and the offsets second. For a code comment the offsets are source offsets, which are exactly the positions artifact_update edits, so they are the more precise kind. A prose comment's rendered-text offsets were already approximate for the agent before this PR. The quote is what an agent locates text by in both cases, and it is the exact source slice for code comments. No change.

First Principles (repeated quote + same 32-char prefix): a prose anchor's prefix is 32 chars of RENDERED text (anchorFromRange). It equals the raw source in front of an in-fence occurrence only when (a) the reader selected the code text itself, in the plain stand-in shown before highlighting loads, which is a comment on that code line, so the chip is right; or (b) the same quote with the same 32 chars before it appears both in prose and inside a fence. In (b) the thread shows as a chip on the code copy instead of a prose highlight and stays in the sidebar; nothing is lost. Covered by codeComments.test.ts "leaves a native prose selection (32 chars of RENDERED context) on prose".

iamwhatever
iamwhatever previously approved these changes Oct 20, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at 84a19be.

Code comments ride Pierre's own line-selection, gutter and annotation props, so nothing reaches into the shadow DOM. Anchors store source offsets with raw-source context, and routing tries the stored offset first, then a prefix-gated search after edits (codeComments.ts#L149). Replies, resolved threads and prose anchors are never claimed. The feature stays inert outside artifact pages because the context defaults to null.

Every AI item on this head has a reply. The popover clamp rebuttal holds, because code chips open the shared popover. The Design and First Principles PASS asks are answered with reasoning that matches the code. The five deferred UX/Opus items (keyboard path, clearing the range, chip state label, range label, sidebar jump) are all listed by span in #22402, which has an owner and a due date. All checks are green, there are no conflicts and the base is main.

Note for whoever approves: iamwhatever force-pushed this head, so under the last-push rule a different maintainer's approval is needed.

— crew-pr-reviewer (r114)

@dodgeblaster

Copy link
Copy Markdown
Contributor

Steward review — needs a rebase + a design decision before this can move

I picked this up from #8339 to verify and shepherd it. The implementation is sound and the crew reviewer approved it at 84a19be, but the branch has fallen behind main and now collides with work that shipped there in the meantime. I can't merge it as-is, and the remaining decision isn't mine to make — details below.

State as of today

  • CI (at head 84a19be): all green — every required check passes or skips, 0 failures.
  • Mergeability: CONFLICTING / DIRTY — the branch is ~90 commits behind main.
  • The only real source conflict is in one file: website/src/components/SelectionToolbar.tsx. The docs/system-specs/modules/artifacts.md and the i18n/locales/*.json files auto-merge cleanly.

Why the conflict is non-trivial (not a mechanical rebase)

After this branch's merge-base, main shipped #21133 (22e02d99bb) — "find and comment on text inside fenced code blocks", which solves the same shadow-DOM code-comment problem this PR targets, but with the opposite approach:

The two independently add a codeSelection prop and selection machinery to the same component, which is why the conflict is semantic rather than a same-directory coincidence. A blind rebase would leave two rival code-comment implementations in one file.

But the gap this PR fills is still open

#21133 wired only the file-viewer (MarkdownPanel, DiffBlock, CommentOverlay). It did not touch the artifact detail page — ArtifactDetailPage / CodeBlock / MarkdownRenderer have no codeSelection / pierreShadow wiring on main today. So artifact-page code comments (the #8339 scope) are still unimplemented on main. This PR is not redundant.

The decision this needs (maintainer call, not a steward's)

Now that main has a shipped, tested shadow-DOM-piercing pattern for code comments in the file viewer, there are two coherent paths for the artifact page and they're mutually exclusive in SelectionToolbar:

  1. Land this PR's Pierre-native line-anchored approach for artifact code comments (reconciling it against fix(file-viewer): find and comment on text inside fenced code blocks #21133's codeSelection prop so the component supports both hosts), or
  2. Extend fix(file-viewer): find and comment on text inside fenced code blocks #21133's pierreShadow approach to the artifact page for one consistent house pattern, superseding this PR.

That's a product/architecture choice I shouldn't make unilaterally.

What I'd ask of the author

  • Rebase feat/artifact-code-comments onto current main and resolve the SelectionToolbar.tsx conflict against fix(file-viewer): find and comment on text inside fenced code blocks #21133 — reconcile the two codeSelection prop definitions rather than clobbering main's. Once pushed, CI + the crew reviewer re-run on the new head (their approval is scoped to 84a19be and won't carry over; a force-push also re-triggers the last-push rule the reviewer already flagged — a different maintainer's approval is needed).
  • A note on whether you've considered converging on pierreShadow vs. keeping the Pierre-native path would help the maintainer settle (1) vs (2) quickly.

Leaving the issue and PR open pending that rebase + the design decision. This is a UX change, so screenshots of the artifact-page code-comment flow are expected before any merge.

@iamwhatever

Copy link
Copy Markdown
Contributor

@helenastafford heads-up: this PR blocks #22402, so we will merge current main into feat/artifact-code-comments and resolve the one conflict in website/src/components/SelectionToolbar.tsx. This is a merge commit on top of your branch, not a rebase or force-push, so your commits stay as they are. We will then fix any CI failure it causes. Pull before you push again.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor
  • span=12b2011ba91e -- Code anchors lack sidebar reveal and live popover positioning

Fixed in fd5d8bd. Chips and their code blocks now register as the thread's live anchor (codeAnchorElement in codeComments.ts). The chip click no longer passes a frozen rect. CommentThreadPopover looks the anchor up on every reposition, so it follows the chip on scroll.
A sidebar click with no rect scrolls the owning code block into view, and the popover moves onto the chip when the block's highlight mounts it (onCodeAnchorsChange).
Tests: CommentThreadPopover.codeAnchor.test.tsx (follows the chip on scroll; block reveal, then chip) and two new cases in CodeBlock.comments.test.tsx. All five fail on bb14517 and pass on fd5d8bd.
This also covers the sidebar-jump item of #22402.

@iamwhatever

Copy link
Copy Markdown
Contributor
  • span=0ca69ffbf75f -- Context equality misclassifies prose and code anchors

Not fixed here; this needs the author's call. The finding is in the PR's own anchor design, not in the merge from main: codeComments.ts is byte-identical between the PR head 84a19be and bb14517.
The design tells prose and code anchors apart only by whether the stored prefix matches the raw source (contextMatches, routeCodeComments). The module note at the top of codeComments.ts already names the prose-to-code case. The other half: a code anchor whose prefix changed after an edit is claimed by no fence, so proseOverlayComments hands it to the prose overlay.
A correct fix needs one stored anchor-origin field, as the finding says. That changes the stored anchor shape, so I did not make it on your branch. Heuristics such as "the quote starts on a line boundary" also match prose selections, so they would not be correct.
@helenastafford, how would you like this handled? (a) add an origin field to the anchor in this PR, (b) keep the current design and land it with a follow-up issue, or (c) another approach you prefer.

…mitives

Code fences render in Pierre's shadow DOM, unreachable by the light-DOM
selection capture and highlight overlay — so code comments now ride
Pierre's own line-selection / gutter-utility / lineAnnotations APIs.
Anchors encode source-content offsets (quote = exact source slice),
routing is span + slice-equality against blocks derived from the same
parseBlocks the renderer uses, and routed threads render as in-surface
annotation chips. Inert outside artifact pages.

Fixes #8339
@iamwhatever

Copy link
Copy Markdown
Contributor

@helenastafford heads-up: this branch was rebased onto main and force-pushed (with a lease), because PR Hygiene allows only 1 or 2 commits and refuses merge commits.

  • Old head: fd5d8bd
  • New head: 818384e (on main at a576d00)
  • Commit 1, 91dc994: your commit, unchanged except the SelectionToolbar.tsx conflict. It keeps main's codeSelectionRef and your externalOpenSeqRef.
  • Commit 2, 818384e: the GPT F2 fix (code-thread popover follows the live chip, sidebar reveal), plus its tests.

Before you push again, please run git fetch origin and point your local branch at the new head:

git fetch origin
git checkout -B feat/artifact-code-comments origin/feat/artifact-code-comments

If you have unpushed local work, save it on another branch first (git branch backup-8360). F1 is still waiting on your choice in the earlier comment.

A code thread's chip sits in Pierre's shadow DOM, where the thread
popover's [data-mc-cid] lookup cannot reach it. The chip click passed a
frozen rect, so the popover stayed put while the page scrolled, and a
sidebar click opened it at the fallback spot without revealing the code.

Chips and their code blocks now register as the thread's live anchor
(codeAnchorElement). The popover looks the anchor up on every reposition,
scrolls the owning block into view from the sidebar, and moves onto the
chip once the block's highlight mounts it.

Addresses GPT 6.1 finding F2 on bb14517 and the sidebar-jump item of
#22402.

Also put a range's chip under its selected empty last line: the line
count skipped a trailing newline, so a range ending on an empty line
showed its chip one line too high (GPT 6.1 finding on 818384e).
@iamwhatever

Copy link
Copy Markdown
Contributor

@helenastafford the head moved again: 818384e -> d5ba0a1. Your commit 91dc994 is unchanged. Only my commit on top changed: it now also fixes the GPT finding about a range that ends on an empty line (the chip sat one line too high), with a test.

The same command applies before you push:

git fetch origin
git checkout -B feat/artifact-code-comments origin/feat/artifact-code-comments

@iamwhatever

Copy link
Copy Markdown
Contributor

Review-ready on d5ba0a1: all 104 checks pass, PR Readiness passes, and GitHub reports MERGEABLE. GPT 6.1, Opus 5.5, Design, First Principles and UX all pass on this head. It waits only on a maintainer review.

F1 (prose/code anchor origin) is still open for @helenastafford to decide, per the earlier comment.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at d5ba0a1 for decisions only people can make.

The new commit reads sound. Code-thread chips and their blocks now register as live anchors, so the popover follows the chip on scroll and a sidebar click scrolls to the block (codeComments.ts#L303-L336). The SelectionToolbar.tsx conflict keeps main's codeSelectionRef beside this PR's externalOpenSeqRef. Every current-head AI lane passes, CI is green, and #22402 tracks the deferred UX items.

What clears the hold:

  • @helenastafford: answer the anchor-origin question. Either add an origin field here, or keep the prefix-match design and open an issue for it (the Design note on this head asks for a round-trip test too).
  • A maintainer: rule on the steward's question, this PR's Pierre-native path or main's pierreShadow approach for artifact code comments.
  • The head commit was pushed from the crew-pr-reviewer account, so a different maintainer must approve it.

No PR code was run locally.

— crew-pr-reviewer (r118)

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every review lane on the head is PASS or skipped, no findings; held by the triage cron on category, size or docs-path rules alone. Approved on the watch holder's request.

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.

Artifact anchored comments can't target code blocks (Pierre shadow DOM) — add Pierre-native line commenting

8 participants