vscode: add review comments from a rendered Markdown Preview (artifact-canvas host integration) - #1045
Merged
Conversation
… black in dark mode)
…er, host sends raw text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PIR Review: Review comments from a rendered Markdown Preview (VSCode + artifact-canvas)
Fixes #859
Summary
Adds Codev Markdown Preview — a VSCode custom editor that renders a spec/plan/review in the
shared
@cluesmith/codev-artifact-canvasReact surface and lets a reviewer add inline reviewcomments by hovering a block and clicking
+, with no drop to the raw.mdeditor. It is thefirst host integration of the artifact-canvas package. The on-disk
<!-- REVIEW(@author): text -->convention is centralized in a new
@cluesmith/codev-core/review-markerscodec shared by both thenew preview and the existing editor Comments-API path. Mid-implement (architect-directed), the work
also fixed marker rendering at its source in the package: the renderer now strips full-line HTML
comments before parsing (fixes #1036 and the multi-line-paragraph split) and runs with
html: trueFiles Changed
git diff --stat main...HEAD(code + artifacts; excludes porch chore commits and the builder thread):packages/artifact-canvas/src/renderer/renderer.ts(+86 / −) — strip comments pre-parse + line map;html:truepackages/artifact-canvas/src/renderer/__tests__/data-line.test.ts(+45) — strip/no-split/line-map/fencepackages/artifact-canvas/src/renderer/__tests__/sanitization.test.ts(+35 / −) — D7 policy flippackages/core/src/review-markers.ts(new, +114) — shared marker codecpackages/core/src/__tests__/review-markers.test.ts(new, +98)packages/core/package.json(+4) —./review-markerssubpath exportpackages/vscode/src/markdown-preview/preview-provider.ts(new, +116) — CustomTextEditor + bridgepackages/vscode/src/markdown-preview/preview-template.ts(new, +69) — webview HTMLpackages/vscode/src/markdown-preview/webview/main.ts(new, +91) — React webview entrypackages/vscode/src/markdown-preview/webview/webview-env.d.ts(new, +4) —declare module '*.css'packages/vscode/src/comments/plan-review.ts(+30 / −) — editor path shares the codecpackages/vscode/src/commands/view-artifact.ts(+11 / −) — sidebar View → previewpackages/vscode/src/extension.ts(+29) — register provider +codev.openMarkdownPreviewpackages/vscode/esbuild.js(+70 / −) — second browser/IIFE webview bundlepackages/vscode/package.json(+38 / −) — customEditors, command/menus, deps, check-typespackages/vscode/tsconfig.json(±) — exclude webview dir from host typecheckpackages/vscode/tsconfig.webview.json(new, +16) — webview typecheck (DOM libs)codev/plans/859-…md,codev/resources/arch.md,codev/resources/lessons-learned.md— docsCommits
git log main..HEAD --oneline(non-chore):9415edbeScope custom editor to codev artifacts; type-check the webview bundle03a0dbfdExtract Markdown Preview webview HTML into preview-template.ts9e37063acore: stacked comments on one block all anchor to that blockc66e4082Renderer owns marker hiding: drop core stripMarkersForRender, host sends raw text443f9d28artifact-canvas: strip comments pre-parse (fix artifact-canvas: marker comments render as body text; hide markers in the rendered body while preserving data-line accounting #1036/split) + html:true (artifact-canvas: relax HTML policy to html:true + DOMPurify (render safe static HTML) #1042)75246957Sidebar View Review File also opens in the Markdown Preview81284b99Sidebar View Spec/Plan File opens in the Markdown Preview96ee1d99Fix title icon theming: light/dark codev variants (was black in dark mode)68aa3fb4Use Codev icon for the Open Markdown Preview title button4e91d0f2Rename surface to 'Codev Markdown Preview'53702239vscode: Codev Review Preview custom editor on artifact-canvas253d4c81vscode: editor review path shares the core marker codeca8080a30core: shared review-marker codecTest Results
core(tsc),artifact-canvas(tsup),vscode(check-typeshost + webview,lint, 2 esbuild bundles) all pass.core29 ·artifact-canvas39 ·vscode395. New: thecore/review-markerssuite (serialize/parse/strip-gating/stacking/round-trip) and theartifact-canvasrenderer additions (comment-strip, no-split, line-map, fence-exclusion, D7 policy flip).dev-approvalgate, Extension Development Host): rendered preview opens for codev artifacts; hover+→ InputBox → marker written + re-rendered; multi-line paragraph no longer splits; raw HTML renders (img/details), scripts stripped; sidebar View Spec/Plan/Review open in the preview; dark-mode title icon correct; multiple comments on one block all render.Architecture Updates
Routed to COLD (
codev/resources/arch.md, "VS Code Extension → Key Design Decisions"), not HOT:the HOT tier is at its 10-fact cap with more foundational facts, and this is subsystem-scoped. Added
a "Markdown Preview / artifact-canvas host integration (#859)" entry capturing the CustomTextEditor +
first-bundled-webview pattern and the two cross-cutting invariants it established: (1) the on-disk
REVIEW-marker convention lives in
@cluesmith/codev-core/review-markers(shared by every host), and(2) the canvas renderer is
html:true+ DOMPurify (sole guard, #1042/D7) and strips full-line HTMLcomments pre-parse with a line map (#1036).
Lessons Learned Updates
Routed to COLD (
codev/resources/lessons-learned.md, "UI/UX"): three entries —(1) VS Code's built-in markdown preview has no preview→host message channel for contributed scripts
(so render in an owned webview, don't extend the built-in preview); (2) editor/title command icons
given as an SVG file path render with no color context (
currentColor→ black), so supply{light,dark}variants; (3) hide a source-embedded annotation by removing its line pre-parse(with a line map), not by blanking it, or a blank line splits the multi-line block.
Things to Look At During PR Review
shared
artifact-canvaspackage and amends spec-945's D7 (html:false→html:true+DOMPurify). This was architect-directed mid-implement; recorded in the plan addendum, artifact-canvas: relax HTML policy to html:true + DOMPurify (render safe static HTML) #1042, and
arch.md. The closed spec-945 file is intentionally not rewritten. Worth a careful look at the
security posture: DOMPurify is now the sole raw-HTML guard (plus the webview's nonce CSP).
renderer.ts): the cleaned→originallineMapthreaded viamarkdown-it
envis the load-bearing bit for correctdata-lineafter stripping. Fence-awarenessprevents stripping comment lines inside code blocks. Indented (4-space) code blocks are not
fence-tracked — an HTML-comment line inside one could be stripped (rare; noted as a v1 edge).
core/review-markers.ts): a marker anchors to the nearestnon-marker line above it (so stacked comments group on one block). Known boundary: an
editor-authored comment deep inside a multi-line block anchors to a mid-block line with no
data-line, so it won't render in the canvas (canvas-authored comments always target the blockstart, so they never hit this). Richer anchoring is deferred to vscode: markdown preview marker-aware features — inline REVIEW rendering + right-edge marker minimap #863.
esbuild.jssecond entry) — first of its kind in theextension; the extension-host bundle stays React-free (the webview entry isn't imported by host code).
How to Test Locally
pir-859→ Review Diff..builders/pir-859in VSCode → F5 ("Run Codev Extension") → Extension Development Host.codev/plans|specs|reviews/*.md→ title-bar Open Markdown Preview (or sidebar View Spec/Plan/Review). Renders; no raw<!-- REVIEW -->text.+→ type → Enter → marker written, re-rendered, anchored. Multi-line paragraph does not split. Multiple comments on one block all show.<details>,<img src="https://…">) renders;<script>/onerror=stripped..md(e.g. README) is NOT offered the preview in "Reopen With…".+Comments path and existing markers unchanged.Consultation (PR, single advisory pass)
PIR runs one advisory 3-way pass (
max_iterations: 1); it is not re-reviewed, so dispositionsare recorded here for the human at the
prgate.void-prefixed floating promise atpreview-provider.ts:77). Addressed — removed thevoidprefix (matches the project'sbare-call convention).
an off-topic
agy --sandboxtangent, then an "empty workspace" prompt). This is a lane/infrafailure, not a review of this PR. Escalated to the human; effectively a 2-of-3 pass.
for the human):
canvas (they anchor to a line with no
data-line). Real but a documented, architect-approvedlimitation: the block-start-parity promise came from the original re-plan's markdown-it
resolver, which the architect explicitly directed me to drop (codec simplification), then we
landed on the strip-pre-parse + nearest-non-marker convention through a series of approved
decisions. Canvas-authored comments always target the block start and never hit this; markers
are never lost (still in the file, still rendered in the editor's Comments thread). Richer
anchoring is explicitly vscode: markdown preview marker-aware features — inline REVIEW rendering + right-edge marker minimap #863. Not fixed here to avoid unrequested scope creep into the
canvas component's anchoring (which is vscode: markdown preview marker-aware features — inline REVIEW rendering + right-edge marker minimap #863's domain).
packages/vscode/src/__tests__/bridge tests. The pure, regression-prone logic (the markercodec: serialize / parse / strip / anchor) is fully unit-tested in
core(29 tests). The hostbridge is thin
vscode-API glue (onDidReceiveMessage→showInputBox→WorkspaceEdit) thatisn't unit-testable without a heavy
vscodemock; it was exercised live at thedev-approvalgate. Judged not worth a brittle mock harness for this surface.
Follow-ups (filed)
showInputBox) + anchor the+to the first line (currently renders above the baseline) + richer multi-line anchoring.