Cowork: inline markdown file preview collapses YAML frontmatter and strips blank lines; copy button returns broken text

Resolved 💬 1 comment Opened May 21, 2026 by wilburx3 Closed Jun 21, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗