From edc863e020d7d58a35e4a68d170a81d1ba36bcb2 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Wed, 28 Jan 2026 15:20:37 -0800 Subject: [PATCH] feat: add copy buttons to user and assistant messages (#78) Closes #74 Reviewed-on: https://git.nhcarrigan.com/nhcarrigan/hikari-desktop/pulls/78 Co-authored-by: Naomi Carrigan Co-committed-by: Naomi Carrigan --- src/lib/components/Terminal.svelte | 97 ++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/src/lib/components/Terminal.svelte b/src/lib/components/Terminal.svelte index cf6491b..fb6faab 100644 --- a/src/lib/components/Terminal.svelte +++ b/src/lib/components/Terminal.svelte @@ -155,6 +155,30 @@ terminalElement.removeEventListener("copy", handleCopy); } }); + + // Copy message content to clipboard + async function copyMessage(content: string) { + try { + await navigator.clipboard.writeText(content); + // Optionally capture to clipboard history + await clipboardStore.captureClipboard(content, null, "Message from chat"); + + // Visual feedback could be added here if needed + } catch (error) { + console.error("Failed to copy message:", error); + } + } + + // State for showing "Copied!" feedback + let copiedMessageId: string | null = null; + + async function handleCopyMessage(messageId: string, content: string) { + await copyMessage(content); + copiedMessageId = messageId; + setTimeout(() => { + copiedMessageId = null; + }, 2000); + }
{:else} {#each lines as line (line.id)} -
+
{formatTime(line.timestamp)} {#if getLinePrefix(line.type)} {getLinePrefix(line.type)} @@ -194,10 +218,32 @@ [{line.toolName}] {/if} {#if line.type === "assistant" || line.type === "user"} - +
+ + +
{:else}