Skip to content

feat: rendered markdown, Mermaid diagrams, Google Docs-style comments, dark mode - #39

Draft
Ronkahn21 wants to merge 12 commits into
wong2:mainfrom
Ronkahn21:feat/comment-and-theme-ux
Draft

feat: rendered markdown, Mermaid diagrams, Google Docs-style comments, dark mode#39
Ronkahn21 wants to merge 12 commits into
wong2:mainfrom
Ronkahn21:feat/comment-and-theme-ux

Conversation

@Ronkahn21

Copy link
Copy Markdown

Summary

  • Rendered markdown view: toggle any .md file between Diff and Rendered with a toolbar button
  • Mermaid diagrams: fenced mermaid blocks render as live diagrams in the rendered view (lazy-loaded)
  • Google Docs-style comments on rendered text: select any passage in the rendered view → floating + → comment anchored to the highlighted text; bubbles appear in the right margin aligned to their anchor
  • Multi-line diff comments: press-drag the gutter + across lines to comment on a range; a ghost + stays pinned to the start line while dragging
  • Dark mode: sun/moon toggle in toolbar, persisted to localStorage, applied via data-theme attribute
  • /diffx-finish-review skill updated: documents both comment types (anchorType: "line" with endLineNumber/lineContents, anchorType: "rendered" with renderedAnchor including paragraphIndex/offset fallback)

Closes #38

Details

Rendered comments use the CSS Custom Highlight API to paint the anchor text. The renderedAnchor object stores selectedText, context, paragraphIndex, and character offsets so the highlight can be restored after re-renders or on /diffx-finish-review.

The ghost + button is a position: absolute overlay captured from e.currentTarget.getBoundingClientRect() at drag-start and cleared on pointerup/pointercancel.

Also addressed in this PR:

  • pointercancel handler so drag state doesn't get stuck on touch-scroll or alt-tab
  • e.button !== 0 guard on gutter + (right-click was starting a drag)
  • onKeyDown on gutter + so keyboard users can open a single-line composer via Enter/Space
  • localStorage reads/writes guarded against blocked storage (private browsing)
  • /api/file scoped to .md files only (was readable for any file under cwd)
  • Dark theme CSS variables --comment-card-border/--comment-card-shadow added
  • Comment bubble actions visible on :focus-within for keyboard users
  • Resolved comment body rendered through ReactMarkdown (was raw markdown text)
  • aria-label/aria-pressed on theme toggle button

Test plan

  • 16/16 e2e tests pass (npx playwright test e2e/comments.spec.ts)
  • Build clean (pnpm run build)
  • .md file shows Diff/Rendered toggle; Rendered shows formatted HTML with Mermaid diagrams
  • Text selection in Rendered view shows + tooltip; comment anchors to highlighted text with right-margin bubble; resolving/unresolving works
  • Drag gutter + across lines → ghost stays at start line; release opens composer with correct range
  • Theme toggle switches light/dark; persists on reload

Ronkahn21 added 10 commits July 13, 2026 15:08
…e comments

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
- Add remark-breaks so single newlines in comment bodies render as <br>
- Float CommentForm near selection instead of appending to bottom of content
- Fix injectHighlights to fall back to text-match when paragraphIndex is stale

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
Diff comments:
- Multi-line via press-drag on the gutter "+" (opens only on release),
  driven by synchronous pointer listeners + shadow-DOM hit-testing
- GitHub-blue selection highlight; inline thread is the commented-line signal
- Inline edit / resolve (collapsed summary) / delete on each comment

Rendered (markdown) comments, Google-Docs style:
- Highlights painted via the CSS Custom Highlight API (zero DOM mutation)
- Two-way highlight <-> margin-card linkage via a single activeCommentId
- Fix mermaid re-rendering: stable react-markdown components + ref-based
  MermaidBlock so diagrams no longer re-init when highlighting

Theme:
- Manual light/dark toggle (data-theme + persisted), no-flash inline script
- Dark-mode comment-highlight colors that stay readable

Testing:
- Playwright e2e covering the +-drag multi-line and single-line click

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
- Collapse rendered comment margin to 0 width when no comments exist
  (fixes rendered view content squished to 173px in normal viewport)
- Increase samePositions epsilon 0.5->2px to prevent sub-pixel
  ResizeObserver feedback loop causing comment cards to oscillate
- Fix fileAnnotationsMap TS error: side typed as union not undefined
- Add sourceLine to RenderedAnchor for cross-view comment sync
- e2e: beforeEach cleanup+navigation in all groups, retry hover/scroll

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
Signed-off-by: Ron Kahn <rkahn@nvidia.com>
@Ronkahn21

Copy link
Copy Markdown
Author

@coderabbitai review

Signed-off-by: Ron Kahn <rkahn@nvidia.com>
Signed-off-by: Ron Kahn <rkahn@nvidia.com>
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.

feat: rendered markdown, Mermaid diagrams, Google Docs-style comments, dark mode

1 participant