summaryrefslogtreecommitdiffhomepage
path: root/packages/frontend/src/lib/components/DebugPanel.svelte
blob: aea1ccbad7974fdd87b7beb66e90e0b9103095d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<script lang="ts">
import { tabStore } from "../tabs.svelte.js";

let copyLabel = $state("Copy conversation");

function resetCopyLabel(): void {
	copyLabel = "Copy conversation";
}

async function handleCopy(): Promise<void> {
	const text = tabStore.copyConversation();
	try {
		await navigator.clipboard.writeText(text);
		copyLabel = "Copied";
	} catch {
		copyLabel = "Failed";
	}
	setTimeout(resetCopyLabel, 1500);
}
</script>

<div class="flex flex-col gap-3">
	<div class="text-xs font-semibold text-base-content/50 uppercase tracking-wide">Debug</div>

	<div class="flex flex-col gap-2">
		<p class="text-xs text-base-content/70">Conversation</p>
		<p class="text-xs text-base-content/40">
			Copy a structured plain-text dump of the active tab's conversation
			(chunk shape included) for bug reports.
		</p>
		<button type="button" class="btn btn-sm btn-primary w-full" onclick={handleCopy}>
			{copyLabel}
		</button>
	</div>
</div>