feat(ui): code blocks and chat messages from shadcn-vue's code-block, message and bubble

This commit is contained in:
sam committed 2026-10-19 02:22:42 +11:00
1 parent d876c150eb
commit 63adbc71ef
67 files changed
+1770 -310

No files matched your search

+5 -37
View File
@@ -1,49 +1,17 @@
<script setup lang="ts">
import { Button } from "@/components/ui/button";
import { computed } from "vue";
import CodeView from "@/base/CodeView.vue";
/**
* A JSON payload, verbatim. Two panels show one (the attempt's recorded config
* and the debug view), and both must show exactly what the daemon stored --
* no projection, no prettifying beyond indentation.
*/
import { computed, ref, watch } from "vue";
import { Check, Copy, TriangleAlert } from "@lucide/vue";
import HighlightedJson from "@/base/HighlightedJson.vue";
const props = defineProps<{ value: unknown }>();
const text = computed(() => JSON.stringify(props.value ?? {}, null, 2));
const copied = ref(false);
const copyError = ref(false);
watch(text, () => { copied.value = false; copyError.value = false; });
async function copy(): Promise<void> {
copyError.value = false;
try {
await navigator.clipboard.writeText(text.value);
copied.value = true;
} catch {
copied.value = false;
copyError.value = true;
}
}
</script>
<template>
<div class="group/json relative">
<Button
type="button"
variant="secondary"
size="icon-sm"
class="absolute top-2 right-2 z-10 opacity-0 focus-visible:opacity-100 group-hover/json:opacity-100 group-focus-within/json:opacity-100"
:aria-label="copyError ? 'Copy failed. Retry copying output' : copied ? 'Copied output' : 'Copy output'"
:title="copyError ? 'Copy failed. Retry.' : copied ? 'Copied' : 'Copy output'"
@click="copy"
>
<TriangleAlert v-if="copyError" class="size-4 text-danger" />
<Check v-else-if="copied" class="size-4" />
<Copy v-else class="size-4" />
</Button>
<span class="sr-only" role="status">{{ copyError ? 'Could not copy output.' : copied ? 'Output copied.' : '' }}</span>
<pre
class="max-h-[60vh] overflow-auto rounded-sm border border-border bg-muted p-3 font-mono text-xs leading-normal whitespace-pre-wrap break-words"
><HighlightedJson :text="text" /></pre>
</div>
<CodeView :code="text" lang="json" />
</template>