Repository navigation
feat(editor): preview unsaved Markdown from the fallback banner - #21575
Conversation
There was a problem hiding this comment.
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 —
getCachedMarkdownRichModeEligibilitynow runs for every renderable inline Markdown edit tab, not only whenmdViewMode === 'rich', and the result derivesrichModeFallsBackToSource. - Preview toggle mode —
getEditorToggleModesgains arichModeFallsBackToSourceflag; fallback markdown edit tabs get['source','rich','preview','changes']. - Preview routing — the toggle's
previewvalue opens the dedicated preview tab viaopenMarkdownPreviewrather than becoming a render mode, andhandleOpenMarkdownPreviewwas hoisted above the toggle handler. - Banner action —
onOpenMarkdownPreviewis threaded throughEditorContent/EditorEditFileSurfaceto the fallback banner, gated onmodel.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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the merge delta. The only new commit merges
nwparker/markdown-betterinto the branch without touching this PR's 12 files — the net diff is byte-identical to the prior review. The previously flagged missingeditor.richMarkdown.openPreviewentry inen.jsonis still unresolved and still fails the localization gates.
Reviewed changes
- Base merge —
39fe876merges basenwparker/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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Fallback preview label — added
editor.richMarkdown.openPreviewtoen.json(bcf4aded), resolving the previously flagged localization gate failures. Verified locally:verify-localization-catalog.mjsandverify-localization-extraction.mjsboth exit 0. - Base merge —
60ebab837mergesnwparker/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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ 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 —
hasClosingSuffixnow 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.tsadds``` ~to its closer cases and asserts the scanner's fence range matchesmarked.lexerwhile the trailing<div>stays inside the code block. The new case fails against the old rule, so it is real coverage.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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.
After (#21575): the same unsaved draft opens in Preview, showing its edited heading and resolved reference link while disk still contains the old version.
Testing
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
Checklist