Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(ui): artifact cards render inside the message thread, panel tabs closable

Sanil1777dc3188b7
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index 0884cadaf0..5451829ac0 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -143,6 +143,13 @@ export type ThreadComponents = {
* `null` when there is nothing to show.
*/
TranscriptFooter?: ComponentType | undefined;
+ /**
+ * Host-owned content rendered after the last message, inside the
+ * scrollable transcript — artifact cards from versioned tools that
+ * carry no tool-call id and would otherwise be invisible to the
+ * inline tool-call renderer. Always mounted (not gated on isRunning).
+ */
+ AfterMessages?: ComponentType | undefined;
/** Host-owned attachment previews rendered above the editor. */
ComposerAttachments?: ComponentType | undefined;
/** Host-owned attachment picker rendered in the action row. */
@@ -500,6 +507,7 @@ const ThreadRoot: FC<{
<ThreadPrimitive.Messages>{() => <ThreadMessage />}</ThreadPrimitive.Messages>
<RunningStatusSlot />
<TranscriptFooterSlot />
+ <AfterMessagesSlot />
{ActiveTasks && <ActiveTasks />}
</div>
@@ -574,6 +582,13 @@ const TranscriptFooterSlot: FC = () => {
);
};
+/** Host content after the last message; always mounted (not gated). */
+const AfterMessagesSlot: FC = () => {
+ const { AfterMessages } = useContext(ThreadComponentsContext);
+ if (!AfterMessages) return null;
+ return <AfterMessages />;
+};
+
const ThreadMessage: FC = () => {
const { AssistantMessage: AssistantMessageComponent = AssistantMessage } =
useContext(MessageComponentsContext);
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index 8f40d5a47c..82cbd2e25b 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -2164,7 +2164,7 @@ const Conversations = ({
: [];
const liveArtifactDeck =
liveArtifacts.length > 0 && artifactDeckThreadId ? (
- <div className="mb-2 flex flex-col gap-2">
+ <div className="flex flex-col gap-2">
{liveArtifacts.map(artifact => (
<ArtifactCardAdapter
key={artifact.artifactId}
@@ -2216,7 +2216,6 @@ const Conversations = ({
{sendErrorBanner}
{stallWarningBanner}
{sendAdvisoryBanner}
- {liveArtifactDeck}
{/* The core's run queue for this thread; renders nothing while empty. */}
<ComposerMessageQueue />
{/* Where this conversation works. Last, so it sits directly on the
@@ -2338,6 +2337,7 @@ const Conversations = ({
onOpenHumanMode={() => openTinyVoice(chatMascot, navigate)}
onSwitchToMicCloud={() => setComposerOverride('mic-cloud')}
onModelChange={applyComposerModel}
+ afterMessages={liveArtifactDeck}
/>
{/* The transcript-local overlays: background processes and the Agent
Process Source panel. Mounted beside the Thread (not inside it)
diff --git a/app/src/features/conversations/aui/ArtifactCardAdapter.tsx b/app/src/features/conversations/aui/ArtifactCardAdapter.tsx
index 024853b4a8..fc1fad7a5c 100644
--- a/app/src/features/conversations/aui/ArtifactCardAdapter.tsx
+++ b/app/src/features/conversations/aui/ArtifactCardAdapter.tsx
@@ -58,8 +58,19 @@ export function ArtifactCardAdapter({ artifact, onRetry, onOpenPreview }: Artifa
}
};
+ const handleKeyDown = (e: React.KeyboardEvent) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ handleClick();
+ }
+ };
+
return (
<div
+ role={isReady && onOpenPreview ? 'button' : undefined}
+ tabIndex={isReady && onOpenPreview ? 0 : undefined}
+ onClick={handleClick}
+ onKeyDown={isReady && onOpenPreview ? handleKeyDown : undefined}
className={'flex flex-col items-start gap-1.5' + (isReady ? ' cursor-pointer' : '')}
data-testid="artifact-card-adapter"
>
diff --git a/app/src/features/conversations/aui/ArtifactPreviewPanel.tsx b/app/src/features/conversations/aui/ArtifactPreviewPanel.tsx
index 67c9bea0bc..f3a421d4e6 100644
--- a/app/src/features/conversations/aui/ArtifactPreviewPanel.tsx
+++ b/app/src/features/conversations/aui/ArtifactPreviewPanel.tsx
@@ -19,7 +19,6 @@ import {
useState,
} from 'react';
-import { Button } from '../../../components/ui';
import { useT } from '../../../lib/i18n/I18nContext';
import { useAppSelector } from '../../../store/hooks';
import type { ArtifactSnapshot } from '../../../store/chatRuntimeSlice';
@@ -105,7 +104,31 @@ export function ArtifactPreviewPanel({ artifactId, onClose }: ArtifactPreviewPan
return () => { window.removeEventListener('mousemove', onMove); window.removeEventListener('mouseup', onUp); };
}, []);
- const showTabs = allArtifacts.length > 1;
+ // Tab close: remove from local tab list, close panel if last
+ const [closedIds, setClosedIds] = useState<Set<string>>(new Set());
+ const visibleTabs = useMemo(
+ () => allArtifacts.filter(a => !closedIds.has(a.artifactId)),
+ [allArtifacts, closedIds],
+ );
+ const handleCloseTab = useCallback((id: string) => {
+ setClosedIds(prev => {
+ const next = new Set(prev);
+ next.add(id);
+ return next;
+ });
+ // If closing the active tab, switch to the next one.
+ setActiveId(prev => {
+ if (prev !== id) return prev;
+ const remaining = visibleTabs.filter(a => a.artifactId !== id);
+ return remaining.length > 0 ? remaining[0].artifactId : prev;
+ });
+ // If all tabs closed, close the panel
+ if (visibleTabs.length <= 1) {
+ onClose();
+ }
+ }, [visibleTabs, onClose]);
+
+ const showTabs = visibleTabs.length > 1;
return (
<div
@@ -122,19 +145,34 @@ export function ArtifactPreviewPanel({ artifactId, onClose }: ArtifactPreviewPan
<div className="flex items-center justify-between border-b shrink-0">
<div className="flex items-center gap-1 min-w-0 flex-1 overflow-x-auto">
{showTabs ? (
- allArtifacts.map(a => (
- <button
+ visibleTabs.map(a => (
+ <div
key={a.artifactId}
- onClick={() => setActiveId(a.artifactId)}
- className={`flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium border-b-2 transition-colors shrink-0 ${
+ className={`group flex items-center gap-1 border-b-2 px-2 py-2.5 transition-colors shrink-0 min-w-0 ${
a.artifactId === activeId
- ? 'border-primary text-foreground'
- : 'border-transparent text-muted-foreground hover:text-foreground'
+ ? 'border-primary'
+ : 'border-transparent'
}`}
>
- <FileText className="h-3.5 w-3.5" />
- <span className="truncate max-w-[120px]">{a.title}</span>
- </button>
+ <button
+ onClick={() => setActiveId(a.artifactId)}
+ className={`flex min-w-0 items-center gap-1.5 text-xs font-medium transition-colors ${
+ a.artifactId === activeId
+ ? 'text-foreground'
+ : 'text-muted-foreground hover:text-foreground'
+ }`}
+ >
+ <FileText className="h-3.5 w-3.5 shrink-0" />
+ <span className="truncate max-w-[110px]">{a.title}</span>
+ </button>
+ <button
+ onClick={() => handleCloseTab(a.artifactId)}
+ className="ml-0.5 rounded p-0.5 text-muted-foreground/50 hover:bg-accent hover:text-foreground shrink-0"
+ title="Close artifact"
+ >
+ <X className="h-3 w-3" />
+ </button>
+ </div>
))
) : (
<div className="flex items-center gap-2 px-4 py-2.5 min-w-0">
@@ -145,9 +183,9 @@ export function ArtifactPreviewPanel({ artifactId, onClose }: ArtifactPreviewPan
</div>
)}
</div>
- <Button variant="ghost" size="xs" onClick={onClose} className="mr-2 shrink-0">
+ <button onClick={onClose} className="mr-2 shrink-0 inline-flex items-center justify-center rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground">
<X className="h-4 w-4" />
- </Button>
+ </button>
</div>
{/* Content */}
@@ -384,10 +422,10 @@ function EditableTextViewer({
</button>
</div>
- <Button variant="ghost" size="xs" onClick={handleCopy} title="Copy to clipboard">
+ <button onClick={handleCopy} title="Copy to clipboard" className="inline-flex items-center justify-center rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground">
{copied ? <Check className="h-3.5 w-3.5 text-green-500" /> : <Clipboard className="h-3.5 w-3.5" />}
- </Button>
- <Button variant="ghost" size="xs" onClick={handleSave} disabled={saving} title="Save as new version">
+ </button>
+ <button onClick={handleSave} disabled={saving} title="Save as new version" className="inline-flex items-center justify-center rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50">
{saving ? (
<div className="h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary border-t-transparent" />
) : saved ? (
@@ -395,7 +433,7 @@ function EditableTextViewer({
) : (
<Save className="h-3.5 w-3.5" />
)}
- </Button>
+ </button>
</div>
</div>
diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsx
index 8cac0f9bd8..721c092bf3 100644
--- a/app/src/features/conversations/components/AssistantUiChat.tsx
+++ b/app/src/features/conversations/components/AssistantUiChat.tsx
@@ -112,6 +112,7 @@ export function AssistantUiChat({
composerHeader,
composerFooterExtras,
composerReplacement,
+ afterMessages,
inputValue,
onInputValueChange,
onEscape,
@@ -144,6 +145,7 @@ export function AssistantUiChat({
* normal composer.
*/
composerReplacement?: ReactNode;
+ afterMessages?: ReactNode;
inputValue: string;
onInputValueChange: (value: string) => void;
/** Returns whether Escape acted (stopped a run); `false` lets the key through. */
@@ -234,6 +236,13 @@ export function AssistantUiChat({
composerReplacementRef.current = composerReplacement;
const hasComposerReplacement = composerReplacement !== undefined;
const ComposerReplacement = useCallback(() => <>{composerReplacementRef.current}</>, []);
+ // Artifact cards from versioned tools render as part of the transcript
+ // (after the last message), not in the composer header — the cards are
+ // messages' content, not attachments. Stable type through a ref, same
+ // pattern as composerHeader above.
+ const afterMessagesRef = useRef(afterMessages);
+ afterMessagesRef.current = afterMessages;
+ const AfterMessages = useCallback(() => <>{afterMessagesRef.current}</>, []);
const ComposerAttachments = useCallback(() => {
const { attachments, attachmentInteractionBlocked, onRemoveAttachment } = slotPropsRef.current;
return (
@@ -327,6 +336,9 @@ export function AssistantUiChat({
RunningStatus: AgentRunningStatus,
// A crashed turn's partial reply and its "Interrupted" marker.
TranscriptFooter: InterruptedTurnNotice,
+ // Versioned-artifact cards live in the transcript after the last
+ // message (see `AfterMessages` slot in thread.tsx).
+ AfterMessages,
// The web pages the turn fetched, grouped from its `source` parts into
// one collapsed disclosure under the answer.
SourceGroup: ChatSources,