Skip to content

fix(desktop): Export as HTML uses the current doc + lets you choose the location#179

Merged
oratis merged 1 commit into
mainfrom
fix/desktop-export-html-current-doc
Jun 18, 2026
Merged

fix(desktop): Export as HTML uses the current doc + lets you choose the location#179
oratis merged 1 commit into
mainfrom
fix/desktop-export-html-current-doc

Conversation

@oratis

@oratis oratis commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Fixes the reported bug: Export as HTML exported a fixed "Welcome to Markup" document instead of the open one, and dumped it into ~/Downloads with no location choice.

Root cause

handleExportHtml closed over the render-scope tab, but the menu listener is registered once in an empty-deps effect — so it captured the first render's tab (the welcome buffer). Every export rendered that, regardless of what you had open. (Export PDF had the same latent bug.)

Fix

  • Current document: both export handlers now read the live active tab from the store (useAppStore.getState()), exactly like Save / Save As.
  • Choose the location: Export as HTML now opens a Save dialog (filtered to .html, path authorized via the existing save-panel grant), writes the rendered HTML to the chosen path via the existing write_file, and shows an "Exported …" toast. Cancelling is a no-op. (No more silent Downloads dump.)
  • Removed the now-dead browser-download exportHtml / downloadString helpers; added pickHtmlSavePath; EN + 中文 toast string.

Verify

tsc ✓ · biome ✓ · pnpm build ✓. (Sandbox/MAS-safe: writing to a user-picked path is authorized by the save panel, same as Save As.)

🤖 Generated with Claude Code

…e where

Two bugs in "Export as HTML":

1. It always exported a fixed "Welcome to Markup" document. The menu listener is
   registered once (empty-deps effect), so handleExportHtml closed over the
   first render's `tab` — the initial welcome buffer — not the active one. It now
   reads the live active tab from the store (useAppStore.getState()), matching
   how Save / Save As already work. Same stale-closure fix applied to Export PDF.

2. It silently downloaded to ~/Downloads. It now opens a Save dialog so the user
   picks the destination (filtered to .html, path authorized via the existing
   save-panel grant), writes the rendered HTML there, and shows an "Exported …"
   toast. Cancelling the dialog is a no-op.

- tauri.ts: pickHtmlSavePath (save dialog + authorize).
- App.tsx: handleExportHtml/handleExportPdf read the live tab; export writes to
  the chosen path via the existing write_file.
- Removed the now-dead browser-download exportHtml/downloadString helpers.
- EN + 中文 "Exported {0}" toast.

tsc ✓ · biome ✓ · build ✓.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oratis oratis merged commit 9e9cc63 into main Jun 18, 2026
4 checks passed
@oratis oratis deleted the fix/desktop-export-html-current-doc branch June 18, 2026 13:09
@oratis oratis mentioned this pull request Jun 18, 2026
oratis added a commit that referenced this pull request Jun 18, 2026
Patch release on top of v1.0.0 with the unreleased desktop fixes:
- Export as HTML exports the current document + lets you choose the save
  location (#179).
- About dialog: Check for Updates + Changelog (#180).

Bumps package.json / tauri.conf.json / Cargo.toml (+ Cargo.lock) to 1.0.1 and
adds docs/release-notes-v1.0.1.md. iOS is unaffected (desktop-only changes).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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