Skip to content

Preserve assistant message formatting on copy#1156

Merged
boudra merged 1 commit into
mainfrom
diagnose/clipboard-markdown-mime
May 24, 2026
Merged

Preserve assistant message formatting on copy#1156
boudra merged 1 commit into
mainfrom
diagnose/clipboard-markdown-mime

Conversation

@boudra
Copy link
Copy Markdown
Collaborator

@boudra boudra commented May 24, 2026

Linked issue

None.

Type of change

  • Bug fix
  • New feature (with prior issue + design alignment)
  • Refactor / code improvement
  • Docs

What does this PR do

Assistant turn copy now puts both plain markdown and rich HTML on the clipboard when the platform supports rich clipboard writes. This lets formatted assistant output such as tables, nested lists, headings, and code blocks keep their structure when pasted into rich-text editors, while still falling back to plain markdown on platforms that only support text copy.

How did you verify it

  • npx vitest run src/utils/rich-clipboard.test.ts --bail=1
  • npm run format
  • npm run lint
  • npm run typecheck

The new unit test covers markdown-to-HTML clipboard rendering, unsafe HTML/link handling, rich clipboard writes, and plain-text fallback when rich writes fail.

Checklist

  • One focused change. Unrelated cleanups split out.
  • npm run typecheck passes
  • npm run lint passes
  • npm run format ran (Biome)
  • UI changes include screenshots or video for every affected platform
  • Tests added or updated where it made sense

Risk surface: this touches web/Electron clipboard behavior for assistant turn copy. Native and denied rich-write paths keep the existing plain markdown fallback; browser permission/focus edge cases are covered by falling back to text copy.

@boudra boudra enabled auto-merge (squash) May 24, 2026 04:03
@boudra boudra merged commit 83f205b into main May 24, 2026
14 checks passed
@boudra boudra deleted the diagnose/clipboard-markdown-mime branch May 24, 2026 04:10
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