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: attribute runtime errors in chat & remove artifact list button
Gus493659a56038
diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsxindex 21c623de6..5714320e3 100644--- a/src/web/src/components/agent-chat/agent-chat-view.tsx+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx@@ -81,7 +81,6 @@ import {import {ArrowUp,BedDouble,- Box,FileText,Loader2,Mail,@@ -549,6 +548,7 @@ export function AgentChatView({const { workspaceId, slug } = useWorkspace();const {agents,+ runtimes,agentLinks,activeTaskCounts,subscribeWs,@@ -561,6 +561,13 @@ export function AgentChatView({setAgentId: setChannelAgentId,} = useChannel();const agentId = propAgentId ?? (params.id as string);+ // Resolve the conversation agent's runtime provider so runtime errors can be+ // attributed to the runtime CLI (Claude Code / Codex / OpenCode) — issue #236.+ const activeAgent = agents.find((a) => a.id === agentId);+ const activeRuntime = activeAgent?.runtime_id+ ? runtimes.find((r) => r.id === activeAgent.runtime_id)+ : null;+ const runtimeProvider = activeRuntime?.provider ?? null;const scrollToTaskId =propScrollToTaskId !== undefined? propScrollToTaskId@@ -597,9 +604,6 @@ export function AgentChatView({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 [calendarEventSheetOpen, setCalendarEventSheetOpen] = useState(false);@@ -686,23 +690,6 @@ export function AgentChatView({[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],@@ -716,7 +703,6 @@ export function AgentChatView({(artifact: Artifact) => {if (isPreviewable(artifact)) {setSelectedArtifact(artifact);- setArtifactSheetSource("agent");setArtifactSheetOpen(true);} else {window.open(getArtifactUrl(artifact.id, workspaceId, true), "_blank");@@ -729,7 +715,6 @@ export function AgentChatView({(artifact: Artifact) => {if (isPreviewable(artifact)) {setSelectedArtifact(artifact);- setArtifactSheetSource("issue");setArtifactSheetOpen(true);} else {window.open(getArtifactUrl(artifact.id, workspaceId, true), "_blank");@@ -2804,6 +2789,7 @@ export function AgentChatView({msg.role === "assistant" ? handleToggleFlag : undefined}groupPosition={pos ?? "solo"}+ provider={runtimeProvider}/></div>);@@ -2820,6 +2806,7 @@ export function AgentChatView({task={activeTask}messages={taskMessages}connectionLost={connectionLost}+ provider={runtimeProvider}/></div>)}@@ -2910,24 +2897,6 @@ export function AgentChatView({: `${agentName} is well-rested and ready to go`}</TooltipContent></Tooltip>- <Button- variant="ghost"- size="sm"- onClick={() => {- setMenuOpen(false);- setArtifactSheetSource("agent");- setArtifactSheetOpen(true);- }}- className="relative w-full justify-start gap-2 rounded-md text-muted-foreground hover:text-foreground"- >- <Box className="size-3.5" />- <span className="text-xs">Artifacts</span>- {agentArtifacts.length > 0 && (- <span className="ml-auto flex size-4 items-center justify-center rounded-full bg-primary text-[9px] font-medium text-primary-foreground">- {agentArtifacts.length}- </span>- )}- </Button></PopoverContent></Popover>)}@@ -3149,14 +3118,13 @@ export function AgentChatView({if (!v)setTimeout(() => {setSelectedArtifact(null);- setArtifactSheetSource(null);}, 300);}}- artifacts={artifactSheetArtifacts}+ artifacts={selectedArtifact ? [selectedArtifact] : agentArtifacts}workspaceId={workspaceId}initialArtifact={selectedArtifact}- versionMap={artifactSheetVersionMap}- duplicateFilenames={artifactSheetDuplicateFilenames}+ 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 860937aae..b306d3597 100644--- a/src/web/src/components/agent-chat/artifact-sheet.tsx+++ b/src/web/src/components/agent-chat/artifact-sheet.tsx@@ -75,13 +75,7 @@ export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, initvariant="ghost"size="icon-sm"className="shrink-0 sm:hidden"- onClick={() => {- if (artifacts.length > 1) {- setSelectedArtifact(null);- } else {- handleOpenChange(false);- }- }}+ onClick={() => handleOpenChange(false)}><ArrowLeft className="size-4" /></Button>diff --git a/src/web/src/components/agent-chat/historical-task-thinking.tsx b/src/web/src/components/agent-chat/historical-task-thinking.tsxindex fad585571..a2e4eaa09 100644--- a/src/web/src/components/agent-chat/historical-task-thinking.tsx+++ b/src/web/src/components/agent-chat/historical-task-thinking.tsx@@ -27,10 +27,13 @@ export function HistoricalTaskThinking({taskId,thinkingCount,workspaceId,+ provider,}: {taskId: string;thinkingCount: number;workspaceId: string;+ /** Provider of the conversation's agent runtime, used to attribute runtime errors (issue #236). */+ provider?: string | null;}) {const [messages, setMessages] = useState<TaskMessageResponse[]>([]);const [loading, setLoading] = useState(false);@@ -57,6 +60,7 @@ export function HistoricalTaskThinking({thinkingCountHint={thinkingCount}onExpandThinking={fetchMessages}thinkingLoading={loading}+ provider={provider}/>);}diff --git a/src/web/src/components/agent-chat/message-list.tsx b/src/web/src/components/agent-chat/message-list.tsxindex 14a4c0cd0..6827f5383 100644--- a/src/web/src/components/agent-chat/message-list.tsx+++ b/src/web/src/components/agent-chat/message-list.tsx@@ -8,6 +8,7 @@ import { Streamdown } from "streamdown";import { highlightMentions } from "@/lib/highlight-mentions";import { TaskStream } from "@/components/task-stream";import { HistoricalTaskThinking } from "@/components/agent-chat/historical-task-thinking";+import { RuntimeErrorBlock } from "@/components/agent-chat/runtime-error-block";import { FileText, Calendar, CircleDot, Mail, Flag, Copy, Check } from "lucide-react";import { getEventIconType, type GroupPosition } from "@/components/agent-chat/agent-chat-view";@@ -39,6 +40,8 @@ export interface MessageItemProps {isFlagged?: boolean;onToggleFlag?: (messageId: string) => void;groupPosition?: GroupPosition;+ /** Provider of the conversation's agent runtime, used to attribute runtime errors (issue #236). */+ provider?: string | null;}function EventMessageIcon({ content, conversationType }: { content: string; conversationType?: string | null }) {@@ -136,6 +139,7 @@ export const MessageItem = memo(function MessageItem({isFlagged,onToggleFlag,groupPosition = "solo",+ provider,}: MessageItemProps) {const { copy, copied } = useCopyToClipboard();@@ -213,6 +217,7 @@ export const MessageItem = memo(function MessageItem({messages={taskMessages}connectionLost={connectionLost}onRetry={onRetry}+ provider={provider}/>{isTaskDone && actionButtons}</div>@@ -275,11 +280,20 @@ export const MessageItem = memo(function MessageItem({isFlagged && "bg-muted/30 rounded-lg px-2 -mx-2")} data-message-id={msg.id} data-quote-source {...(msg.task_id ? { "data-task-id": msg.task_id } : {})}>{targetConvId && msg.role === "assistant" && msg.task_id && thinkingCount > 1 && (- <HistoricalTaskThinking taskId={msg.task_id} thinkingCount={thinkingCount - 1} workspaceId={workspaceId} />+ <HistoricalTaskThinking taskId={msg.task_id} thinkingCount={thinkingCount - 1} workspaceId={workspaceId} provider={provider} />+ )}+ {msg.metadata?.error_source === "runtime" ? (+ <div className="px-1 py-1">+ <RuntimeErrorBlock+ provider={(msg.metadata.provider as string | null | undefined) ?? provider}+ message={msg.content}+ />+ </div>+ ) : (+ <div className="markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground">+ <Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }} linkSafety={{ enabled: false }} allowedTags={MENTION_ALLOWED_TAGS} literalTagContent={MENTION_LITERAL_TAGS} components={mentionComponents}>{highlightMentions(msg.content, agents)}</Streamdown>+ </div>)}- <div className="markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground">- <Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }} linkSafety={{ enabled: false }} allowedTags={MENTION_ALLOWED_TAGS} literalTagContent={MENTION_LITERAL_TAGS} components={mentionComponents}>{highlightMentions(msg.content, agents)}</Streamdown>- </div>{actionButtons}</div>) : null}diff --git a/src/web/src/components/agent-chat/runtime-error-block.tsx b/src/web/src/components/agent-chat/runtime-error-block.tsxnew file mode 100644index 000000000..560c8ca98--- /dev/null+++ b/src/web/src/components/agent-chat/runtime-error-block.tsx@@ -0,0 +1,64 @@+"use client";++import { useState } from "react";+import { AlertCircle, RotateCw, Loader2 } from "lucide-react";+import { runtimeDisplayName } from "@/lib/runtime-display";++/**+ * A visually distinct error block that attributes a runtime error to the agent+ * runtime CLI (Claude Code / Codex / OpenCode) on the user's machine, making it+ * clear the error did NOT originate from Alook. See issue #236.+ *+ * Shared by message-list (failed-task chat message) and task-stream (in-stream+ * + task-level errors) so the presentation is identical everywhere.+ */+export function RuntimeErrorBlock({+ provider,+ message,+ onRetry,+ retrying: retryingProp,+}: {+ provider?: string | null;+ message: string;+ onRetry?: () => void | Promise<void>;+ retrying?: boolean;+}) {+ const [retryingLocal, setRetryingLocal] = useState(false);+ const retrying = retryingProp ?? retryingLocal;++ const handleRetry = async () => {+ if (!onRetry) return;+ setRetryingLocal(true);+ try {+ await onRetry();+ } finally {+ setRetryingLocal(false);+ }+ };++ return (+ <div className="rounded-md border border-destructive/30 bg-destructive/5 p-2 max-w-full overflow-hidden">+ <div className="flex items-center gap-2">+ <p className="flex items-center gap-1.5 text-sm font-semibold text-destructive min-w-0">+ <AlertCircle className="size-3.5 shrink-0" />+ <span>Error from {runtimeDisplayName(provider)}</span>+ </p>+ {onRetry && (+ <button+ type="button"+ onClick={handleRetry}+ disabled={retrying}+ className="ml-auto shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1"+ >+ {retrying ? <Loader2 className="size-3 animate-spin" /> : <RotateCw className="size-3" />}+ Retry+ </button>+ )}+ </div>+ <p className="mt-1.5 text-sm text-destructive/90 wrap-anywhere whitespace-pre-wrap">{message}</p>+ <p className="mt-1.5 text-xs text-muted-foreground">+ This came from the agent runtime on your machine, not from Alook.+ </p>+ </div>+ );+}diff --git a/src/web/src/components/task-stream.tsx b/src/web/src/components/task-stream.tsxindex 5fdcedf05..8ff8e7be6 100644--- a/src/web/src/components/task-stream.tsx+++ b/src/web/src/components/task-stream.tsx@@ -7,11 +7,10 @@ import type { TaskMessageResponse } from "@alook/shared";import type { TaskApi as Task } from "@alook/shared";import {ChevronRight,- AlertCircle,- RotateCw,Loader2,} from "lucide-react";import { Streamdown } from "streamdown";+import { RuntimeErrorBlock } from "@/components/agent-chat/runtime-error-block";/* ── Grouped stream items ── */@@ -127,6 +126,7 @@ export function TaskStream({thinkingCountHint,onExpandThinking,thinkingLoading,+ provider,}: {task: Task;messages: TaskMessageResponse[];@@ -135,8 +135,9 @@ export function TaskStream({thinkingCountHint?: number;onExpandThinking?: () => void;thinkingLoading?: boolean;+ /** Provider of the conversation's agent runtime, used to attribute runtime errors (issue #236). */+ provider?: string | null;}) {- const [retrying, setRetrying] = useState(false);const allItems = useMemo(() => groupMessages(messages), [messages]);const isRunning = task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled" && task.status !== "superseded";@@ -233,39 +234,23 @@ export function TaskStream({</div>)}- {/* Stream error messages */}+ {/* Stream error messages — attributed to the agent runtime (issue #236) */}{errorItems.length > 0 && (<div className="space-y-1 mt-1">{errorItems.map((item) => (- <p key={item.id} className="text-sm text-destructive flex items-start gap-1.5 min-w-0">- <AlertCircle className="size-3.5 shrink-0 mt-0.5" />- <span className="wrap-anywhere">{item.content}</span>- </p>+ <RuntimeErrorBlock key={item.id} provider={provider} message={item.content} />))}</div>)}- {/* Task-level error display */}+ {/* Task-level error display — attributed to the agent runtime (issue #236) */}{task.status === "failed" && task.error && (- <div className="flex items-start gap-2 mt-2 max-w-full overflow-hidden">- <p className="text-sm text-destructive flex items-start gap-1.5 min-w-0">- <AlertCircle className="size-3.5 shrink-0 mt-0.5" />- <span className="wrap-anywhere">{task.error}</span>- </p>- {onRetry && (- <button- type="button"- onClick={async () => {- setRetrying(true);- try { await onRetry(); } finally { setRetrying(false); }- }}- disabled={retrying}- className="shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1"- >- {retrying ? <Loader2 className="size-3 animate-spin" /> : <RotateCw className="size-3" />}- Retry- </button>- )}+ <div className="mt-2">+ <RuntimeErrorBlock+ provider={provider}+ message={task.error}+ onRetry={onRetry}+ /></div>)}diff --git a/src/web/src/lib/runtime-display.test.ts b/src/web/src/lib/runtime-display.test.tsnew file mode 100644index 000000000..1db3b5932--- /dev/null+++ b/src/web/src/lib/runtime-display.test.ts@@ -0,0 +1,25 @@+import { describe, it, expect } from "vitest";+import { runtimeDisplayName, GENERIC_RUNTIME_NAME } from "./runtime-display";++describe("runtimeDisplayName", () => {+ it("maps known providers to friendly names", () => {+ expect(runtimeDisplayName("claude")).toBe("Claude Code");+ expect(runtimeDisplayName("codex")).toBe("Codex");+ expect(runtimeDisplayName("opencode")).toBe("OpenCode");+ });++ it("falls back to the generic label for undefined / null", () => {+ expect(runtimeDisplayName(undefined)).toBe(GENERIC_RUNTIME_NAME);+ expect(runtimeDisplayName(null)).toBe(GENERIC_RUNTIME_NAME);+ expect(runtimeDisplayName("")).toBe(GENERIC_RUNTIME_NAME);+ });++ it("falls back to the generic label for unknown slugs", () => {+ expect(runtimeDisplayName("gemini")).toBe(GENERIC_RUNTIME_NAME);+ expect(runtimeDisplayName("CLAUDE")).toBe(GENERIC_RUNTIME_NAME); // case-sensitive by design+ });++ it("generic label reads as a sentence fragment", () => {+ expect(GENERIC_RUNTIME_NAME).toBe("the agent runtime");+ });+});diff --git a/src/web/src/lib/runtime-display.ts b/src/web/src/lib/runtime-display.tsnew file mode 100644index 000000000..86d063136--- /dev/null+++ b/src/web/src/lib/runtime-display.ts@@ -0,0 +1,20 @@+/**+ * Friendly display names for agent-runtime providers.+ *+ * Used to attribute runtime errors in the chat UI so the user can see an error+ * came from the agent runtime CLI on their machine (Claude Code / Codex /+ * OpenCode) — not from Alook itself. See issue #236.+ */+const PROVIDER_DISPLAY_NAMES: Record<string, string> = {+ claude: "Claude Code",+ codex: "Codex",+ opencode: "OpenCode",+};++/** Generic label when the provider is unknown / missing / legacy. */+export const GENERIC_RUNTIME_NAME = "the agent runtime";++export function runtimeDisplayName(provider?: string | null): string {+ if (!provider) return GENERIC_RUNTIME_NAME;+ return PROVIDER_DISPLAY_NAMES[provider] ?? GENERIC_RUNTIME_NAME;+}diff --git a/src/web/src/lib/services/task.test.ts b/src/web/src/lib/services/task.test.tsindex b643b7fd5..93151dc6d 100644--- a/src/web/src/lib/services/task.test.ts+++ b/src/web/src/lib/services/task.test.ts@@ -426,7 +426,60 @@ describe("TaskService", () => {// ── failTask ─────────────────────────────────────────────────────describe("failTask", () => {- it("creates error message when error is non-empty", async () => {+ it("creates a runtime-attributed error message with the resolved provider (TC6)", async () => {+ const task = {+ id: "t1",+ agentId: "a1",+ workspaceId: "w1",+ conversationId: "c1",+ runtimeId: "rt1",+ status: "failed",+ };+ taskQ.failTask.mockResolvedValue(task);+ taskQ.countRunningTasks.mockResolvedValue(0);+ agentQ.updateAgentStatus.mockResolvedValue(undefined);+ runtimeQ.getAgentRuntime.mockResolvedValue({ id: "rt1", provider: "claude" });++ await service.failTask("t1", "w1", "Not logged in · Please run /login");++ expect(runtimeQ.getAgentRuntime).toHaveBeenCalledWith({}, "rt1");+ expect(messageQ.createMessage).toHaveBeenCalledWith({}, {+ conversationId: "c1",+ role: "assistant",+ content: "Not logged in · Please run /login",+ taskId: "t1",+ metadata: JSON.stringify({ error_source: "runtime", provider: "claude" }),+ });+ });++ it("still attributes the message with provider:null when the runtime can't be resolved (TC7)", async () => {+ const task = {+ id: "t1",+ agentId: "a1",+ workspaceId: "w1",+ conversationId: "c1",+ runtimeId: "rt1",+ status: "failed",+ };+ taskQ.failTask.mockResolvedValue(task);+ taskQ.countRunningTasks.mockResolvedValue(0);+ agentQ.updateAgentStatus.mockResolvedValue(undefined);+ // Lookup throws — must not block the task lifecycle.+ runtimeQ.getAgentRuntime.mockRejectedValue(new Error("db down"));++ await expect(service.failTask("t1", "w1", "boom")).resolves.toBeTruthy();++ expect(messageQ.createMessage).toHaveBeenCalledWith({}, {+ conversationId: "c1",+ role: "assistant",+ content: "boom",+ taskId: "t1",+ metadata: JSON.stringify({ error_source: "runtime", provider: null }),+ });+ expect(agentQ.updateAgentStatus).toHaveBeenCalled();+ });++ it("attributes with provider:null when the task has no runtimeId", async () => {const task = {id: "t1",agentId: "a1",@@ -440,11 +493,13 @@ describe("TaskService", () => {await service.failTask("t1", "w1", "something went wrong");+ expect(runtimeQ.getAgentRuntime).not.toHaveBeenCalled();expect(messageQ.createMessage).toHaveBeenCalledWith({}, {conversationId: "c1",role: "assistant",- content: "Error: something went wrong",+ content: "something went wrong",taskId: "t1",+ metadata: JSON.stringify({ error_source: "runtime", provider: null }),});});@@ -512,8 +567,9 @@ describe("TaskService", () => {expect(messageQ.createMessage).toHaveBeenCalledWith({}, {conversationId: "c1",role: "assistant",- content: "Error: something went wrong",+ content: "something went wrong",taskId: "t1",+ metadata: JSON.stringify({ error_source: "runtime", provider: null }),});expect(messageQ.createMessage).toHaveBeenCalledWith({}, {conversationId: "c1",diff --git a/src/web/src/lib/services/task.ts b/src/web/src/lib/services/task.tsindex bbe934fdd..e895b5647 100644--- a/src/web/src/lib/services/task.ts+++ b/src/web/src/lib/services/task.ts@@ -204,11 +204,26 @@ export class TaskService {}if (error) {+ // Attribute the error to the agent runtime (Claude Code / Codex /+ // OpenCode) so the chat UI can make clear it did NOT come from Alook.+ // Resolve the provider from the task's runtime; never let this block the+ // task lifecycle (issue #236).+ let provider: string | null = null;+ try {+ if (task.runtimeId) {+ const rt = await queries.runtime.getAgentRuntime(this.db, task.runtimeId);+ provider = rt?.provider ?? null;+ }+ } catch {+ // non-critical: fall back to a generic runtime label+ }+const msg = await messageQueries.createMessage(this.db, {conversationId: task.conversationId,role: "assistant",- content: `Error: ${error}`,+ content: error,taskId,+ metadata: JSON.stringify({ error_source: "runtime", provider }),});try {