claude-code - 💡(How to fix) Fix Cowork: inline markdown file preview collapses YAML frontmatter and strips blank lines; copy button returns broken text

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error Messages/Logs

None — the corruption is silent. No error surfaced in the UI.

Root Cause

The bug compounds because the copy button on a file preview is the natural way to move file content from chat into another tool (editor, terminal, Obsidian, another markdown file). Because the button returns the broken state, the corruption silently propagates downstream. Multiple iterations of "Claude writes a markdown file → user reviews via preview → copy/paste somewhere" will silently mangle every file unless the user inspects the file on disk.

Code Example

None — the corruption is silent. No error surfaced in the UI.

---

---

## owner: wilbur updated: 2026-05-21 purpose: Source of truth for kyujin scoring. Edit this file to change what the digest surfaces.

# Wilbur's Job ProfileScorer Input
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When Cowork's chat shows an inline preview of a markdown file (one Claude has written or read), the preview renderer strips blank lines that exist in the file on disk. YAML frontmatter (the ---\nkey: value\n--- block at the top of the file) gets collapsed: each key/value pair is concatenated onto a single line, the closing --- is consumed, and the result is rendered as if the frontmatter were a single H2 paragraph. Blank-line separation between ## headers and their following content is also lost in the preview.

The copy button on these inline file previews returns the broken, rendered text — not the underlying file bytes. So when you click copy and paste elsewhere, you get the corrupted version, not what's actually on disk.

The file on disk is fine. Opening the file directly (Finder → editor, or cat file.md) shows correct formatting. The bug is entirely in the chat-preview component plus the copy action wired to that preview.

What Should Happen?

  • The inline file preview should render the file exactly as written, preserving blank lines and YAML frontmatter delimiters.
  • The copy button on a file preview should copy the raw file bytes (or at minimum, an exact text representation faithful to the file on disk).

Error Messages/Logs

None — the corruption is silent. No error surfaced in the UI.

Steps to Reproduce

  1. In Cowork, ask Claude to create or edit a markdown file with YAML frontmatter and several ## sections separated by blank lines (e.g., a profile.md, a knowledge.md, any CommonMark-typical doc).
  2. Observe the inline preview of that file that Claude renders in the chat.
  3. The YAML frontmatter collapses into a single H2-styled paragraph; the closing --- is gone; blank lines between sections disappear; section content runs together.
  4. Click the copy button on the inline file preview.
  5. Paste into any text editor or other markdown file.
  6. The pasted content has the same collapsed/broken structure as the preview, not the actual file bytes.
  7. Open the same file directly from disk in an editor (or cat it). Confirm the file on disk has correct formatting with blank lines intact.

Claude Model

N/A — this is a chat-UI rendering bug, not model output.

Is this a regression?

Unknown — first noticed in current Cowork research preview.

Claude Code Version

Claude 1.8089.1 (b98a06) 2026-05-19T18:28:48.000Z

Platform

Cowork (Claude desktop app, research preview)

Operating System

macOS

Terminal/Shell

N/A — the bug is in the Cowork chat preview component, not a terminal.

Additional Information

The bug compounds because the copy button on a file preview is the natural way to move file content from chat into another tool (editor, terminal, Obsidian, another markdown file). Because the button returns the broken state, the corruption silently propagates downstream. Multiple iterations of "Claude writes a markdown file → user reviews via preview → copy/paste somewhere" will silently mangle every file unless the user inspects the file on disk.

Concrete example where I noticed it: editing a profile.md with YAML frontmatter and many ## sections. The chat preview rendered the YAML as:

---

## owner: wilbur updated: 2026-05-21 purpose: Source of truth for kyujin scoring. Edit this file to change what the digest surfaces.

# Wilbur's Job Profile — Scorer Input

— the three frontmatter lines merged onto one line, prefixed with ##, and the closing --- was missing. The file on disk had the YAML correctly delimited and each field on its own line, verified via cat -A.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Cowork: inline markdown file preview collapses YAML frontmatter and strips blank lines; copy button returns broken text