Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat: add version tags to same-name artifacts in conversation
Gus11a2abd3f21b
diff --git a/src/web/src/components/agent-chat/agent-chat-view.test.ts b/src/web/src/components/agent-chat/agent-chat-view.test.tsindex 8d2f063ed..15af26e13 100644--- a/src/web/src/components/agent-chat/agent-chat-view.test.ts+++ b/src/web/src/components/agent-chat/agent-chat-view.test.ts@@ -219,11 +219,11 @@ function artifact(id: string, created_at: string): Artifact {return {id,conversation_id: "conv1",+ agent_id: "agent1",filename: "file.txt",content_type: "text/plain",size: 100,source: "agent",- r2_key: `key-${id}`,created_at,};}@@ -326,7 +326,7 @@ function msgInConv(id: string, created_at: string, conversation_id: string): Mes}function artifactInConv(id: string, created_at: string, conversation_id: string): Artifact {- return { id, conversation_id, filename: "file.txt", content_type: "text/plain", size: 100, source: "agent", r2_key: `key-${id}`, created_at };+ return { id, conversation_id, agent_id: "agent1", filename: "file.txt", content_type: "text/plain", size: 100, source: "agent", created_at };}describe("buildTimeline — conversation grouping", () => {diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsxindex 9029f8f59..073ededa2 100644--- a/src/web/src/components/agent-chat/agent-chat-view.tsx+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx@@ -271,7 +271,7 @@ function NapSeparator({ agentName }: { agentName: string }) {);}-function ArtifactCard({ artifact, onClick }: { artifact: Artifact; onClick: (a: Artifact) => void }) {+function ArtifactCard({ artifact, version, hasDuplicates, onClick }: { artifact: Artifact; version: number; hasDuplicates: boolean; onClick: (a: Artifact) => void }) {return (<buttononClick={() => onClick(artifact)}@@ -283,7 +283,14 @@ function ArtifactCard({ artifact, onClick }: { artifact: Artifact; onClick: (a:><FileText className="size-4 shrink-0 text-muted-foreground" /><div className="min-w-0 flex-1">- <p className="text-sm font-medium truncate">{artifact.filename}</p>+ <p className="text-sm font-medium truncate">+ {artifact.filename}+ {hasDuplicates && (+ <span className="ml-1.5 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal">+ v{version}+ </span>+ )}+ </p><p className="text-xs text-muted-foreground">{formatSize(artifact.size)}</p></div></button>@@ -352,6 +359,23 @@ export function AgentChatView() {const agentArtifacts = useMemo(() => artifacts.filter((a) => a.source === "agent"), [artifacts]);+ const { versionMap, duplicateFilenames } = useMemo(() => {+ const groups = new Map<string, Artifact[]>();+ for (const a of agentArtifacts) {+ const group = groups.get(a.filename) || [];+ group.push(a);+ groups.set(a.filename, group);+ }+ const vm = new Map<string, number>();+ const dupes = new Set<string>();+ for (const [filename, group] of groups) {+ group.sort((a, b) => a.created_at.localeCompare(b.created_at));+ if (group.length > 1) dupes.add(filename);+ group.forEach((a, i) => vm.set(a.id, i + 1));+ }+ return { versionMap: vm, duplicateFilenames: dupes };+ }, [agentArtifacts]);+const timeline = useMemo(() => buildTimeline(messages, agentArtifacts, napMarkers, conversation?.id), [messages, agentArtifacts, napMarkers, conversation?.id]);const handleArtifactClick = useCallback((artifact: Artifact) => {@@ -1513,6 +1537,8 @@ export function AgentChatView() {<ArtifactCardkey={`artifact-${item.data.id}`}artifact={item.data}+ version={versionMap.get(item.data.id) ?? 1}+ hasDuplicates={duplicateFilenames.has(item.data.filename)}onClick={handleArtifactClick}/>);@@ -1834,6 +1860,8 @@ export function AgentChatView() {artifacts={agentArtifacts}workspaceId={workspaceId}initialArtifact={selectedArtifact}+ versionMap={versionMap}+ duplicateFilenames={duplicateFilenames}/><EmailEventSheetdiff --git a/src/web/src/components/agent-chat/artifact-sheet.tsx b/src/web/src/components/agent-chat/artifact-sheet.tsxindex a7a536bd9..32343e54b 100644--- a/src/web/src/components/agent-chat/artifact-sheet.tsx+++ b/src/web/src/components/agent-chat/artifact-sheet.tsx@@ -25,13 +25,15 @@ interface ArtifactSheetProps {artifacts: Artifact[];workspaceId: string;initialArtifact?: Artifact | null;+ versionMap: Map<string, number>;+ duplicateFilenames: Set<string>;}const MIN_WIDTH = 320;const MAX_WIDTH_RATIO = 0.8;const DEFAULT_WIDTH = 448;-export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, initialArtifact = null }: ArtifactSheetProps) {+export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, initialArtifact = null, versionMap, duplicateFilenames }: ArtifactSheetProps) {const [selectedArtifact, setSelectedArtifact] = useState<Artifact | null>(null);const [width, setWidth] = useState(DEFAULT_WIDTH);const dragging = useRef(false);@@ -98,7 +100,14 @@ export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, init><ArrowLeft className="size-4" /></Button>- <SheetTitle className="truncate flex-1">{selectedArtifact.filename}</SheetTitle>+ <SheetTitle className="truncate flex-1">+ {selectedArtifact.filename}+ {duplicateFilenames.has(selectedArtifact.filename) && (+ <span className="ml-1.5 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal">+ v{versionMap.get(selectedArtifact.id) ?? 1}+ </span>+ )}+ </SheetTitle><Buttonvariant="ghost"size="icon-sm"@@ -139,11 +148,18 @@ export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, init<buttonkey={a.id}onClick={() => setSelectedArtifact(a)}- className="flex items-start gap-3 w-full rounded-lg px-3 py-2.5 text-left hover:bg-muted/50 transition-colors"+ className="flex items-center gap-3 w-full rounded-lg px-3 py-2.5 text-left hover:bg-muted/50 transition-colors">- <FileText className="size-4 mt-0.5 shrink-0 text-muted-foreground" />+ <FileText className="size-4 shrink-0 text-muted-foreground" /><div className="min-w-0 flex-1">- <p className="text-sm font-medium truncate">{a.filename}</p>+ <p className="text-sm font-medium truncate">+ {a.filename}+ {duplicateFilenames.has(a.filename) && (+ <span className="ml-1.5 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal">+ v{versionMap.get(a.id) ?? 1}+ </span>+ )}+ </p><p className="text-xs text-muted-foreground">{formatSize(a.size)} · {new Date(a.created_at).toLocaleString()}</p>