Skip to content

Phase 3: Electron shell — basic viewer#40

Merged
jamesainslie merged 6 commits intomainfrom
electron-phase-3-electron-shell
Mar 20, 2026
Merged

Phase 3: Electron shell — basic viewer#40
jamesainslie merged 6 commits intomainfrom
electron-phase-3-electron-shell

Conversation

@jamesainslie
Copy link
Owner

Summary

  • Add packages/electron/ — a standalone Electron desktop app that imports @mdview/core with Electron-native adapter implementations
  • Implement full feature parity with Chrome extension: themes, syntax highlighting, mermaid diagrams, TOC, comments, export, and auto-reload
  • 70 new tests across 10 test files, all 1277 tests pass

What's included

3.1 Scaffold — package.json, tsconfigs, electron-vite 3-process build config, vitest workspace integration

3.2 Main-process adapters — StorageAdapter (electron-store), FileAdapter (fs/promises + chokidar), IdentityAdapter (os.userInfo), ExportAdapter (showSaveDialog + printToPDF)

3.3 IPC bridge — 17 typed IPC channel constants, MdviewPreloadAPI interface, contextBridge preload script with 15 invoke channels + 3 event listeners

3.4 Main process + state — StateManager with electron-store persistence, 14 IPC handlers, file watcher lifecycle management, macOS open-file event handling

3.5 Renderer adapters — Thin wrappers delegating through window.mdview preload bridge: MessagingAdapter, StorageAdapter, FileAdapter, IdentityAdapter, ExportAdapter

3.6 ViewerMDViewElectronViewer class orchestrating: file load → state → theme → 6-stage render pipeline → TOC → export UI → comments → auto-reload → event listeners

3.7 Build pipeline — electron-builder config with dmg/zip (mac), AppImage (linux), nsis (win) targets and .md/.markdown file associations

Test plan

  • npm run test:ci — 1277 tests pass (1207 original + 70 new)
  • npm -w @mdview/electron run build — electron-vite builds all 3 processes
  • npm -w @mdview/electron run dev — launches Electron window
  • Manual: open .md file, verify rendering with themes/syntax/mermaid

Add packages/electron/ with three-process architecture (main, preload,
renderer), electron-vite build config, vitest workspace integration,
and convenience scripts in root package.json.
…bridge

Implement StorageAdapter (electron-store), FileAdapter (fs + chokidar),
IdentityAdapter (os.userInfo), ExportAdapter (dialog + printToPDF).
Define typed IPC channels and preload API shape. Wire contextBridge
with all 15 channels including event listeners. 32 new tests.
…nderer adapters

Wire up full main process with electron-store, chokidar file watching,
state management, and 14 IPC handlers. Add renderer-side adapter wrappers
that delegate through window.mdview preload bridge. 33 new tests.
Implement MDViewElectronViewer with 6-stage render pipeline, theme
engine, TOC, export UI, comments, and auto-reload via chokidar IPC.
Copy content.css from chrome-ext (to be consolidated in Phase 4).
5 new viewer tests.
Configure electron-builder with dmg/zip (mac), AppImage (linux),
nsis (win) targets and markdown file associations. Add icon generation
script and placeholder icons.
Vite's default IIFE worker format doesn't support code-splitting
needed by @mdview/core's render-worker. Use ES modules instead.
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@jamesainslie jamesainslie merged commit b50a1f7 into main Mar 20, 2026
0 of 2 checks passed
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.

1 participant