Repository navigation
feat(agent): add copy button to assistant messages in AI agent chat (closes #371) - #374
Conversation
Closes #365 - Added silent parameter (default false) to loadData - When silent=true, skips setLoading(true) so existing rows stay visible during background refresh - Initial load and filter-change calls remain non-silent (correct full loading state on first paint and filter switch) - All post-mutation calls use loadData(true): handleSendWebhook, handleDismiss, handleBulkSend, handleBulkDone, handleBulkDismiss, and pollJob completion handler - Zero new TypeScript errors introduced (verified via tsc --noEmit diff) Signed-off-by: Maqbool Ahmed <[email protected]>
gkhngyk
left a comment
There was a problem hiding this comment.
Nice — the copy button works exactly as described (raw markdown text, tool/chart parts skipped, assistant-only, hover reveal), and it's Prettier-clean. 🙌
One small thing before merge: the toast says 'Link copied', but you're copying a message, not a link — please change it to something like 'Copied' or 'Message copied' (the 'Link copied' string is carried over from the team-invite copy pattern).
Optional a11y nice-to-have (non-blocking): add focus-visible:opacity-100 alongside group-hover:opacity-100 so keyboard users can see the button when it's focused. Thanks!
Working on it |
…tton Signed-off-by: Maqbool Ahmed <[email protected]>
Done — changed the toast to |
gkhngyk
left a comment
There was a problem hiding this comment.
Fix confirmed — the toast now reads 'Copied' (accurate, since a message is copied, not a link), and you even added the aria-label + focus-visible:opacity-100 a11y touch. Copy logic is correct: raw markdown only (type === 'text'), tool/chart parts skipped, assistant-only, empty messages excluded. Prettier-clean. Thanks for iterating on this! 🙌
Problem
On the
/dashboard/agentpage, there was no way to copy an assistant reply.Users had to hand-select the text, which is especially painful for long
markdown responses with lists, bold, and headings.
Solution
Added a small copy icon button that appears on hover at the bottom-right of
every assistant message bubble. Clicking it copies the raw markdown text to
the clipboard and briefly shows a "Link copied" confirmation toast + check
icon, then resets after 2 seconds.
Implementation details
File changed:
web/src/app/[locale]/(dashboard)/dashboard/agent/page.tsx1. Imports
CopyandCheckfromlucide-react(same icon set used throughout the app)toastfromsonner(same pattern asteam-section.tsx→toast.success('Link copied'))2. MessageBubble changes
copiedstate (useState(false))rawText— concatenates onlytype === 'text'parts, skippingtool-*andtool-render_chartparts as specified:(message.parts ?? []).filter(p => p.type === 'text').map(p => p.text).join('\n\n')handleCopy()— callsnavigator.clipboard.writeText(rawText), firestoast.success('Link copied'), setscopied = truefor 2 s then resetsgroupclass so child hover states workabsolute bottom-2 right-2,opacity-0 group-hover:opacity-100,flips between
<Copy />and<Check />based oncopiedstate!isUser && rawText— user messages and empty assistantmessages never show the button
3. Reuses existing app patterns
navigator.clipboard.writeText+toast.success('Link copied')— identicalto
team-section.tsxline 451Copyicon — same asaudit-report.tsxandapi-keys-section.tsxopacity-0 group-hover:opacity-100— same hover reveal used on the deletebutton in the conversation sidebar
Verification
How to test manually
/dashboard/agentand ask the assistant a questionCloses #371