feat(markdown): open markdown files in a read-only view (#54)#55
Draft
kevmtt wants to merge 1 commit into
Draft
Conversation
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.
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.
Summary
Wires the existing markdown pieces (markdown surface type, the secure
markdown.load_filepipe handler, themarked+DOMPurifyrenderer) into a working feature and adds the missing entry points, mirroring the diff view.Previously the render chain was dead:
__wmux_setMarkdownContentdispatched awmux:markdown-updateCustomEvent that no component listened to, andMarkdownPanewas mounted without acontentprop — so markdown never rendered (always showed the empty placeholder).Related Issue
Closes #54
Changes
SurfaceRef.markdownContent, add asetMarkdownContent(surfaceId, content)store action (locates the owning pane by id across workspaces), and thread it intoMarkdownPanevia acontentprop. Replaces the dead CustomEvent.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/--filepreserved;--filenow also resolves relative paths.markdown:open-fileIPC (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…".## Markdownsection toresources/claude-instructions.md(auto-injected into~/.claude/CLAUDE.mdbyclaude-context.ts).tests/unit/markdown-content.test.ts(4 tests) coveringsetMarkdownContent.Acceptance criteria
wmux markdown set <id> --content "# Hi"and--file <path>render in the panewmux markdown <relative-or-absolute.md>opens a new markdown surface showing the filewmux markdown set <id> ...still works (no regression)resources/claude-instructions.mddocuments the command (lands in~/.claude/CLAUDE.mdon next launch)Test Plan
npm run build:main✅ ·npx vite build✅ ·npx vitest run tests/unit/markdown-content.test.ts✅ (4/4)pty-managertest failures (node-pty native module unavailable in this env) are unrelated — they fail identically on cleanmaster.