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 artifact sidebar popup to issue sheet
Gus7eb776c7f1a8
diff --git a/src/web/src/app/(app)/w/[slug]/issues/page.tsx b/src/web/src/app/(app)/w/[slug]/issues/page.tsxindex 49ece2717..87b368311 100644--- a/src/web/src/app/(app)/w/[slug]/issues/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/issues/page.tsx@@ -19,6 +19,8 @@ import { cn } from "@/lib/utils";import { toast } from "sonner";import { DndContext, DragOverlay, PointerSensor, useSensor, useSensors, useDroppable, useDraggable, type DragEndEvent, type DragStartEvent } from "@dnd-kit/core";import { IssueSheet } from "@/components/issues/issue-sheet";+import { ArtifactSheet } from "@/components/agent-chat/artifact-sheet";+import { isPreviewable, getArtifactUrl, computeArtifactVersions } from "@/components/artifact-content-renderer";const SIDECAR_DEFAULT_WIDTH = 448;@@ -250,6 +252,8 @@ export default function IssuesPage() {const [sidecarWidth, setSidecarWidth] = useState(SIDECAR_DEFAULT_WIDTH);const [traceTasks, setTraceTasks] = useState<TraceTask[] | null>(null);const [activeDragId, setActiveDragId] = useState<string | null>(null);+ const [artifactSheetOpen, setArtifactSheetOpen] = useState(false);+ const [selectedArtifact, setSelectedArtifact] = useState<Artifact | null>(null);const pendingStatusUpdate = useRef<string | null>(null);const refreshSeqRef = useRef(0);const selectedIdRef = useRef<string | null>(null);@@ -257,6 +261,21 @@ export default function IssuesPage() {const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 8 } }));const agentsById = useMemo(() => new Map(agents.map(a => [a.id, a])), [agents]);+ const issueArtifacts = useMemo(() => detail?.artifacts ?? [], [detail?.artifacts]);+ const { versionMap: artifactVersionMap, duplicateFilenames: artifactDuplicateFilenames } = useMemo(+ () => computeArtifactVersions(issueArtifacts),+ [issueArtifacts],+ );++ const handleArtifactClick = useCallback((artifact: Artifact) => {+ if (isPreviewable(artifact)) {+ setSelectedArtifact(artifact);+ setArtifactSheetOpen(true);+ } else {+ window.open(getArtifactUrl(artifact.id, workspaceId, true), "_blank");+ }+ }, [workspaceId]);+async function reload() {setLoading(true);try {@@ -801,6 +820,20 @@ export default function IssuesPage() {onStatusChange={handleStatusChange}onCommented={() => selectedId && openIssue(selectedId)}onDispatched={(id) => { silentReload(); openIssue(id); }}+ onArtifactClick={handleArtifactClick}+ />++ <ArtifactSheet+ open={artifactSheetOpen}+ onOpenChange={(v) => {+ setArtifactSheetOpen(v);+ if (!v) setTimeout(() => setSelectedArtifact(null), 300);+ }}+ artifacts={issueArtifacts}+ workspaceId={workspaceId}+ initialArtifact={selectedArtifact}+ versionMap={artifactVersionMap}+ duplicateFilenames={artifactDuplicateFilenames}/></div>);diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsxindex 9620742b6..02a3f73c9 100644--- a/src/web/src/components/agent-chat/agent-chat-view.tsx+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx@@ -50,7 +50,7 @@ import { highlightMentions } from "@/lib/highlight-mentions";import { ArtifactSheet, formatSize } from "@/components/agent-chat/artifact-sheet";import { EmailEventSheet } from "@/components/agent-chat/email-event-sheet";import { IssueSheet } from "@/components/issues/issue-sheet";-import { isPreviewable, getArtifactUrl } from "@/components/artifact-content-renderer";+import { isPreviewable, getArtifactUrl, computeArtifactVersions } from "@/components/artifact-content-renderer";import { FollowUpBuffer } from "@/components/agent-chat/follow-up-buffer";import { ScrollToBottomButton } from "@/components/ui/scroll-to-bottom-button";import { MessageItem } from "@/components/agent-chat/message-list";@@ -338,6 +338,7 @@ export function AgentChatView({const [artifacts, setArtifacts] = useState<Artifact[]>([]);const [artifactSheetOpen, setArtifactSheetOpen] = useState(false);const [selectedArtifact, setSelectedArtifact] = useState<Artifact | null>(null);+ const [artifactSheetSource, setArtifactSheetSource] = useState<"agent" | "issue" | null>(null);const [emailSheetOpen, setEmailSheetOpen] = useState(false);const [selectedEmailId, setSelectedEmailId] = useState<string | null>(null);const [issueSheetOpen, setIssueSheetOpen] = useState(false);@@ -381,28 +382,33 @@ 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 { versionMap, duplicateFilenames } = useMemo(() => computeArtifactVersions(agentArtifacts), [agentArtifacts]);++ const artifactSheetArtifacts = useMemo(+ () => artifactSheetSource === "agent" ? agentArtifacts : artifactSheetSource === "issue" ? (issueDetail?.artifacts ?? []) : [],+ [artifactSheetSource, agentArtifacts, issueDetail?.artifacts],+ );+ const { versionMap: artifactSheetVersionMap, duplicateFilenames: artifactSheetDuplicateFilenames } = useMemo(+ () => computeArtifactVersions(artifactSheetArtifacts),+ [artifactSheetArtifacts],+ );const timeline = useMemo(() => buildTimeline(messages, agentArtifacts, napMarkers, conversation?.id), [messages, agentArtifacts, napMarkers, conversation?.id]);const handleArtifactClick = useCallback((artifact: Artifact) => {if (isPreviewable(artifact)) {setSelectedArtifact(artifact);+ setArtifactSheetSource("agent");+ setArtifactSheetOpen(true);+ } else {+ window.open(getArtifactUrl(artifact.id, workspaceId, true), "_blank");+ }+ }, [workspaceId]);++ const handleIssueArtifactClick = useCallback((artifact: Artifact) => {+ if (isPreviewable(artifact)) {+ setSelectedArtifact(artifact);+ setArtifactSheetSource("issue");setArtifactSheetOpen(true);} else {window.open(getArtifactUrl(artifact.id, workspaceId, true), "_blank");@@ -1884,7 +1890,7 @@ export function AgentChatView({<Buttonvariant="ghost"size="icon-sm"- onClick={() => setArtifactSheetOpen(true)}+ onClick={() => { setArtifactSheetSource("agent"); setArtifactSheetOpen(true); }}className="relative rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"/>}>@@ -1993,13 +1999,13 @@ export function AgentChatView({open={artifactSheetOpen}onOpenChange={(v) => {setArtifactSheetOpen(v);- if (!v) setTimeout(() => setSelectedArtifact(null), 300);+ if (!v) setTimeout(() => { setSelectedArtifact(null); setArtifactSheetSource(null); }, 300);}}- artifacts={agentArtifacts}+ artifacts={artifactSheetArtifacts}workspaceId={workspaceId}initialArtifact={selectedArtifact}- versionMap={versionMap}- duplicateFilenames={duplicateFilenames}+ versionMap={artifactSheetVersionMap}+ duplicateFilenames={artifactSheetDuplicateFilenames}/><EmailEventSheet@@ -2056,6 +2062,7 @@ export function AgentChatView({onCommented={() => {if (selectedIssueId) openIssue(selectedIssueId);}}+ onArtifactClick={handleIssueArtifactClick}/></>);diff --git a/src/web/src/components/artifact-content-renderer.tsx b/src/web/src/components/artifact-content-renderer.tsxindex 6d174be20..52cce4e1d 100644--- a/src/web/src/components/artifact-content-renderer.tsx+++ b/src/web/src/components/artifact-content-renderer.tsx@@ -40,6 +40,23 @@ export function getArtifactUrl(id: string, workspaceId: string, download?: boolereturn `/api/artifacts/${id}/content?${params}`;}+export function computeArtifactVersions(artifacts: Artifact[]): { versionMap: Map<string, number>; duplicateFilenames: Set<string> } {+ const groups = new Map<string, Artifact[]>();+ for (const a of artifacts) {+ const group = groups.get(a.filename) || [];+ group.push(a);+ groups.set(a.filename, group);+ }+ const versionMap = new Map<string, number>();+ const duplicateFilenames = new Set<string>();+ for (const [filename, group] of groups) {+ group.sort((a, b) => a.created_at.localeCompare(b.created_at));+ if (group.length > 1) duplicateFilenames.add(filename);+ group.forEach((a, i) => versionMap.set(a.id, i + 1));+ }+ return { versionMap, duplicateFilenames };+}+function isMarkdown(filename: string): boolean {return /\.md$/i.test(filename);}diff --git a/src/web/src/components/issues/issue-sheet.tsx b/src/web/src/components/issues/issue-sheet.tsxindex ffc5634d6..7e426ed75 100644--- a/src/web/src/components/issues/issue-sheet.tsx+++ b/src/web/src/components/issues/issue-sheet.tsx@@ -27,6 +27,8 @@ import { cn } from "@/lib/utils";import { toast } from "sonner";import { Streamdown } from "streamdown";import type { Agent, Artifact, Issue, IssueComment, Message, TaskApi } from "@alook/shared";+import { isPreviewable, getArtifactUrl } from "@/components/artifact-content-renderer";+import { formatSize } from "@/components/agent-chat/artifact-sheet";import { isTerminalIssueStatus } from "@alook/shared";import type { TraceTask } from "@/lib/api";import { updateIssue } from "@/lib/api";@@ -137,29 +139,41 @@ function CommentRow({ comment, agents }: { comment: IssueComment; agents: Agent[);}-function AttachmentList({ artifacts, workspaceId }: { artifacts: Artifact[]; workspaceId: string }) {+function AttachmentList({ artifacts, workspaceId, onArtifactClick }: { artifacts: Artifact[]; workspaceId: string; onArtifactClick?: (artifact: Artifact) => void }) {if (artifacts.length === 0) return null;+ const baseCls = "flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-accent";return (<div className="space-y-1">- {artifacts.map((artifact) => (- <a- key={artifact.id}- href={`/api/artifacts/${artifact.id}/content?workspace_id=${workspaceId}&download=1`}- target="_blank"- rel="noopener noreferrer"- className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-accent"- >- <FileIcon className="size-3.5 shrink-0 text-muted-foreground" />- <span className="min-w-0 flex-1 truncate">{artifact.filename}</span>- <span className="shrink-0 text-xs text-muted-foreground">- {artifact.size < 1024- ? `${artifact.size} B`- : artifact.size < 1024 * 1024- ? `${(artifact.size / 1024).toFixed(1)} KB`- : `${(artifact.size / (1024 * 1024)).toFixed(1)} MB`}- </span>- </a>- ))}+ {artifacts.map((artifact) => {+ const canPreview = onArtifactClick && isPreviewable(artifact);+ const inner = (+ <>+ <FileIcon className="size-3.5 shrink-0 text-muted-foreground" />+ <span className="min-w-0 flex-1 truncate">{artifact.filename}</span>+ <span className="shrink-0 text-xs text-muted-foreground">{formatSize(artifact.size)}</span>+ </>+ );+ return canPreview ? (+ <button+ key={artifact.id}+ type="button"+ onClick={() => onArtifactClick(artifact)}+ className={cn(baseCls, "w-full text-left")}+ >+ {inner}+ </button>+ ) : (+ <a+ key={artifact.id}+ href={getArtifactUrl(artifact.id, workspaceId, true)}+ target="_blank"+ rel="noopener noreferrer"+ className={baseCls}+ >+ {inner}+ </a>+ );+ })}</div>);}@@ -188,6 +202,7 @@ export interface IssueSheetProps {onStatusChange?: (issueId: string, status: string) => Promise<void>;onCommented?: () => void;onDispatched?: (issueId: string) => void;+ onArtifactClick?: (artifact: Artifact) => void;}export function IssueSheet({@@ -212,6 +227,7 @@ export function IssueSheet({onStatusChange,onCommented,onDispatched,+ onArtifactClick,}: IssueSheetProps) {const mode = issue ? "detail" : "create";@@ -647,7 +663,7 @@ export function IssueSheet({{/* Attachments (detail mode) */}{mode === "detail" && detail?.artifacts && detail.artifacts.length > 0 && (<div className="shrink-0 px-2 sm:px-3 py-2">- <AttachmentList artifacts={detail.artifacts} workspaceId={workspaceId} />+ <AttachmentList artifacts={detail.artifacts} workspaceId={workspaceId} onArtifactClick={onArtifactClick} /></div>)}</>