Skip to content

feat(ui): add copy format options -- Markdown and Email-ready HTML #18967

Closed

Description

@andrewdunndev

The current copy button on assistant messages copies raw text via navigator.clipboard.writeText(). This works, but when pasting into Gmail, Slack, or docs the formatting is lost. The raw markdown renders as plain text.

I'd like to add format options to the existing copy button. Two additional modes alongside the current behavior:

Copy Markdown -- puts the raw markdown on the clipboard as text/plain with the content type that markdown-aware apps (Notion, Obsidian, GitHub) can render. This is close to what exists today but explicitly signals the format.

Copy for Email -- converts the markdown to sanitized HTML and puts it on the clipboard via navigator.clipboard.write() with text/html MIME type. Gmail, Outlook, and Apple Mail render this correctly. The HTML gets inline styles (no external CSS dependencies): monospace code blocks, bordered tables, styled blockquotes, blue links. Wrapped in Arial 14px to match Gmail's default.

I've built this pattern in another project and it works well. The sanitization strips all classes/styles from the rendered HTML and inlines email-safe CSS on key elements (code, pre, blockquote, table, th/td, a).

Implementation approach: Replace the single IconButton with a DropdownMenu (already exists in packages/ui/src/components/dropdown-menu.tsx). Three menu items: Copy Text (current), Copy Markdown, Copy for Email. The trigger is the existing copy icon.

The change is scoped to packages/ui/src/components/message-part.tsx -- the handleCopy function and the JSX around the copy button. No API changes.

Happy to submit a PR if this approach works.

Activity

  1. github-actions commented on Mar 24, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • This appears to be a feature request, but the title does not start with [FEATURE]: as required by the feature request template.
    • The feature request template requires checking the verification checkbox confirming the feature hasn't been suggested before.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. andrewdunndev commented on Mar 24, 2026

    @andrewdunndev
    Author

    Closing as duplicate of #14041 (copy as markdown) and #10693 (copy as rich text). I'll comment on those with an implementation offer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.webRelates to opencode on web / desktop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions