Skip to content

fix(file-viewer): find and comment on text inside fenced code blocks - #21133

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
presidentarrow:fix/find-in-code-blocks
Oct 20, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
presidentarrow:fix/find-in-code-blocks

Conversation

@presidentarrow

@presidentarrow presidentarrow commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: In a markdown file's preview, Cmd/Ctrl+F finds text inside fenced code blocks, and selecting that text opens the comment box.

Open a markdown file that has a fenced block, press Cmd/Ctrl+F and search for a command that appears only inside the block: the bar says "No results". Drag over the same text and no comment box appears, so the block cannot be commented on. Edit mode already works.

Why it matters

READMEs, runbooks and skills keep their commands in fenced blocks, so those are the strings people search for and want to comment on. Today they have to switch to Edit mode to find one, and cannot comment on one at all.

Not a goal

  • Underlining a comment made on code, or its hover tooltip. The comment is saved with its quote; only the paint in the document is missing.
  • Find in the chat transcript's code blocks. AssistantMessage has the same gap and its own search.
  • Artifact pages and the chat transcript. They pass no codeSelection, so they behave as before. The artifact pages' comment anchors cannot resolve a drag inside a code block, and the chat has no comment box. SelectionToolbar takes such a drag only from a host that passes codeSelection, and only the file panel's preview does.
  • In-file find for code files and diffs, which fix(dashboard): stop chat search answering Cmd/Ctrl+F over a code/diff side panel #17381 left unbuilt on purpose.
  • A source line for a selection whose first row cannot be told apart from another copy in the file. The rendered block carries no data-sourcepos, so that comment keeps its quote and carries no line.
  • The find bar leaving the screen when a match sits in the last screenful of a document. A prose-only search does it too, and this PR does not change that scroll.

What changed (motivation → approach → change)

Find and the comment box work inside fenced code blocks in the preview. They did not before, because Pierre, the code renderer, draws each fenced block into an open shadow root, and two things stop at it. The find's TreeWalker never enters a shadow root. A drag inside one reaches the document as a collapsed selection (both ends move to the host's parent), which SelectionToolbar drops as empty.

utils/pierreShadow.ts reads a block one source line at a time, so a phrase can cross Pierre's token spans, and it skips the line numbers beside the code. It resolves a drag with Selection.getComposedRanges. The find (useMarkdownPanelFind.ts) matches through it. SelectionToolbar.tsx uses it to open the box for a host that passes codeSelection (the file panel's preview does; its diff view, the artifact pages and the chat do not), and MarkdownPanel.tsx to anchor the comment and to quote its line, counted in the file's own text and not in the fenced copy the preview draws of a code file. The comment carries inCode (InlineComment in CommentOverlay.tsx) so it is not underlined on the first matching prose, and a line and column only when the first row of the selection can be told apart from every other copy of it in the file. findUniqueCoords (markdownPanelSourcePos.ts) looks up only that row, so a block inside a list or quote still gets a position, and it reports the column of the first visible character, so the indentation a drag started on does not shift it. A comment draft is filed under the position of the passage's first visible character: which code block it is in (a diff fence counts once per file, each marked by DiffBlock.tsx), then the row's own line number and the column in it (codePassagePosition in pierreShadow.ts, negated so it never meets a prose offset). A block still drawn as its plain copy gives the key its highlighted copy gives, so a draft typed before the swap is found after it. The key does not depend on which blocks have painted, whether a diff fence holds a Pierre host, or which rows the page holds, so the same command in two blocks keeps two drafts. A column or row that does not fit its field (a line of 100,000 characters) takes the shared fallback slot, which no placed passage uses. The box follows scroll through the live range. website/docs/frontend-conventions.md records which browsers each half needs.

A find survives Pierre's late swap of a block. WarmSwap shows a plain copy first, parks the highlighted copy beside it, then swaps them, which left a find holding ranges on nodes that were gone. The find skips the parked copy (its text would count twice), and watchText finds again on the highlighted copy after the swap, on the same match and without scrolling the reader. The current find match in a code or diff block takes one dark text colour (highlights-and-page-zoom.css), since Pierre's token colours disappear on the orange fill; prose is unchanged.

Backwards compatibility

Compatible: nothing accepted before is rejected; InlineComment gains an optional inCode, so saved drafts load as before.

Removes nothing: every prose match and selection behaves as before, and every other SelectionToolbar host behaves as before because the code-selection path is opt-in.

Tests

File Locks in
utils/pierreShadow.test.ts Lines read across tokens; no gutter or style text; a parked copy is skipped; the watcher fires once a frame, re-attaches to new blocks and stops; a passage's position by block, row number and column, whether the block is plain, parked or shown and whichever rows are rendered; each file of a diff fence counted as its own block, with or without its host; a plain copy of a fence gives the key its highlighted copy gives; a column, row or block count that does not fit its field gives no position, in the plain copy and the highlighted one
test/useMarkdownPanelFind.test.tsx Phrase across tokens; prose and code in order; the swap keeps the match, paints the highlighted copy and does not scroll; case, full screen, closing
test/SelectionToolbar.codeBlock.test.tsx The box opens on a drag in code for a host that opts in, hangs from the code's range, restores nothing on Escape and follows scroll; the same text in two blocks keeps two drafts, also when the earlier block paints after the later draft was typed, or a diff fence ahead of it loses its host; the files of one diff fence keep separate drafts; a draft typed over a fence's plain copy is found again over its highlighted copy, and the other way round; a passage outside the field files under the shared fallback slot and the next row under its own; a host that did not opt in, a plain diff body, ordinary selections and engines without the API are unchanged
test/CommentOverlay.test.ts findUniqueCoords: the first visible character of an indented selection, a selection that starts on a newline, CRLF files, blocks in a list or quote, and no position for a first row another copy shares or for absent text
test/MarkdownPanelCodeBlock.test.tsx Through the real panel: the find paints the phrase; the open box paints the dragged passage; a comment on code keeps inCode, carries the line and column of its first row only when that row can be told apart from other copies, and is not underlined in prose; a code file's comment quotes its own line when sent, from the highlighted copy or the plain fallback; the diff view opens no box in the side panel or in full screen
test/DiffBlock.test.tsx Each file of a patch sits in one layout-neutral section, while frames stream, in plain mode and painted; a one-file patch has one
test/findCurrentMatchContrast.test.ts The current find match in a code or diff block takes one dark colour that reads at least 3:1 on its fill in every built-in palette; the global rule keeps its fill and no colour

Tests are 2,448 of the 2,890 changed lines. The eight files this PR adds or extends pass in five shuffled orders (seeds 11, 23, 47, 91, 2026). Each production edit was broken one line at a time (129 scripted mutations): 128 turned a test red, and the other is equivalent (it hands findUniqueCoords the trimmed selection, which it trims again).

Manual verification

Chromium, against a gateway built from this branch, on a generic markdown file:

  • Before the change, on main at 0a008292c9: a phrase from the prose gives "1 of 1", while npm run build, which sits only in a fence, gives "No results". A drag over it opens no box.
  • npm run build, which sits only in a fence: "1 of 1", and the painted range is exactly that text.
  • docker build, once in prose and once in a fence below the fold: Enter steps to the second. That block is still a plain copy when it is reached, then Pierre swaps it in. The bar keeps "2 of 2" and the match stays painted.
  • Find opened the instant the file appears: it starts on the plain copy and ends on the highlighted one, with the count unchanged.
  • A file whose only digits are the line numbers: searching a digit gives "No results".
  • Drag over npm run build: the box opens, Copy puts npm run build on the clipboard, Add comment lists the comment with its quote.
  • With the box open the dragged code is tinted as a prose phrase is, and the tint goes when the box closes.
  • Scrolling the panel 90 px with the box open moves the code and the box by 90 px.
  • In full screen: the find says "1 of 1" on the fence, and a drag over its code opens the box and saves the comment.
  • The same file as a diff (an untracked file in a git repository): a drag over its code opens no box, while the same drag in the preview does.
  • The same command in two fenced blocks of one file: a draft typed on the first is not offered on the second after a reload, clearing the second leaves the first's draft, and selecting the first again restores it. With four such blocks and a jump straight to the last, a draft typed there is not offered on the first block once that one has painted. With a diff fence ahead of three identical code fences, a draft typed on the second, then plain diffs turned on and a reload, is not offered on the third.
  • A drag over two rows of a plain block: line 30, column 5, the first visible character. Over a list item's fence: line 16, column 4.
  • A drag over rows another block repeats, or over a tab-indented fence: the comment keeps its quote and carries no line.
  • With Pierre's chunk held back so the fences stay plain copies: a draft typed over mycli rm NAME --force in a plain copy comes back over the highlighted copy after a fresh load, the text typed there comes back over the plain copy, and the same passage in the second block opens empty. Scrolling the panel by 120 px moves a box opened over a highlighted copy, or over a plain copy that stays plain, by 120 px; a box opened over a plain copy that then swaps does not move.
  • A diff fence of two files that share a first line: a draft typed on that line in file one is not offered in file two after a reload, the two drafts are stored apart, and file one's comes back. The code fence after it opens empty.
  • The current find match in code, dark theme: the token colours read 1.03:1 to 2.44:1 on the orange fill, and black reads 6.07:1 (at least 5.84:1 in every built-in palette). A prose match is unchanged.

Not checked: Firefox and Safari.

Screenshots / video

Before, on main: the command in the fence gives "No results".

Find bar reading No results for npm run build, which sits inside a bash block

After: the same search finds it.

Find bar showing 1 of 1 with npm run build highlighted inside a bash block

Stepping to a fence below the fold, after Pierre swapped it in:

Find bar showing 2 of 2 with docker build highlighted in prose and in the fence below

The drag before and after, the comment box over code, and the comment added

A dragged line in a bash block on main, with no comment box

Comment box open above a selected line in a bash block

One pending comment quoting npm run build

Related Issues

Closes #21124
Closes #21838
Refs #21837 (the underline for a comment on code, listed under Not a goal)

Pattern harvest

Rule candidate: agents-md
Pattern: a TreeWalker or Selection read over a subtree that can hold a Pierre block stops at its shadow root; read it through utils/pierreShadow.ts.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|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

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 16, 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 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of fac04a158d02c828b20b2bcabec8c61c2477f579 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Before merge, check that watchText's subtree observer doesn't re-run the whole find every frame on a large preview that is still updating.

[DESIGN-REVIEWED] fac04a1

Description read

[DESCRIPTION-READ] 1af98f9eaa890207ca8a9194ea92574add27168015f3fbc6b762b44455b1a887

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 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of fac04a158d02c828b20b2bcabec8c61c2477f579 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

A comment saved on code leaves no mark in the document, while prose comments are underlined, so code comments are only visible in the pending list.

Watch

  • Code comments leave no trace in the file. The diff skips them when painting comment underlines (if (!comment.anchor || comment.inCode) continue). In attachment-06, npm run build looks the same after the comment as before it; the comment only appears in the "1 comment pending" list at the bottom. Prose comments get an underline and a hover. Someone who comments on several commands can't see which ones they've already covered without scrolling to that list. This will happen to everyone who comments on code, every time. It's friction rather than a failure, since the saved comment keeps its quote. The PR's "Not a goal" section defers this on purpose, so a human should accept that gap knowingly before merging. The smallest fix is a gutter dot or a faint row tint on the commented code line.
  • Repeated commands get no location. When the first row of the selection appears more than once in the file, the comment is saved without a line (findUniqueCoords returns undefined). In a runbook that repeats npm ci, the comment the agent receives names the text but not which copy, and nothing in the UI tells the user that. It only happens with duplicated commands, but then it happens every time. The smallest fix is to show "(location unknown)" on that comment's row in the pending list.

The screenshots show every changed element: find with no results before the fix, a find match inside code, a find spanning prose and code, the comment box over code, and the pending comment. No first-time reader has looked at them, so this lane can't go higher than CONCERNS.

[UX-REVIEWED] fac04a1

Description read

[DESCRIPTION-READ] ac7ffe9f968af1b113f46fa45c394a429cba063e04b813dd7d184119e059b0ee

That sha256 names everything this verdict read: the PR description, plus the 9 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 Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of fac04a158d02c828b20b2bcabec8c61c2477f579 via the fork AI-review pipeline — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

Before merge, check that a comment dragged over a code file's plain fallback still quotes the right line now that send quotes from content instead of displayContent.

Inventory (9 items) — 9 justified

Intent: let a reader find text in a markdown preview's fenced code blocks and comment on it, as Edit mode already allows. This is a FIX.

  1. Cmd/Ctrl+F in the preview finds text inside fenced code blocks, including a phrase that spans syntax tokens — justified
  2. Dragging over code in the file panel's preview opens the comment box; artifact pages, the chat and the diff view are unchanged — justified
  3. A comment made on code is saved marked as code and is no longer underlined on the first matching prose — justified
  4. A code comment carries a line and column only when its first row is unique in the file — justified
  5. Comment drafts on code are kept per block, row and column, and survive the swap from plain to highlighted rendering — justified
  6. An open find stays on the same match, without scrolling, when a block's highlighted copy swaps in — justified
  7. The current find match inside code or diff blocks is drawn in one dark text colour — justified
  8. Sent comments on a code file quote lines from the file itself, not from the fenced copy the preview draws — justified
  9. Each file of a diff fence is now wrapped in a layout-neutral section; the browser support floor is documented — justified

[FIRST-PRINCIPLES-REVIEWED] fac04a1

Description read

[DESCRIPTION-READ] 7cd7260423d9db36166d94219d1af85546451df0242cc2b46579b3f04b426d04

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 Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed fac04a158d02c828b20b2bcabec8c61c2477f579 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fac04a1

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed fac04a158d02c828b20b2bcabec8c61c2477f579 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fac04a1

cruisercohen
cruisercohen previously approved these changes Oct 17, 2026

@cruisercohen cruisercohen 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.

Thanks @presidentarrow, this is a careful fix with a very thorough description, and thanks for the before/after evidence.

Approving on 7e76595. The cause matches #21124: Pierre draws each fenced block into an open shadow root, the find's TreeWalker never enters it, and a drag inside one reaches the document as a collapsed selection. pierreShadow.ts reads each [data-line] as one run, so a phrase can cross token spans while the gutter numbers stay out, and getComposedRanges gives the toolbar the real range.

Checked locally:

  • The 4 new test files pass (73). With the 4 changed components put back to main's versions, 23 of them fail.
  • The related suites (SelectionToolbar, MarkdownPanel, CommentOverlay, the find and highlight tests, artifact comments, AssistantMessage) pass: 34 files, 817 tests. eslint and tsc -p tsconfig.app.json --noEmit are clean.
  • Edge cases I looked at: the global regex starts each run at index 0, because a failed exec resets lastIndex. The find paints through CSS highlights, so watchText's observer cannot fire on its own repaint. A multi-line drag stays inside the content column, so it does not pick up line numbers. The code-selection path is opt-in for the file panel's preview only, and the diff view keeps ignoring such a drag.

The UX lane's two notes (no underline for a comment on code, and no box over code in browsers without getComposedRanges) are both covered by your Not-a-goal list and the conventions doc, so they read to me as follow-ups.

I approved the waiting workflow runs, as you asked, and re-ran Cross-Platform Portability once after it timed out during checkout. Approving on the code; CI still running at 10:26 PDT: 85 checks pass, none failed, and two backend test shards and PR Readiness are still pending.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 17, 2026
@presidentarrow

Copy link
Copy Markdown
Contributor Author

UX note "A comment on code leaves no mark in the document" (span=236a366bb012): not changed in this PR.

It is listed under "Not a goal" in the description: the comment is saved with its quote, and only the paint in the document is missing. The skip is deliberate. MarkdownPanel.tsx:846 (if (!comment.anchor || comment.inCode) continue) keeps a code comment from underlining the same words in prose elsewhere in the file, which the First Principles lane listed as justified.

Painting a mark inside a fenced block needs an anchor that survives Pierre swapping in the highlighted copy of the block, so it is a design of its own. The approving review reads this note as a follow-up. I can open an issue for it if you want one.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

Browser coverage, raised by three lanes: UX ("In older browsers, dragging over code does nothing and says nothing", span=889476718201), Design (check in Safari 17.x that the older getComposedRanges(...shadowRoots) signature degrades to "no box" and does not open one on the wrong range) and First Principles (check the code-block drag on Firefox and Safari).

Covered: shadowSelectionRange in website/src/utils/pierreShadow.ts returns null, so no toolbar opens, when getComposedRanges is missing, when the call throws (where an older call shape is expected to land), when it reports no ranges, and when the range is not wholly inside one shown code block. pierreShadow.test.ts has a test for each. Prose selection is unchanged, and the browser floor (Chrome/Edge 137, Safari 17, Firefox 142) is in website/docs/frontend-conventions.md.

Not covered: I did not run a real Safari 17.x or Firefox, as the description says under "Not checked". A notice for older browsers would be a new surface outside this PR's goal, and the approving review reads the missing-box note as a follow-up.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

Opus finding (span=62c33351e01e): the stored column of a code comment lands on leading whitespace. Confirmed, and not changed in this PR.

In resolveSelectionCoords (MarkdownPanel.tsx, lines 522 to 526; the lane cites line 93), content.includes(raw) sends the untrimmed selection to findCoords, so a drag that starts on a space stores the column of that space. The saved anchor is trimmed, and the line is right. Current main does the same raw-first lookup for non-code selections (lines 511 and 512), so this follows the existing convention.

The fix is two lines and one test. A push may dismiss the approval on 7e76595 and would likely send the fork workflows back to waiting for approval, so I held it. @cruisercohen, default: merge as is and take the column fix as a follow-up. Say if you want it pushed in this PR instead.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

@cruisercohen thanks again for the approval. PR Readiness passed at 17:42 UTC and there are 104 checks, none failing. GitHub shows UNSTABLE only because the Sensitive Change Review run created by your approval is waiting for approval; it is the one check suite that is not green. Could you merge when you have a moment?

@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.

Requesting changes on 7e76595. The code looks sound, but two follow-ups are deferred and neither has a linked issue.

The fix is right: Pierre draws fenced blocks into shadow roots, and pierreShadow.ts now reads each [data-line] as one run and resolves drags with getComposedRanges. When that API is missing, throws or returns a range outside one shown block, the code returns null, and the code-selection path is opt-in for the file panel preview only. CI on this head is green, and every lane item has a reply.

Deferred items that need an issue (or a fix in this PR):

  1. A comment on code leaves no mark in the document, because the underline pass skips inCode comments (MarkdownPanel.tsx#L846). The UX lane asked to track it, and your reply offers an issue.
  2. Opus span=62c33351e01e: a drag that starts on a space stores the column of that space, because the untrimmed raw is the findCoords needle (MarkdownPanel.tsx#L524). You confirmed it and held the fix.

To clear this, either push the column fix with its test, or open one issue per remaining item and link each in the PR description. A new push needs a fresh review.

— crew-pr-reviewer (r110)

@presidentarrow

Copy link
Copy Markdown
Contributor Author

@cruisercohen the crew reviewer's request for changes is what keeps this PR blocked. It asks for a fix or a tracking issue for the two items I had deferred, so I filed one issue for each:

I did not push the column fix, because a push would dismiss your approval on 7e76595cbc and send the fork workflows back to waiting for approval. Could you dismiss that review, given your approval and the two issues?

@cruisercohen

Copy link
Copy Markdown
Contributor

@presidentarrow Thanks for filing #21837 and #21838. We won't dismiss iamwhatever's review: clearing a maintainer's change request is his call. His review also asks for each issue to be linked in the PR description, and the description's Related Issues section still lists only #21124. Once both are linked there, his re-review is the next step. Our approval on 7e76595 stands.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

@cruisercohen both issues are now listed under Related Issues as Refs #21837 and Refs #21838, so they stay open when this merges.

@iamwhatever that covers the two items in your review. The edit queued five workflow runs (Code Review, Issue Gate, GPT 6.1 Review, Sensitive Change Review and Screenshot Evidence) that are waiting for approval.

@presidentarrow
presidentarrow force-pushed the fix/find-in-code-blocks branch from 35d291b to fac04a1 Compare October 20, 2026 11:23
@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 Oct 20, 2026
@presidentarrow

Copy link
Copy Markdown
Contributor Author

Pushed fac04a1. Against 35d291b the change is one new test file, website/src/test/pierreShadow.realPierre.test.tsx, for the Design lane's first Watch item (span ff29fa39146b); no production file changed.

The commit is also rebased onto main 4be2da2, because main moved by one commit while I tested (a Windows favourites-read fix touching project_lists.py, chat_handlers.py and test_favorite_projects.py, none of which this PR changes). The patch-id of this PR's commit is the same before and after the rebase, and website/ is byte-identical to the tree I ran the checks on.

GPT 6.1 and Opus 5.5 reported no findings on 35d291b. Design, First Principles and UX reported CONCERNS; each item has its own comment below.

The push re-queued the fork workflows: 19 runs are waiting for approval. The last round was approved at 10:01 UTC, and I would be grateful if a maintainer could approve this one too.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

Design Watch "No test renders real Pierre" (span=ff29fa39146b) on 35d291b: fixed in fac04a1. The lane was right: every fixture was built by hand in test/pierreDom.ts, so a Pierre release that renamed data-line or moved the line numbers could have passed the whole suite.

pierreShadow.realPierre.test.tsx renders a real CodeBlock through the lazy Pierre chunk and checks only what pierreShadow.ts reads:

  • the shown shadow root holds one [data-line] row per source line, and each row is [line number, exact source text], so a line number inside a row fails it;
  • searchRuns returns one run per source line with exactly that text, and matchRanges finds rm NAME, a phrase across Pierre's tokens;
  • codePassagePosition for ls on the second row is 200006 (line 2, column 6).

I broke pierreShadow.ts six ways and ran only this file, restoring each time and comparing the file byte for byte:

  • CODE_LINE renamed: 2 of 3 fail (expected [] to deeply equal [ 'mycli rm NAME', 'mycli ls' ]). The third checks Pierre's own output, which still uses data-line, so it correctly stays green.
  • CODE_HOST renamed: 3 of 3 fail.
  • The gutter added to the find's runs, and CODE_LINE also matching the gutter numbers: each fails the find test (expected [ '1', '2', 'mycli rm NAME', … ] to deeply equal [ 'mycli rm NAME', 'mycli ls' ]).
  • The line weight off by one: expected 100006 to be 200006.
  • The column left out of the key: expected 200000 to be 200006.

The test runs in about 2.5 s per case because the block is shown at WarmSwap's 2.5 s deadline (happy-dom lays nothing out, so the earlier height check never passes). The wait polls for the rows with a 10 s ceiling, under the suite's 15 s test timeout. It passed 10 of 10 alone, and in five shuffled orders together with the seven other test files this PR touches (223 tests each).

I did not snapshot Pierre's markup, so a harmless upgrade stays green.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

Design suggestion "a host-supplied resolver" (span=05d12f795e0c) on 35d291b: the same suggestion as span 312b93bd2a6b on b05066d, and my answer is the one in the comment above (issuecomment-6288243128): not taken in this PR. In short, SelectionToolbar.tsx names none of .code-block, [data-diff-section] or pre.pierre-plain (a search of the file finds none); it imports three functions from utils/pierreShadow.ts, and nine other mounts in four files share the component. A resolver would move those three calls into MarkdownPanel.tsx and add a prop type for one host. I will do it here if the reviewers want it.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

UX Watch "Older browsers fail silently" (span=d4316b141d1d) on 35d291b: the same item as span ccbc741e23aa on b05066d, and the question I put there is still open (issuecomment-6288245416): do the reviewers want a hint for browsers without getComposedRanges in this PR? It would be a new user-facing string, so it needs a catalog key and a decision on where it shows.

The lane adds that the Tip banner "Select any text to add inline comments" promises something that will not happen there. The string is components.markdownPanel.select_any_text_to_add_inline_comments_then_subm (i18n/locales/en.json), shown by MarkdownPanelBody.tsx; this PR changes neither. In the code, a prose selection goes through window.getSelection() (SelectionToolbar.tsx:607) and only a drag inside a code block calls getComposedRanges, behind a typeof check and a try/catch (pierreShadow.ts:218, :221–:229). So from the source the banner stays true for prose and not for code in those browsers. I have not run it on Chrome before 137 or Firefox before 142.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

UX Watch "This lane had no blind read" (span=616ca1f4325f) on 35d291b: nothing in the diff changes this. The lane read attachments 01–06 and wants a first-time reader to look at the find highlight in code, the comment box over code and the pending code comment. I can supply the screenshots, which are in the description, but not the reader. If a reviewer is willing to open the preview on a markdown file with a fenced block and say what they expect to happen, I will act on it.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

UX Watch "A code comment leaves no mark in the document" (span=ed1e9d57c632) on 35d291b: the same item as span c14381723c7b on b05066d and span bc280d3d06dc before it. Out of this PR's goal: ## Not a goal lists "Underlining a comment made on code, or its hover tooltip", and the lane itself says "The PR lists this as out of scope." It is tracked in #21837. A gutter dot, which the lane suggests as a first step, is the item answered in issuecomment-6286615636.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

First Principles "Not justified as shipped", item 6 (span=648bdfbdd35f) on 35d291b: kept, for the reasons in the comment on the same item at b05066d (issuecomment-6288243175, span 152729680649): the shared slot is the state the GPT 6.1 lane blocked, with a reproduction (span 23dbf0c7f905), and a blocking lane outranks an advisory one. A reviewer who wants per-passage drafts dropped is amending the Goal, which the lane names as what clears this item ("a human amends the Goal"); I will do it if asked.

One correction to the lane's evidence. It cites SelectionToolbar.tsx:1016 as the slot an externalSelection with no offset already gets. Line 1016 is a comment about a revoked selection; the slot is line 1046, savedSelectionRef.current = { start: externalSelection.start ?? -1, length: 0 }. It is the same -1 slot, so the lane's point about cost stands.

GPT 6.1 and Opus 5.5 reported no findings on this head, so the draft-key fix for the long-row finding is accepted by both.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

First Principles "Not justified as shipped", item 7 (span=8ec347be9115) on 35d291b: it goes or stays with item 6, and the lane says so ("the only reader is the item 6 key"). I checked that claim: the only places that name data-diff-section outside tests are DiffBlock.tsx:369, where each file section is written, and pierreShadow.ts:26 and :29, where it joins the unit selector the key counts. It exists for a reason item 6 does not cover on its own: a diff fence of several files draws one Pierre host per file inside one .diff-block, and counting the wrapper made the same row and column in two files share a key (the GPT 6.1 finding at span 995396e9afaa on 1ba1b1d, in its multi-file form). The section div is display: contents, so it adds no layout box. If the key is removed, so is this, and DiffBlock.tsx goes back to a Fragment.

@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
@presidentarrow

Copy link
Copy Markdown
Contributor Author

UX Watch "Repeated commands get no location" (span=c7922df0aba2) on fac04a1: the behaviour is as the lane reads it, it is listed under ## Not a goal, and the marker it suggests is a new user-facing string, so I am asking before adding one.

What the code does. findUniqueCoords (markdownPanelSourcePos.ts:42, called at MarkdownPanel.tsx:526) returns no position when the selection's first row occurs more than once in the file. That is deliberate: the rendered block carries no data-sourcepos, and a line for the wrong copy is worse than none. MarkdownPanelCodeBlock.test.tsx pins it ("puts no line on text that occurs twice in the file, rather than the first occurrence's"). The comment keeps its quote: the message to the agent reads 1. ("npm ci"): "note", with no line and no surrounding-text snippet (formatCommentsMessage, CommentOverlay.tsx:182–:192).

The lane is also right that nothing in the UI says so. The pending row (CommentRow, CommentOverlay.tsx:60) shows the quoted text and the note for every comment, with or without a line.

Question for the reviewers: do you want a "(location unknown)" marker on that row in this PR? It needs a catalog key in every locale and a decision on its wording, and CommentList is mounted only by MarkdownPanelBody.tsx, so it would not touch another host. If yes, say so and I will add it with its key; otherwise I would leave it where ## Not a goal puts it.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

UX Watch "Code comments leave no trace in the file" (span=3a7cc0a02b71) on fac04a1: the same item as span ed1e9d57c632 on 35d291b, c14381723c7b on b05066d and bc280d3d06dc before it, and my answer has not changed: out of this PR's goal (## Not a goal lists "Underlining a comment made on code, or its hover tooltip"), tracked in #21837. The gutter dot or row tint the lane offers as the smallest fix is answered in issuecomment-6286615636.

The lane closes this item with "a human should accept that gap knowingly before merging". That acceptance is for the maintainers; I have not asked for it beyond this comment, and I have changed nothing for it.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

Design Review (PASS) check "that watchText's subtree observer doesn't re-run the whole find every frame on a large preview that is still updating" on fac04a1: it can re-run once per frame, and I measured what that costs; I have not measured a streaming file.

This is the same check as r113 item 1, answered in issuecomment-6281680047. watchText is byte-identical on this head to the one I measured (same 20 lines on 3f62972 and fac04a1), so those numbers still apply. It runs only while the find bar is open with a term, and at most once per frame: watchText (pierreShadow.ts:240) schedules its re-run through requestAnimationFrame. Its one caller is useMarkdownPanelFind.ts:163. Measured in Chromium on a 120-fence file with 360 matches, as main-thread busy time over 3 s: find closed 0.8% and 2.9% idle; find open 0.6% and 0.7% idle, 13.2% and 14.6% with a DOM change every 100 ms, and 56.7% and 57.3% with a change every frame. That is about 7 to 10 ms per re-run.

So a preview that changes every frame with find open would keep the main thread about 57% busy. I used a synthetic mutation source, not a streaming file, so I am calling the bound acceptable for a preview and not measured for every source. If the reviewers want a cheaper bound (for example debouncing the re-find while a source is streaming), say so and I will add it with a test.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

First Principles (PASS) check "that a comment dragged over a code file's plain fallback still quotes the right line now that send quotes from content instead of displayContent" on fac04a1: it does, and a test pins it for that exact path.

MarkdownPanelCodeBlock.test.tsx has two tests that drag a selection in a code file and read the message the panel sends: "quotes the commented line of a code file, not the line above it" (highlighted copy) and "quotes the commented line of a code file from its plain fallback" (the plain copy, dragInPlainCode). Both expect the literal 1. (line 2, col 11, "pick(a)" in "const b = pick(a)"): "note" for a three-line file.

I checked that they can fail. With formatCommentsMessage(filePath, comments, content, extraPrompt) at MarkdownPanel.tsx:693 changed back to pass displayContent, both go red (expected '[Document feedback on /tmp/notes.ts —…' to contain '1. (line 2, col 11, "pick(a)" in "con…'), and with the file restored byte for byte both pass. I ran only those two tests; I did not click through a code file in a browser for this answer.

@cruisercohen cruisercohen 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.

Re-reviewed fac04a1. Approving.

  • The column-100,000 aliasing is fixed (in 35d291b; fac04a1 leaves that code byte-identical). packedCodePosition refuses a column at or past 100,000, a row at or past 10,000,000, and a packed number that is not a safe integer, so those passages take the shared fallback slot instead of another passage's key. With the repro from the finding (a 100,000-character row followed by target, then target on the next row), the first target now gets no position and the second keeps 200000, in both the highlighted and the plain copy. On b05066d both got 200000. Each clause fails its own tests when I remove it: the column check fails 4 (3 in pierreShadow, 1 in SelectionToolbar), the row check 1, and the safe-integer check 1.
  • The two-file fix from b05066d is intact: going back to counting the whole .diff-block still fails the same 4 tests.
  • The new real-Pierre test answers Design's note: renaming the row selector in pierreShadow.ts fails 2 of its 3 tests, as you described.
  • Locally, tsc, eslint and i18n:check are clean, the PR's 8 test files pass (223 tests), and 164 related test files passed on 35d291b (2,855 tests). GPT 6.1 and Opus 5.5 report no blocking findings, and every CI check on this head passes.
  • On the older-browser hint: I would not add it in this PR. On those browsers the box behaves as it did before this change, so nothing regresses, few users are on those versions, and the hint would be a new string in every locale. frontend-conventions.md already records the limit.

@presidentarrow

Copy link
Copy Markdown
Contributor Author

UX Watch "Older browsers fail silently" (spans ccbc741e23aa on b05066d and d4316b141d1d on 35d291b): not adding the hint, as cruisercohen's review of fac04a1 (12:55 UTC) says: the box behaves on those browsers as it did before this change, so nothing regresses, few users are on them, and the hint would be a new string in every locale. frontend-conventions.md records the limit. No change in this PR.

Still open, and not acted on: whether a "(location unknown)" marker is wanted on a pending comment whose first row repeats in the file (issuecomment-6290400589), and whether SelectionToolbar's code selection should become a host-supplied resolver (issuecomment-6288243128).

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 20, 2026
@presidentarrow

Copy link
Copy Markdown
Contributor Author

PR #21133 has everything it needs except one review decision.

Could one of you dismiss that review, or ask it to re-review, and then merge? The open items left are advisory questions to the reviewers, listed in the what-is-left note (comment 6275056217).

@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 fac04a1. This replaces our r110 change request.

Both r113 items are answered. Draft keys now count the .code-block / [data-diff-section] unit, which is always present, so toggling plain diffs no longer shifts a later fence's key (pierreShadow.ts L99-L105). The watchText cost is measured and bounded to one re-find per frame. Find paints through CSS.highlights, so a re-find never mutates the DOM it watches.

Every current-head lane item has its own reply. The missing mark on a code comment is tracked in #21837. On your open question: a "(location unknown)" marker is not needed for this PR, because the comment still carries its quote and the limit is stated under Not a goal. CI is green, and cruisercohen approved this head.

— crew-pr-reviewer (r115)

@iamwhatever
iamwhatever merged commit 22e02d9 into kirodotdev:main Oct 20, 2026
100 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

3 participants