Skip to content

feat(editor): preview unsaved Markdown from the fallback banner - #21575

Merged
nwparker merged 6 commits into
nwparker/markdown-betterfrom
nwparker/markdown-fallback-preview
Sep 19, 2026
Merged

nwparker merged 6 commits into
nwparker/markdown-betterfrom
nwparker/markdown-fallback-preview

Conversation

@nwparker

@nwparker nwparker commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​179 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​167
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103 $\color{#cf222e}{\Huge{\mathbf{−}}}$​46 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​57

ELI5

When Markdown needs code mode, you can still preview the document—including edits you have not saved yet.

What Changed

Adds Open preview to the fallback banner and offers preview in the editor toggle. Both open the existing preview tab linked to the current draft. Previously the fallback left this action hard to discover. The regression verifies the rendered heading and reference link while disk still contains the old version.

Why

Reuses the existing preview route and draft buffer. Extracted from #21530 so preview navigation can be reviewed independently from keyboard, table, and code serialization changes. Depends on #21527. The English preview label ships in this layer.

Linked Issue

Related to #9858; does not complete full GFM support.

Visual Proof

Before (#21575): an unsaved source draft is stuck behind the fallback banner; the preview action is not available there.

Before: unsaved draft with fallback banner

After (#21575): the same unsaved draft opens in Preview, showing its edited heading and resolved reference link while disk still contains the old version.

After: unsaved draft rendered in Preview

Testing

  • 53 focused classification, shell, render-model, and preview-control unit tests passed on this isolated layer.
  • Rebuilt hidden Electron regression passed; screenshots inspected.
  • Changed-code quality passed with zero findings.
  • Localization catalog and extraction checks passed after moving the preview label into this layer (bcf4ade).
  • Latest combined-stack hidden Electron preview check passed with the unsaved title and resolved reference link visible.
  • Fresh CI and bot review must finish on the current head.

Review

Readiness: reuses existing actions; no new persistence, credentials, network calls, retries, or long-lived collections. Runtime environment and source-file identities are forwarded. No mobile-facing or wire-contract changes. Standard button styling and cross-platform keyboard handling retained. Native Windows/Linux UI still needs separate evidence.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • Focused scope, ELI5, mechanism, and rationale explained.
  • Before/after visual proof and regression test attached.
  • Security, performance, compatibility, and remote use reviewed.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The new editor.richMarkdown.openPreview string is missing from en.json, so pnpm run verify:localization-catalog and verify:localization-extraction — both run in .github/workflows/pr.yml — fail. Add the key before merging.

Reviewed changes

  • Rich-mode fallback detection — getCachedMarkdownRichModeEligibility now runs for every renderable inline Markdown edit tab, not only when mdViewMode === 'rich', and the result derives richModeFallsBackToSource.
  • Preview toggle mode — getEditorToggleModes gains a richModeFallsBackToSource flag; fallback markdown edit tabs get ['source','rich','preview','changes'].
  • Preview routing — the toggle's preview value opens the dedicated preview tab via openMarkdownPreview rather than becoming a render mode, and handleOpenMarkdownPreview was hoisted above the toggle handler.
  • Banner action — onOpenMarkdownPreview is threaded through EditorContent/EditorEditFileSurface to the fallback banner, gated on model.canShowMarkdownPreview, rendering an "Open preview" button.
  • Tests — 4 unit files (53 tests, all passing locally) plus a new e2e spec that proves an unsaved draft renders its heading and reference link while the file on disk stays unchanged.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in the merge delta. The only new commit merges nwparker/markdown-better into the branch without touching this PR's 12 files — the net diff is byte-identical to the prior review. The previously flagged missing editor.richMarkdown.openPreview entry in en.json is still unresolved and still fails the localization gates.

Reviewed changes

  • Base merge — 39fe876 merges base nwparker/markdown-better (8b33fe85, "retain CR line endings during save recovery") into the branch. None of this PR's files changed, so no new review surface.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Fallback preview label — added editor.richMarkdown.openPreview to en.json (bcf4aded), resolving the previously flagged localization gate failures. Verified locally: verify-localization-catalog.mjs and verify-localization-extraction.mjs both exit 0.
  • Base merge — 60ebab837 merges nwparker/markdown-better (f154eb43) into the branch, bringing upstream rich-markdown serialization fixes; none of this PR's own files are touched by the merge, and the net PR diff against the new base is unchanged apart from the label.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Re-reviewed the delta since the last Pullfrog review: a one-file fix to the shared Markdown fence tracker's closing-suffix rule, plus its boundary regression test.

  • Matched marked's fence suffix whitespace rule — hasClosingSuffix now accepts extra fence characters in a closing line only when they precede any whitespace, so a line like ``` ~ no longer closes a fence; previously fence characters were accepted anywhere in the suffix.
  • Extended the boundary regression test — markdown-scanner-boundaries.test.ts adds ``` ~ to its closer cases and asserts the scanner's fence range matches marked.lexer while the trailing <div> stays inside the code block. The new case fails against the old rule, so it is real coverage.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 98b2c55 into nwparker/markdown-better Sep 19, 2026
35 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