feat(desktop): add copy buttons for blockquote and code blocks with i…#593
feat(desktop): add copy buttons for blockquote and code blocks with i…#593twfhyr wants to merge 3 commits into
Conversation
|
QA note: copy support currently seems focused on blockquotes and fenced code blocks, but inline code/text pills should be covered as well. For example, branch names like |
|
Thanks for flagging this. Inline code spans now have their own copy button too. What was added:
This covers the branch name / text pill case you mentioned (e.g. |
|
Thanks for jumping on the inline-code case so quickly. I pulled the PR branch and tried it locally. The feature itself is definitely useful, but I noticed one keyboard navigation issue that I think we should clean up before merging. If I tab through the rendered message without using the mouse, focus eventually lands on one of the inline-code copy buttons, but the button itself is still hidden. The tooltip shows up with Steps I used:
I think this is happening because the inline copy button is hidden with Could you adjust this so that whenever the button receives keyboard focus, it becomes visible too? Something like showing it on One smaller UX note: the inline button is positioned at Overall I like the direction here — code block copy looks good and the inline-code support is a useful addition. I just don’t want us to merge an invisible focus target into the chat UI. |
|
Code-structure concern: this feels like it reinvents the copy-button pattern instead of extending the one we already have.
Can we extract the existing behavior into a shared copy button/hook and reuse it here? That would keep the interaction consistent and avoid drift between four different copy implementations. |
…con + tooltip - Add BlockquoteCopyButton component with HugeiconsIcon (Copy01Icon/Tick02Icon) and Radix Tooltip, consistent with CopyResponseButton pattern - Update CodeBlock copy button from plain text to icon + tooltip - Add hover-to-reveal copy button on blockquotes (opacity transition) - Add shared .chat-copy-tooltip styles with z-index and animation keyframes - Add copied state (green accent) for both code and blockquote buttons Closes AntSeed#574
- Add InlineCodeCopyButton component with icon + tooltip (size 12px) - Wrap inline code in chat-inline-code-wrap span with hover-reveal - Use absolute positioning (left: 100%) to avoid layout shift - Add pointer-events: none/auto for hidden/shown states - Consistent opacity transition pattern across all copy buttons
6b9a399 to
dad92c1
Compare
…visible styles - Extract useCopyToClipboard hook from 3 separate copy implementations - Create single CopyButton component used by inline code, blockquote, and code blocks - Refactor CopyResponseButton in ChatBubble.tsx to use the shared hook - Add :focus-visible styles so copy buttons are visible during keyboard navigation - Add focus-within on blockquote container so header appears on keyboard focus - Addresses PR review feedback on AntSeed#593
|
Thanks for the thorough review — both issues are now addressed in the latest push (cba0e35). Keyboard focus visibilityThe inline-code and blockquote copy buttons were hidden with
Shared copy hook / deduplicationAll four copy implementations (inline code, blockquote, code block, and the existing
Net change: 49 insertions, 103 deletions. No more duplicated timer/state/tooltip logic. Re: the |
What
Adds copy buttons with icon + tooltip to blockquote and code blocks in assistant chat messages.
Copy01Icon/Tick02Icon) + Radix Tooltip, matching theCopyResponseButtonpattern inChatBubble.tsx.chat-copy-tooltipwithz-index: 9999and dedicated animation keyframesWhy
Issue #574 — users often want to copy a single block (command, code snippet, config) from an assistant response, not the entire message. Code blocks had a copy button but used plain text. Blockquotes had no copy button at all.
Testing
pnpm --filter @antseed/desktop run typecheck:rendererpassespnpm --filter @antseed/desktop run build:rendererpassespnpm --filter @antseed/desktop run dev) and checking:chat-utils.tsx(none existed prior to this change either)Checklist
pnpm run buildpnpm run test~