Skip to content

feat(app): Markdown preview pane next to the terminal #55

Closed

Description

@arifintahu

The problem

Developers keep their docs in Markdown, and cat README.md in EmberTerm prints raw source. Reading a README, a changelog or a runbook means leaving the terminal for an editor or a browser.

What you would like

A closable right-side panel in the tab that renders one Markdown file (.md / .markdown), so docs can be read next to the shell. Markdown only: other formats were cut to keep size and risk small.

Mockup: terminal on the left, rendered README.md panel on the right

Static mockup, colours approximate. The real panel uses the existing theme tokens.

Goals

  • GitHub-flavoured Markdown: tables, task lists, strikethrough, autolinks, highlighted code blocks, heading anchors, local relative images.
  • Relative .md links open in the same panel (back/forward), #anchor links scroll inside it, http(s) links use the existing opener.
  • Live reload when the file changes on disk, keeping the scroll position.
  • Works for Git Bash, WSL and pwsh paths (cmd: explicit trigger only).

Triggers

  • Phase 1, explicit: Ctrl+click a .md path in the output, a palette action "Preview Markdown file…", and a shortcut.
  • Phase 2, opt-in: auto-open on cat / bat / less / type / Get-Content with exactly one .md argument. Setting, default off. The OSC 133;E command mark already reaches the app, so no new shell hooks.

Non-goals
Editing, export, in-panel search, other formats (PDF, HTML, JSON, mermaid, math), remote images, files over 1 MB, restoring the open panel after a restart.

How it would work

  • Rendering in the frontend: marked + DOMPurify, plus highlight.js with a fixed language subset. All of it is a lazy chunk loaded on first open.
  • Rust only reads files: file_preview, file_preview_image, file_preview_stat, plus a pure path-resolution function (Git Bash /d/x → D:\x, WSL /mnt/d/x and \\wsl.localhost\<distro>\...; msys_to_windows already exists). No new crates.
  • The panel is a column in TabPane, outside the two-pane split model, so session.json and the split model do not change.
  • Security: Markdown from a cloned repo is untrusted. Output is always sanitized before insert, remote images are replaced by a placeholder, images load as data: URLs, and the CSP stays unchanged.

Budget (to be measured in the PR, not assumed)

  • Main bundle (583 KB JS today) stays within about 1.5% growth; the renderer and highlighter are lazy chunks.
  • Markdown chunk about 50 KB gzip or less, highlight chunk about 60 KB gzip or less.
  • No long task over 100 ms when rendering a 200 KB document. If a 1 MB document is janky, render in Rust (pulldown-cmark + ammonia) later; the swap touches one function.
  • No timers or polling when no panel is open. The release binary grows by about the size of the new lazy chunks (assets are embedded uncompressed); measured in the PR. PTY flood benchmark within noise with a panel open.

Suggested slices

  • Rust: file commands, path resolution, tests
  • Panel shell: tab state, divider, close, status-bar item
  • Renderer: sanitize, link/image/anchor rewriting, sanitizer tests
  • Syntax highlighting chunk and token colours
  • Explicit triggers: link provider, palette action, shortcut
  • Live reload
  • Auto-open on cat (setting, default off)
  • Docs, CHANGELOG, Keymap/Settings entries, size and perf numbers

Other ways you considered

  • Rust-side rendering: flat webview bundle and off-UI-thread render, but two new crates. Kept as the fallback if big documents measure slow.
  • Sandboxed iframe: rejected, the CSP has frame-src 'none'.
  • Auto-open only (no explicit trigger): rejected, cat huge.log or cat a.md | grep x would surprise people.

Activity

  1. added
    enhancement
    on Nov 21, 2026
  2. self-assigned this
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions