feat(ui): add copy format options -- Markdown and Email-ready HTML#19035
Open
andrewdunndev wants to merge 1 commit intoanomalyco:devfrom
Open
feat(ui): add copy format options -- Markdown and Email-ready HTML#19035andrewdunndev wants to merge 1 commit intoanomalyco:devfrom
andrewdunndev wants to merge 1 commit intoanomalyco:devfrom
Conversation
Replace the single copy IconButton on assistant text parts with a DropdownMenu offering three copy modes: - Copy response (existing behavior, plain text) - Copy as Markdown (sanitized HTML + text/plain via ClipboardItem, so markdown-aware apps render formatting) - Copy for Email (sanitized HTML with inline email-safe styles for Gmail, Outlook, Apple Mail) Security: - All HTML sanitized via DOMPurify before DOM parsing or clipboard write (matches Markdown.tsx config) - Media tags forbidden (img, video, audio, iframe) to prevent network loads from untrusted content - Safe anchor attributes enforced (rel=noopener noreferrer) - Centralized writeClipboard() with ClipboardItem -> writeText -> textarea fallback chain for cross-platform compatibility Uses the existing DropdownMenu component (Kobalte). Scoped to packages/ui/src/components/message-part.tsx and en.ts i18n strings. Closes anomalyco#14041 Relates to anomalyco#10693
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Found one potentially related PR:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #14041
Relates to #10693
Type of change
What does this PR do?
Replaces the single copy
IconButtonon assistant text parts with aDropdownMenuoffering three copy modes:text/plaintext/html+text/plainviaClipboardItemtext/html(inline styles) +text/plainThe email HTML sanitization strips all classes/styles from rendered HTML and inlines email-safe CSS on key elements (monospace code blocks, bordered tables, styled blockquotes, blue links, Arial 14px base font to match Gmail default).
Security measures:
Markdown.tsximg,video,audio,iframe) to prevent network loads from untrusted contentrel="noopener noreferrer")writeClipboard()helper with three-tier fallback:ClipboardItem→writeText→textarea execCommandScope:
packages/ui/src/components/message-part.tsx(copy handler + DropdownMenu) andpackages/ui/src/i18n/en.ts(2 new keys:ui.message.copyMarkdown,ui.message.copyEmail). Uses the existingDropdownMenucomponent (Kobalte). No API changes.i18n note: Two new keys added to
en.tsonly. Other locale files will need translations in a follow-up.How did you verify your code works?
bun run --filter @opencode-ai/ui typecheckexits 0marked.parseoutput going toinnerHTMLand clipboard). Both fixed with DOMPurify sanitization before submission.session-review.tsxconfirms consistencyClipboardItemfeature detection ensures graceful degradation on platforms without rich clipboard support (TUI via opentui, some Tauri builds)Screenshots / recordings
No screenshots yet. The change replaces the single copy icon button with a dropdown menu that appears on click, showing three options. Visual appearance matches the existing DropdownMenu usage in session review.
Checklist