Skip to content

feat(markdown): open markdown files in a read-only view (#54)#55

Draft
kevmtt wants to merge 1 commit into
amirlehmam:masterfrom
kevmtt:feat/54-open-markdown-view
Draft

feat(markdown): open markdown files in a read-only view (#54)#55
kevmtt wants to merge 1 commit into
amirlehmam:masterfrom
kevmtt:feat/54-open-markdown-view

Conversation

@kevmtt

@kevmtt kevmtt commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Wires the existing markdown pieces (markdown surface type, the secure markdown.load_file pipe handler, the marked + DOMPurify renderer) into a working feature and adds the missing entry points, mirroring the diff view.

Previously the render chain was dead: __wmux_setMarkdownContent dispatched a wmux:markdown-update CustomEvent that no component listened to, and MarkdownPane was mounted without a content prop — so markdown never rendered (always showed the empty placeholder).

Related Issue

Closes #54

Changes

  • Fix render chain: persist content per surface via SurfaceRef.markdownContent, add a setMarkdownContent(surfaceId, content) store action (locates the owning pane by id across workspaces), and thread it into MarkdownPane via a content prop. Replaces the dead CustomEvent.
  • One-shot CLI wmux markdown <file>: creates a markdown surface and loads the file in one step. Relative paths resolve against the terminal's cwd (path.resolve(process.cwd(), …)), not the Electron main-process cwd. wmux markdown set <id> --content/--file preserved; --file now also resolves relative paths.
  • Manual UI entry point: new markdown:open-file IPC (native file picker filtered to allowed extensions, reusing the same extension-whitelist + 5 MB guards as the pipe handler) + a command-palette item "Open Markdown File…".
  • Teach Claude: added a ## Markdown section to resources/claude-instructions.md (auto-injected into ~/.claude/CLAUDE.md by claude-context.ts).
  • Tests: tests/unit/markdown-content.test.ts (4 tests) covering setMarkdownContent.

Acceptance criteria

  • wmux markdown set <id> --content "# Hi" and --file <path> render in the pane
  • wmux markdown <relative-or-absolute.md> opens a new markdown surface showing the file
  • wmux markdown set <id> ... still works (no regression)
  • Relative paths resolve against the terminal's cwd
  • A manual UI entry point opens a markdown file into a view (command palette)
  • resources/claude-instructions.md documents the command (lands in ~/.claude/CLAUDE.md on next launch)
  • Non-markdown / oversized / missing files rejected with a clear error (guards preserved on both paths)

Test Plan

npm run dev
# from a wmux terminal pane:
wmux markdown README.md                      # opens a new markdown view
wmux markdown set <surfaceId> --content "# Hi"
# or: Command Palette → "Open Markdown File…"
  • npm run build:main ✅ · npx vite build ✅ · npx vitest run tests/unit/markdown-content.test.ts ✅ (4/4)
  • Pre-existing pty-manager test failures (node-pty native module unavailable in this env) are unrelated — they fail identically on clean master.

Note: dompurify was already declared in package.json but missing from node_modules; installed it (lockfile unchanged). PR pushed from fork kevmtt/wmux (no write access to upstream).

Wire up the existing markdown surface + load_file handler + marked/DOMPurify
renderer into a working feature and add the missing entry points.

- Fix render chain: persist content per surface (SurfaceRef.markdownContent),
  add a setMarkdownContent store action, and thread it into MarkdownPane via a
  content prop. Replaces the dead wmux:markdown-update CustomEvent that no
  component listened to (content never displayed before).
- CLI: 'wmux markdown <file>' creates a markdown surface and loads the file in
  one step; relative paths resolve against the terminal cwd. 'markdown set'
  still works and now resolves --file paths too.
- Manual UI: command-palette 'Open Markdown File...' opens a native file picker
  (filtered to allowed extensions) and renders the file, reusing the same
  extension-whitelist + 5MB guards as the pipe handler.
- Teach Claude: document the markdown command in claude-instructions.md.
- Add unit tests for setMarkdownContent.
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: open markdown files in a read-only markdown view (like the diff view)

1 participant