Skip to content

feat(ui): add copy button to assistant text responses#7874

Open
IamCoder18 wants to merge 2 commits intoKilo-Org:mainfrom
IamCoder18:feat/agent-copy-button
Open

feat(ui): add copy button to assistant text responses#7874
IamCoder18 wants to merge 2 commits intoKilo-Org:mainfrom
IamCoder18:feat/agent-copy-button

Conversation

@IamCoder18
Copy link
Copy Markdown

Context

Assistant text responses in the chat UI have no copy button. User messages, code blocks inside markdown, and bash tool output all have copy buttons — but assistant text parts don't. This adds one.

Closes #7870

Implementation

The rendering chain ChatView → MessageList → VscodeSessionTurn → AssistantMessage → Part → TextPartDisplay is shared across the sidebar, Agent Manager, and subagent viewer, so a single change in the shared TextPartDisplay component covers all three surfaces.

Most of the infrastructure was already in place:

  • The CSS had a [data-slot="text-part-copy-wrapper"] selector with display: none — pre-wired but never connected
  • i18n keys ui.message.copyResponse and ui.message.copied already translated in 16+ languages
  • All imports (Tooltip, IconButton, createSignal, useI18n) already in the file
  • showAssistantCopyPartID prop already plumbed through the component chain
  • The same copy-button pattern used 4 other times in the same file

CSS (message-part.css): Changed the wrapper from display: none to display: flex with opacity: 0; pointer-events: none and a 0.15s opacity transition. Hover over the parent [data-component="text-part"] reveals the button. When data-is-turn-copy is set (active/last text part), the button is always visible.

TSX (message-part.tsx): Added to TextPartDisplayuseI18n() call, copied signal, isLastTextPart memo (finds last text part in message), showCopy memo (uses showAssistantCopyPartID prop or falls back to isLastTextPart), handleCopy handler with 2s check icon toggle, and a <Tooltip> + <IconButton> block inside a <div data-slot="text-part-copy-wrapper">.

Zero new imports, zero new i18n keys, zero new CSS selectors, zero new props.

Screenshots

Before (no copy button):

ShareX_pmdAMxWE2P

After:

after.mp4

How to Test

  1. Open the Kilo sidebar chat
  2. Send a message that generates an assistant response with multiple text parts
  3. Hover over any assistant text part — a copy button should appear in the bottom-right
  4. Click the copy button — it should briefly show a check icon and copy the text to clipboard
  5. The last/active text part's copy button should be always visible (not just on hover)
  6. Test in the Agent Manager panel — the same copy button should appear there too

Get in Touch

My discord is @iamcoder18 and I am in the Kilo Code discord server.

Wire up the pre-existing text-part-copy-wrapper slot with a copy button in TextPartDisplay. The button reveals on hover over the text part (via CSS opacity transition) and is always visible for the active/last text part (via data-is-turn-copy). Uses existing i18n keys (ui.message.copyResponse, ui.message.copied) and follows the same pattern used by UserMessageDisplay, bash copy, and shell copy in the same file.
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 29, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • packages/kilo-ui/src/components/message-part.css

Reviewed by gpt-5.4-20260305 · 186,545 tokens

Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
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.

[FEATURE]: Agent - add button to copy agent response

1 participant