Repository navigation
Description
Problem
When reviewing a document in the artifact viewer (the markdown preview backed by packages/artifact-canvas), there is no visual anchor that follows the pointer. Long prose paragraphs give the eye nothing to lock onto, so the reader loses their place as the pointer moves across a line and has to re-find it. Owner request (2026-10-13).
Expected
- As the pointer moves over prose, the word under the pointer gets a soft rounded highlight (a muted pill behind the word, same tone family as the existing muted/hover colours, legible in both light and dark themes). It follows the pointer word by word with no lag the eye can notice and no flicker between adjacent words.
- The highlight is purely visual. It does not change the DOM text, selection, copy, the review-marker anchoring (
data-line), the injected comment cards, or the "+" add-comment affordance (artifact-canvas: full-row '+' affordance (GitHub-diff pattern) — structurally eliminate the hover travel-gap bug class #1343), all of which keep working exactly as today. - It clears when the pointer leaves the canvas body, when a drag-selection is in progress (left button held), and while the comment composer has focus. It does not render over injected comment cards, the composer, or the overlays (minimap, reading-mode toggle, keyboard help).
- Works in both reading modes (vertical and horizontal columns) and at every preview font size / line height.
- Switchable: a
codev.markdownPreview.hoverWordHighlightsetting (boolean). Default on.
Fix shape (hypothesis; verify in source)
The canvas body is imperatively owned (ArtifactCanvas.tsx, the bodyRef effect sets innerHTML and later injects comment cards), so the highlight must not wrap words in spans: a DOM rewrite would break data-line anchoring, marker verification and the card injection. Two DOM-free options, builder picks and states it in the plan:
- Overlay rects (recommended, matches the rounded look). On the existing
onMouseMovepath (activateFromPointer, throttled to one animation frame), resolve the caret at the pointer withdocument.caretRangeFromPoint(x, y)(orcaretPositionFromPointwhere available), expand the offset to word boundaries in the text node withIntl.Segmenter(undefined, { granularity: 'word' })(fall back to a\p{L}\p{N}run), build aRangefor the word, and paint one absolutely positioned,pointer-events: noneelement pergetClientRects()fragment, positioned relative to the body wrapper. Dedupe on (text node, start, end) so a move within the same word does nothing. Clear onmouseleave, onbuttons & 1, and on scroll (recompute from the last pointer position or clear). - CSS Custom Highlight API. Register a
Highlightholding the wordRangeand style it with::highlight(codev-hover-word). Zero layout work, but::highlightcannot draw rounded corners, so the look is a square tint. Acceptable only if the owner is fine with that at the dev gate.
Either way: one theme token (for example --codev-canvas-hover-word-background) with light and dark values in default-theme.css next to the existing tokens; the vscode host maps it like the other canvas colours. Skip the highlight inside pre/code (where a word is rarely the reading unit) unless the owner asks otherwise.
Plumbing: a new optional canvas prop (for example hoverWordHighlight?: boolean, default true) on the canvas props type, fed by the host from the setting the same way fontSizePx / lineHeight reach the preview (preview-provider.ts). Setting change re-posts to the open preview like the other preview settings.
Decisions for the owner
- Default on (proposed) or off.
- Apply inside code blocks or skip them (proposed: skip).
- Headings and link text: included (proposed) or excluded.
Verification
Dev gate, real path: open a long plan in the preview, move the pointer across a paragraph, confirm the pill follows word by word with no flicker; check both themes and both reading modes; drag-select across lines and confirm no highlight renders and the selection is unaffected; hover a block that carries comment cards and confirm the "+" affordance, the cards and the composer behave as before; toggle the setting off and confirm it disappears without a reload.
Protocol
PIR (visual feel is tuned at the dev gate). Touches packages/artifact-canvas and apps/vscode/src/markdown-preview only; no contract surface. Owner: vscode architect.
Activity
amrmelsayed commentedon Oct 12, 2026
On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).
[PIR #1802] Plan draft
[PIR #1802] Plan revised: three highlight styles, cursor choice, Read…
[PIR #1802] Plan: None as first highlight option in Reading Aids picker
[PIR #1802] Plan: rename cursor setting to readingCursor; Cursor sect…
[PIR #1802] Plan: add I-beam cursor option
[PIR #1802] Canvas: hover reading aid (word, line, paragraph) and pro…
[PIR #1802] VS Code: Reading Aids picker and hoverHighlight / reading…
[PIR #1802] Thread: implement notes
[PIR #1802] Dev-gate round 1: line styles, lineParagraph default, pic…
[PIR #1802] Dev-gate round 2: stronger line band and paragraph tint i…
[PIR #1802] Review + retrospective
[PIR #1802] Address consultation comments: scroll test, redraw anchor…
[PIR #1802] Thread: review notes
docs(changelog): #1802 reading aids in the Markdown Preview (PR #1812)
amrmelsayed commentedon Oct 16, 2026
Shipped in PR #1812 (merged
0608145f1)Read this first if you are looking for what the title describes. The issue asks for the word under the pointer to be highlighted. That shipped, and it is one of six styles, but it is not the default. At the dev gate the owner reviewed a published lab of variants over a real spec and widened the ask, then moved the default to line-plus-paragraph, which draws no word pill. The title now understates the feature, deliberately.
What shipped
none,word(the rounded pill from the mock),wordLine,wordLineParagraph,line,lineParagraph. The name lists the shapes drawn. Default:lineParagraph.arrow(default, keeping artifact-canvas: show arrow cursor (not I-beam) over markdown content — content is read-only, comments are button-driven #1232'scursor: default),iBeam,hand....overflow menu, beside Reset Font Size, plus the settingscodev.markdownPreview.hoverHighlightandcodev.markdownPreview.readingCursor. No new on-page button: these are set-once preferences, unlike the per-document columns toggle.isolation: isolatewith az-index: -1layer), so the canvas body's DOM is never written anddata-lineanchoring, comment cards and the composer are untouched. Flicker between words is handled by a sticky-on-gap rule, and nearest-caret false positives by a rect hit-test.Decisions worth recording
@cluesmith/codev-artifact-canvasprop defaults changed with this work (hoverHighlightdefaults tolineParagraph), so any other host embedding the canvas inherits the new default on upgrade.Verification
Three-way consultation: Gemini APPROVE, Codex COMMENT, Claude APPROVE, no REQUEST_CHANGES. Codex's two items were fixed before merge, one of them a real test hole: the scroll test previously passed when the highlight vanished entirely, and now requires a single shape that both moved and sits under the pointer. All seven required checks green on the merged head, including the real-browser Playwright job that covers the overlay behaviour.
Changelog and release-notes entries are on
docs/vscode-changelog(40cccb15a). Review and retrospective:codev/reviews/1802-artifact-viewer-highlight-the-.md.One unrelated finding, logged during this work and handed to the architect who owns
packages/codev: two tests incloud-config.test.tsbuild their "lax permissions" precondition withwriteFileSync(..., { mode: 0o644 }), which the process umask masks. Under a restrictive umask one fails loudly and the other passes vacuously. Not touched here.Closing as complete.