Skip to content

feat/markdown preview - #849

Merged
Jinwoo-H merged 2 commits into
stablyai:mainfrom
ypatel2022:feat/markdown-preview
Apr 26, 2026
Merged

Jinwoo-H merged 2 commits into
stablyai:mainfrom
ypatel2022:feat/markdown-preview

Conversation

@ypatel2022

Copy link
Copy Markdown
Contributor

Summary

  • Add Markdown Preview as a separate read-only tab for .md files instead of rendering preview inside the current editor tab.
  • Add VS Code-style entry points for preview: right-click actions, Cmd/Ctrl+Shift+V, and a shortcuts settings entry.
  • Keep preview tabs synced to the source markdown draft and wire them into save, rename/move, external file change, and file explorer auto-reveal flows.
  • Improve markdown rendering parity with VS Code by supporting GFM, hard line breaks, front matter, relative links and anchor navigation, local images, syntax highlighting, Mermaid, sanitized raw HTML, and KaTeX math.
  • Keep rendered markdown preview available in single-file diff tabs while preserving source mode for the actual line-by-line diff.

closes #511

Screenshots

Screenshot 2026-04-18 at 11 26 36 PM Screenshot 2026-04-18 at 11 27 10 PM

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI Review Report

Reviewed the main regression risks around preview-tab state, source-tab synchronization, save behavior, rename/move remapping, external file watch handling, diff behavior, and markdown link/path resolution.

The review flagged and this PR fixed several concrete issues:

  • Preview was still behaving like an in-place mode instead of a separate tab.
  • Save from a focused preview tab needed to target the underlying source markdown file.
  • Rename/move flows needed to remap preview tabs using their synthetic tab IDs instead of plain file paths.
  • Explorer auto-reveal and external-watch logic needed to treat preview tabs as file-backed tabs.
  • The markdown renderer needed sanitized raw HTML handling and math support to get closer to VS Code behavior.

Cross-platform compatibility was explicitly reviewed for the areas touched by this PR:

  • Shortcut handling uses metaKey on macOS and ctrlKey on Linux/Windows.
  • Shortcut labels use ⌘⇧V on macOS and Ctrl+Shift+V elsewhere.
  • Path resolution and link handling were checked for Unix paths, Windows drive-letter file URLs, and both / and \\ separators.
  • Existing platform-specific reveal/open behavior remains routed through Electron shell APIs already used by the app.

Security Audit

Reviewed the user-controlled markdown rendering path and related file/link handling.

  • Raw HTML rendering is now passed through rehype-sanitize before trusted renderers run, reducing XSS risk from markdown content while still allowing supported preview features.
  • Relative links and image paths are resolved against the current markdown file and normalized for both Unix and Windows path formats.
  • In-app file opening is limited to paths that resolve under known worktrees; external URLs and unmatched file URIs fall back to existing shell-open behavior.
  • No new command execution, auth flows, or secret handling were introduced.
  • Added markdown rendering dependencies: rehype-raw, rehype-sanitize, remark-math, rehype-katex, and katex; follow-up is standard dependency review/monitoring only.

@AmethystLiang
AmethystLiang requested a review from Jinwoo-H April 20, 2026 06:01
@nwparker
nwparker requested review from nwparker and removed request for Jinwoo-H April 21, 2026 21:01
@nwparker nwparker added the size/l Large PR (≤2500 added lines, ≤50 files) label Apr 26, 2026
@Jinwoo-H
Jinwoo-H force-pushed the feat/markdown-preview branch from 6e0ef97 to 7bb3d35 Compare April 26, 2026 02:16
ypatel2022 and others added 2 commits April 25, 2026 22:22
- Use GithubSlugger for heading IDs to match rehype-slug output
- Route #L10/#L10C5 line-target links to source editor instead of breaking
- Memoize react-markdown components to prevent unnecessary re-renders
- Remove unused worktreeId prop from MarkdownPreview
- Fix toggle icon size (8px → 12px) to match surrounding UI
- Add "Open Markdown Preview" to file explorer context menu
- Clean up tab context menu item to prevent 2-line wrapping
@Jinwoo-H
Jinwoo-H force-pushed the feat/markdown-preview branch from 7bb3d35 to 0b9cfd6 Compare April 26, 2026 02:22
@Jinwoo-H
Jinwoo-H merged commit 2551758 into stablyai:main Apr 26, 2026
3 checks passed
machamy added a commit to machamy/orca that referenced this pull request Sep 25, 2026
…lt view

The rich editor refuses raw HTML, prose generics and docs over 50k characters,
and those dead-ended at "editable only in code mode". Upstream moved preview to
a separate tab (stablyai#849) but kept the in-pane preview path in the edit and diff
surfaces; put it back in the toggle for both, and open markdown in it by
default. A setting picks Preview, Rich or Source; the per-file toggle wins, and
diffs keep defaulting to Source.

Also bumps to machamy.13 (with the Source Control extension filter already on
main) and keeps agent briefs/ at the repo root out of app.asar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l Large PR (≤2500 added lines, ≤50 files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In addition to markdown rendered in the normal file editor, also render it out in the diff view

4 participants