The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(artifact-card): add new artifact card component
Steven Enamakel6cfad2b6060a
diff --git a/app/src/components/assistant-ui/elements/artifact-card.tsx b/app/src/components/assistant-ui/elements/artifact-card.tsxnew file mode 100644index 0000000000..00e14a7278--- /dev/null+++ b/app/src/components/assistant-ui/elements/artifact-card.tsx@@ -0,0 +1,84 @@+'use client';++/**+ * assistant-ui's artifact-card element: a compact row for a generated file+ * (document, presentation, ...) — icon, title, and either a "writing" shimmer+ * with a live word count, or the settled metadata line once it's done.+ *+ * Vendored from the assistant-ui `elements-artifact-card` registry item+ * (https://r.assistant-ui.com/styles/base-nova/elements-artifact-card.json).+ * Changes from upstream:+ * - `cn` import path and `./surfaces` resolved through this app's alias.+ * - `writingLabel` prop (English default supplied by the caller via+ * `useT()`) replaces the hardcoded "Writing" string.+ * - `icon` prop (defaults to `FileTextIcon`) so a presentation, image, or+ * other artifact kind can swap the glyph instead of always showing a+ * document icon.+ * - `onOpen` replaces upstream's implicit "the whole card is a link" with an+ * explicit handler; the card renders as a `<button>` when present.+ */+import type { ComponentProps, ElementType } from 'react';+import { ArrowUpRightIcon, FileTextIcon } from 'lucide-react';+import { cn } from '@/components/assistant-ui/lib/utils';+import { mono, paper, ShimmerLabel } from '@/components/assistant-ui/elements/surfaces';++export interface ArtifactCardProps+ extends Omit<ComponentProps<'div'>, 'children' | 'title' | 'meta' | 'generating' | 'words'> {+ title: string;+ meta: string;+ generating?: boolean;+ words?: number;+ writingLabel?: string;+ icon?: ElementType;+ onOpen?: () => void;+}++export function ArtifactCard({+ title,+ meta,+ generating = false,+ words = 0,+ writingLabel = 'Writing',+ icon: Icon = FileTextIcon,+ onOpen,+ className,+ ...props+}: ArtifactCardProps) {+ const Container = onOpen ? 'button' : 'div';++ return (+ <Container+ data-slot="artifact-card"+ type={onOpen ? 'button' : undefined}+ onClick={onOpen}+ className={cn(+ paper,+ 'group flex w-full max-w-xs cursor-pointer items-center gap-3 rounded-[20px] p-3.5 text-start transition-transform duration-150 hover:-translate-y-px active:scale-[0.98]',+ className+ )}+ {...props}>+ <span className="bg-foreground/[0.05] text-foreground/45 flex size-9 shrink-0 items-center justify-center rounded-xl">+ <Icon className={cn('size-4', generating && 'animate-pulse motion-reduce:animate-none')} />+ </span>+ <div className="min-w-0 flex-1">+ <p className="truncate text-[13.5px] font-medium">{title}</p>+ {generating ? (+ <p className={cn(mono, 'text-foreground/40 flex items-center gap-1')}>+ <ShimmerLabel className="relative inline-block leading-none">{writingLabel}</ShimmerLabel>+ <span>·</span>+ <span className="tabular-nums">{words} words</span>+ </p>+ ) : (+ <p+ className={cn(+ mono,+ 'fade-in blur-in-[2px] animate-in text-foreground/40 duration-300 motion-reduce:animate-none'+ )}>+ {meta}+ </p>+ )}+ </div>+ <ArrowUpRightIcon className="text-foreground/35 size-3.5 opacity-0 transition-opacity group-hover:opacity-100" />+ </Container>+ );+}