Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(web): show Task steps as task blocks with drill-down activity
LeoXing64828ddf4601
diff --git a/apps/web/src/features/rooms/runtime-status/runtime-activity-path-view.tsx b/apps/web/src/features/rooms/runtime-status/runtime-activity-path-view.tsxindex dd64f671..1d0249b3 100644--- a/apps/web/src/features/rooms/runtime-status/runtime-activity-path-view.tsx+++ b/apps/web/src/features/rooms/runtime-status/runtime-activity-path-view.tsx@@ -22,6 +22,8 @@ import {type RuntimeActivityPathToolCall,} from "./runtime-activity-path";import { RuntimeActivityEntries } from "./runtime-activity-entries";+import { TaskActivityBlock } from "./task-activity-block";+import { parseTaskCommand, taskIdFromOutput } from "./task-command";import {toolGroupPresentation,toolPresentation,@@ -213,6 +215,19 @@ function RuntimeActivityPathRow({ item }: { item: RuntimeActivityPathItem }) {);}if (item.kind === "command") {+ const taskCommand = parseTaskCommand(commandText(item.entries));+ if (taskCommand) {+ return (+ <TaskActivityBlock+ active={item.active}+ command={taskCommand}+ failed={item.outcome === "failed"}+ taskId={+ taskCommand.taskId ?? taskIdFromOutput(outputText(item.entries))+ }+ />+ );+ }const presentation = toolPresentation("command");return (<ActivitySummaryRow@@ -509,3 +524,33 @@ function ActiveMark() {</span>);}++/** The command line a command Activity ran, from its first code or JSON block. */+function commandText(entries: RuntimeActivityPathToolCall["entries"]) {+ const block = entries.find(+ (entry) =>+ entry.type === "content" &&+ (entry.block.format === "code" || entry.block.format === "json"),+ );+ if (block?.type !== "content") return "";+ if (block.block.format === "code") return block.block.content;+ try {+ const input = JSON.parse(block.block.content) as {+ cmd?: unknown;+ command?: unknown;+ };+ const command = input.cmd ?? input.command;+ if (typeof command === "string") return command;+ if (Array.isArray(command)) return command.join(" ");+ } catch {+ // An unreadable input is not a Task command.+ }+ return "";+}++/** Every block the Activity carried; the CLI receipt is among them. */+function outputText(entries: RuntimeActivityPathToolCall["entries"]) {+ return entries+ .map((entry) => (entry.type === "content" ? entry.block.content : ""))+ .join("\n");+}diff --git a/apps/web/src/features/rooms/runtime-status/task-activity-block.tsx b/apps/web/src/features/rooms/runtime-status/task-activity-block.tsxnew file mode 100644index 00000000..c83703d8--- /dev/null+++ b/apps/web/src/features/rooms/runtime-status/task-activity-block.tsx@@ -0,0 +1,160 @@+import {+ SentIcon,+ TaskAdd01Icon,+ TaskDaily01Icon,+ TaskDone01Icon,+} from "@hugeicons/core-free-icons";+import { useQuery } from "@tanstack/react-query";+import { createContext, useContext, type ReactNode } from "react";++import { Icon } from "@/components/ui/icon";+import { StatusPill } from "@/components/ui/status-pill";+import { teamHubData } from "@/features/teamhub/teamhub-api";+import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";+import type { TeamHubTaskExecution } from "@/features/teamhub/teamhub-types";+import { tenantWorkItemTargetQueryOptions } from "@/features/work-items/work-item-queries";++import { RunningDots } from "../task-sidebar/running-dots";+import type { TaskCommand } from "./task-command";++interface TaskActivityLinks {+ tenantId: string;+ openTask?: (taskId: string, title: string) => void;+}++const TaskActivityLinksContext = createContext<TaskActivityLinks | null>(null);++/** Lets task blocks inside an activity log read Tasks and open one. */+export function TaskActivityLinksProvider({+ children,+ openTask,+ tenantId,+}: TaskActivityLinks & { children: ReactNode }) {+ return (+ <TaskActivityLinksContext.Provider value={{ openTask, tenantId }}>+ {children}+ </TaskActivityLinksContext.Provider>+ );+}++const VERBS: Record<TaskCommand["operation"], string> = {+ create: "Started",+ send: "Sent to",+ stop: "Stopped",+ check: "Checked on tasks",+};+const GLYPHS = {+ create: TaskAdd01Icon,+ send: SentIcon,+ stop: TaskDone01Icon,+ check: TaskDaily01Icon,+};++/**+ * One `teamhub task …` step of a Meta's activity: what it did, to which Task,+ * and that Task's current state. Opening it shows the Task's own activity.+ */+export function TaskActivityBlock({+ active = false,+ command,+ failed = false,+ taskId,+}: {+ active?: boolean;+ command: TaskCommand;+ failed?: boolean;+ taskId?: string;+}) {+ const links = useContext(TaskActivityLinksContext);+ const { client } = useTeamHubRuntime();+ const tenantId = links?.tenantId ?? "";+ const readable = Boolean(taskId && tenantId) && command.operation !== "check";+ const item = useQuery({+ ...tenantWorkItemTargetQueryOptions(client, tenantId, taskId ?? ""),+ enabled: readable && !command.name,+ retry: false,+ });+ const execution = useQuery({+ queryKey: ["teamhub", tenantId, "task-execution", taskId],+ queryFn: () =>+ teamHubData(+ client.api.GET("/v0/tasks/{taskId}/execution", {+ params: { path: { taskId: taskId ?? "" } },+ }),+ ),+ enabled: readable,+ retry: false,+ refetchInterval: (query) =>+ query.state.data?.status === "running" ||+ query.state.data?.status === "waiting_for_approval"+ ? 5_000+ : false,+ });+ const title =+ command.operation === "check"+ ? undefined+ : (command.name ?? item.data?.title);+ const open =+ taskId && title !== undefined && links?.openTask+ ? () => links.openTask?.(taskId, title)+ : undefined;+ const row = (+ <>+ <Icon className="shrink-0" icon={GLYPHS[command.operation]} size={15} />+ <span className={`shrink-0 ${active ? "town-shimmer-text" : ""}`}>+ {VERBS[command.operation]}+ </span>+ <span className="min-w-0 flex-1 truncate text-app-ink">{title}</span>+ {failed ? (+ <span className="shrink-0 text-app-danger">Failed</span>+ ) : execution.data ? (+ <TaskState execution={execution.data} />+ ) : null}+ </>+ );+ const rowClass = "flex min-h-8 w-full items-center gap-2 py-1.5 text-left";+ return (+ <li className="runtime-activity-step text-app-muted">+ {open ? (+ <button+ aria-label={`Open task ${title}`}+ className={`${rowClass} rounded-md hover:text-app-body focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-app-focus`}+ onClick={open}+ type="button"+ >+ {row}+ </button>+ ) : (+ <span className={rowClass}>{row}</span>+ )}+ {command.operation === "send" && command.message ? (+ <p className="-mt-1 mb-1 line-clamp-2 pl-[1.45rem] text-app-muted">+ “{command.message}”+ </p>+ ) : null}+ </li>+ );+}++function TaskState({ execution }: { execution: TeamHubTaskExecution }) {+ switch (execution.status) {+ case "running":+ return (+ <span+ aria-label="Task running"+ className="flex shrink-0 items-center text-app-info"+ role="img"+ >+ <RunningDots />+ </span>+ );+ case "waiting_for_approval":+ return <StatusPill tone="warning">Needs approval</StatusPill>;+ case "idle":+ return <StatusPill tone="success">Reported</StatusPill>;+ case "failed":+ return <StatusPill tone="danger">Failed</StatusPill>;+ case "canceled":+ return <StatusPill>Stopped</StatusPill>;+ }+}diff --git a/apps/web/src/features/rooms/runtime-status/task-command.ts b/apps/web/src/features/rooms/runtime-status/task-command.tsnew file mode 100644index 00000000..212fd16e--- /dev/null+++ b/apps/web/src/features/rooms/runtime-status/task-command.ts@@ -0,0 +1,95 @@+/**+ * A Meta's `teamhub task …` CLI call, read from the command it ran. The CLI+ * is our own program with fixed flags, so its argv is a structured record of+ * the Task operation, not prose.+ */+export interface TaskCommand {+ operation: "create" | "send" | "stop" | "check";+ /** The Task's title, from `task create --name` or an earlier step that created it. */+ name?: string;+ /** The message `task send` delivered. */+ message?: string;+ steer?: boolean;+ taskId?: string;+}++const OPERATIONS = new Set<TaskCommand["operation"]>([+ "create",+ "send",+ "stop",+ "check",+]);++export function parseTaskCommand(command: string): TaskCommand | undefined {+ const words = shellWords(command);+ const start = words.findIndex(+ (word, index) =>+ (word === "teamhub" || word.endsWith("/teamhub")) &&+ words[index + 1] === "task",+ );+ if (start < 0) return undefined;+ const operation = words[start + 2] as TaskCommand["operation"];+ if (!OPERATIONS.has(operation)) return undefined;+ const flags = new Map<string, string>();+ let steer = false;+ for (let index = start + 3; index < words.length; index += 1) {+ const word = words[index]!;+ if (word === "&&" || word === "|" || word === ";") break;+ if (word === "--steer") {+ steer = true;+ continue;+ }+ if (!word.startsWith("--")) continue;+ const equals = word.indexOf("=");+ if (equals > 0) {+ flags.set(word.slice(0, equals), word.slice(equals + 1));+ } else if (index + 1 < words.length) {+ flags.set(word, words[index + 1]!);+ index += 1;+ }+ }+ return {+ operation,+ ...(flags.has("--name") ? { name: flags.get("--name") } : {}),+ ...(flags.has("--message") ? { message: flags.get("--message") } : {}),+ ...(flags.has("--task-id") ? { taskId: flags.get("--task-id") } : {}),+ ...(steer ? { steer } : {}),+ };+}++/** The `task_id` in the CLI's JSON receipt, when the output carries one. */+export function taskIdFromOutput(output: string | undefined) {+ const match = output?.match(/"task_id"\s*:\s*"([A-Za-z0-9][A-Za-z0-9_-]*)"/);+ return match?.[1];+}++/** Splits a command line into words, honoring single and double quotes. */+function shellWords(command: string) {+ const words: string[] = [];+ let current = "";+ let quote: "'" | '"' | undefined;+ let started = false;+ for (let index = 0; index < command.length; index += 1) {+ const char = command[index]!;+ if (quote) {+ if (char === quote) quote = undefined;+ else if (char === "\\" && quote === '"' && index + 1 < command.length)+ current += command[++index];+ else current += char;+ continue;+ }+ if (char === "'" || char === '"') {+ quote = char;+ started = true;+ } else if (/\s/.test(char)) {+ if (started) words.push(current);+ current = "";+ started = false;+ } else {+ current += char;+ started = true;+ }+ }+ if (started) words.push(current);+ return words;+}diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/agent-live-activity-panel-tab.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/agent-live-activity-panel-tab.tsxindex 2d205557..de494f9e 100644--- a/apps/web/src/features/rooms/task-sidebar/adapters/agent-live-activity-panel-tab.tsx+++ b/apps/web/src/features/rooms/task-sidebar/adapters/agent-live-activity-panel-tab.tsx@@ -10,6 +10,7 @@ import { roomMessagesInfiniteQueryOptions } from "../../room-queries";import { RuntimeActivityPath } from "../../runtime-status/runtime-activity-path-view";import { useRuntimePresentationEventRecords } from "../../runtime-status/use-runtime-presentation-event-records";import { PanelLoading } from "../panel-loading";+import { TaskActivityDrillDown } from "./task-activity-drill-down";const EMPTY_MESSAGES: readonly TeamHubMessage[] = [];@@ -64,60 +65,66 @@ export function AgentLiveActivityPanelTab({const pending = events.pending;return (- <div- className={hidden ? "hidden" : "flex h-full min-h-0 flex-col bg-card"}- data-testid="agent-live-activity-panel"- data-run-id={runId}- hidden={hidden || undefined}- inert={hidden || undefined}+ <TaskActivityDrillDown+ hidden={hidden}+ key={runId ?? runStatusId}+ tenantId={tenantId}>- <header className="flex min-h-14 shrink-0 items-center gap-2.5 border-b border-border bg-card px-4 py-2">- {onBack ? (- <button- aria-label={backLabel}- className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-app-focus"- onClick={onBack}- title={backLabel}- type="button"- >- <Icon icon={ArrowLeft01Icon} size={16} />- </button>- ) : null}- <ActorAvatar- actorId={actorId}- kind="agent"- name={actorName}- size="xs"- />- <div className="min-w-0 flex-1">- <h2 className="truncate text-sm font-semibold text-foreground">- {`${actorName} activity`}- </h2>- <p className="truncate text-xs font-normal leading-4 text-app-muted">- {pending || hasEvents ? "Activity" : "Waiting for activity"}- </p>- </div>- </header>- {events.error ? (- <LiveActivityState- detail="Published Runtime events could not be read from TeamHub."- title="Activity could not be loaded"- />- ) : pending ? (- <PanelLoading label="Loading activity" />- ) : hasEvents ? (- <RuntimeActivityPath- key={`${activationKey}:${hidden}:${runId ?? runStatusId}`}- messages={activityMessages}- records={events.items}- />- ) : (- <LiveActivityState- detail="This run has not published any activity events yet."- title="No activity yet"- />- )}- </div>+ <div+ className={hidden ? "hidden" : "flex h-full min-h-0 flex-col bg-card"}+ data-testid="agent-live-activity-panel"+ data-run-id={runId}+ hidden={hidden || undefined}+ inert={hidden || undefined}+ >+ <header className="flex min-h-14 shrink-0 items-center gap-2.5 border-b border-border bg-card px-4 py-2">+ {onBack ? (+ <button+ aria-label={backLabel}+ className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-app-focus"+ onClick={onBack}+ title={backLabel}+ type="button"+ >+ <Icon icon={ArrowLeft01Icon} size={16} />+ </button>+ ) : null}+ <ActorAvatar+ actorId={actorId}+ kind="agent"+ name={actorName}+ size="xs"+ />+ <div className="min-w-0 flex-1">+ <h2 className="truncate text-sm font-semibold text-foreground">+ {`${actorName} activity`}+ </h2>+ <p className="truncate text-xs font-normal leading-4 text-app-muted">+ {pending || hasEvents ? "Activity" : "Waiting for activity"}+ </p>+ </div>+ </header>+ {events.error ? (+ <LiveActivityState+ detail="Published Runtime events could not be read from TeamHub."+ title="Activity could not be loaded"+ />+ ) : pending ? (+ <PanelLoading label="Loading activity" />+ ) : hasEvents ? (+ <RuntimeActivityPath+ key={`${activationKey}:${hidden}:${runId ?? runStatusId}`}+ messages={activityMessages}+ records={events.items}+ />+ ) : (+ <LiveActivityState+ detail="This run has not published any activity events yet."+ title="No activity yet"+ />+ )}+ </div>+ </TaskActivityDrillDown>);}diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/message-activities-panel-tab.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/message-activities-panel-tab.tsxindex 7f5122f8..bdc7fd68 100644--- a/apps/web/src/features/rooms/task-sidebar/adapters/message-activities-panel-tab.tsx+++ b/apps/web/src/features/rooms/task-sidebar/adapters/message-activities-panel-tab.tsx@@ -15,6 +15,7 @@ import type { TeamHubMessage } from "@/features/teamhub/teamhub-types";import { ActorAvatar } from "../../members/actor-avatar";import { PanelLoading } from "../panel-loading";+import { TaskActivityDrillDown } from "./task-activity-drill-down";export function MessageActivitiesPanelTab({activationKey,@@ -76,107 +77,109 @@ export function MessageActivitiesPanelTab({}, [activationKey, hidden, message.id, activities.data?.records.length]);return (- <div- className={hidden ? "hidden" : "flex h-full min-h-0 flex-col bg-card"}- data-testid="message-activities-panel"- hidden={hidden || undefined}- inert={hidden || undefined}- >- <header className="flex min-h-14 shrink-0 items-center gap-2.5 border-b border-app-border px-4 py-2">- {onBack ? (+ <TaskActivityDrillDown hidden={hidden} key={message.id} tenantId={tenantId}>+ <div+ className={hidden ? "hidden" : "flex h-full min-h-0 flex-col bg-card"}+ data-testid="message-activities-panel"+ hidden={hidden || undefined}+ inert={hidden || undefined}+ >+ <header className="flex min-h-14 shrink-0 items-center gap-2.5 border-b border-app-border px-4 py-2">+ {onBack ? (+ <button+ aria-label={backLabel}+ className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-app-focus"+ onClick={onBack}+ title={backLabel}+ type="button"+ >+ <Icon icon={ArrowLeft01Icon} size={16} />+ </button>+ ) : null}+ <ActorAvatar+ actorId={message.author.id}+ kind={message.author.kind}+ name={message.author.display_name}+ size="xs"+ />+ <div className="min-w-0 flex-1">+ <h2 className="truncate text-sm font-semibold text-foreground">+ {message.author.display_name} activities+ </h2>+ <p className="truncate text-xs text-app-muted">Activity</p>+ </div><button- aria-label={backLabel}- className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-app-focus"- onClick={onBack}- title={backLabel}+ aria-label="Refresh message activities"+ className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-60"+ disabled={loading}+ onClick={() => {+ setRefreshing(true);+ void activities.refetch().finally(() => setRefreshing(false));+ }}+ title="Refresh"type="button">- <Icon icon={ArrowLeft01Icon} size={16} />+ {refreshing ? (+ <Icon+ className="animate-spin motion-reduce:animate-none"+ icon={Loading03Icon}+ size={16}+ />+ ) : (+ <Icon icon={RefreshIcon} size={16} />+ )}</button>- ) : null}- <ActorAvatar- actorId={message.author.id}- kind={message.author.kind}- name={message.author.display_name}- size="xs"- />- <div className="min-w-0 flex-1">- <h2 className="truncate text-sm font-semibold text-foreground">- {message.author.display_name} activities- </h2>- <p className="truncate text-xs text-app-muted">Activity</p>- </div>- <button- aria-label="Refresh message activities"- className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-60"- disabled={loading}- onClick={() => {- setRefreshing(true);- void activities.refetch().finally(() => setRefreshing(false));+ </header>++ <div+ ref={scrollRef}+ className="workspace-scrollbar min-h-0 flex-1 overflow-y-auto bg-card"+ onScroll={(event) => {+ const element = event.currentTarget;+ followLatest.current =+ element.scrollHeight - element.scrollTop - element.clientHeight <=+ 32;}}- title="Refresh"- type="button">- {refreshing ? (- <Icon- className="animate-spin motion-reduce:animate-none"- icon={Loading03Icon}- size={16}+ {activities.isError ? (+ <ActivityLogState+ detail="The Message activity log could not be read."+ title="Activities could not be loaded"+ />+ ) : loading ? (+ <PanelLoading label="Loading activities" />+ ) : activities.data?.status !== "available" ? (+ <ActivityLogState+ detail={activities.data?.reason}+ title="Message activity log unavailable"/>+ ) : activities.data.records.length > 0 ? (+ <section className="bg-card">+ {!activities.data.has_native_turn ? (+ <p className="border-b border-app-border px-4 py-2 text-xs text-app-muted">+ Only linked tool records are available for this execution.+ </p>+ ) : null}+ {activities.data.truncated ? (+ <p className="border-b border-app-border px-4 py-2 text-xs text-app-muted">+ This unusually large turn was limited to the latest 10,000+ records.+ </p>+ ) : null}+ <RuntimeHistoryView records={activities.data.records} />+ </section>) : (- <Icon icon={RefreshIcon} size={16} />+ <ActivityLogState+ detail={+ activities.data.reason ??+ "Only Runtime records connected by Activity identity are shown."+ }+ title="No exact activity log for this Message"+ />)}- </button>- </header>-- <div- ref={scrollRef}- className="workspace-scrollbar min-h-0 flex-1 overflow-y-auto bg-card"- onScroll={(event) => {- const element = event.currentTarget;- followLatest.current =- element.scrollHeight - element.scrollTop - element.clientHeight <=- 32;- }}- >- {activities.isError ? (- <ActivityLogState- detail="The Message activity log could not be read."- title="Activities could not be loaded"- />- ) : loading ? (- <PanelLoading label="Loading activities" />- ) : activities.data?.status !== "available" ? (- <ActivityLogState- detail={activities.data?.reason}- title="Message activity log unavailable"- />- ) : activities.data.records.length > 0 ? (- <section className="bg-card">- {!activities.data.has_native_turn ? (- <p className="border-b border-app-border px-4 py-2 text-xs text-app-muted">- Only linked tool records are available for this execution.- </p>- ) : null}- {activities.data.truncated ? (- <p className="border-b border-app-border px-4 py-2 text-xs text-app-muted">- This unusually large turn was limited to the latest 10,000- records.- </p>- ) : null}- <RuntimeHistoryView records={activities.data.records} />- </section>- ) : (- <ActivityLogState- detail={- activities.data.reason ??- "Only Runtime records connected by Activity identity are shown."- }- title="No exact activity log for this Message"- />- )}+ </div></div>- </div>+ </TaskActivityDrillDown>);}diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/runtime-history-view.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/runtime-history-view.tsxindex 06de2a35..b0a384c9 100644--- a/apps/web/src/features/rooms/task-sidebar/adapters/runtime-history-view.tsx+++ b/apps/web/src/features/rooms/task-sidebar/adapters/runtime-history-view.tsx@@ -8,6 +8,12 @@ import {} from "@/features/rooms/runtime-status/runtime-tool-presentation";import { MessageMarkdown } from "@/features/rooms/chat/message-markdown";+import { TaskActivityBlock } from "@/features/rooms/runtime-status/task-activity-block";+import {+ parseTaskCommand,+ taskIdFromOutput,+ type TaskCommand,+} from "@/features/rooms/runtime-status/task-command";import type { TeamHubMessageActivityRecord } from "@/features/teamhub/teamhub-types";type HistoryCategory = TeamHubMessageActivityRecord["category"];@@ -37,6 +43,12 @@ export function RuntimeHistoryView({{items.map((item) =>item.kind === "tool_calls" ? (<RuntimeToolCallsActivity calls={item.calls} key={item.key} />+ ) : item.kind === "task" ? (+ <TaskActivityBlock+ command={item.command}+ key={item.key}+ taskId={item.taskId}+ />) : (<RuntimeActivityRecord key={item.key} record={item.record} />),@@ -52,6 +64,7 @@ interface ActivityToolCall {type ActivityTimelineItem =| { calls: ActivityToolCall[]; key: string; kind: "tool_calls" }+ | { command: TaskCommand; key: string; kind: "task"; taskId?: string }| {kind: "record";key: string;@@ -64,6 +77,8 @@ function activityTimelineItems(): ActivityTimelineItem[] {const items: ActivityTimelineItem[] = [];const thinkingTitles = new Set<string>();+ // Later steps name a Task only by id; reuse the name it was created with.+ const taskNames = new Map<string, string>();for (const source of records.flatMap(claudeActivityRecords)) {let record = source;if (record.native_type === "event_msg.mcp_tool_call_end") {@@ -74,7 +89,11 @@ function activityTimelineItems(tool_name: toolNameLabel(stringValue(invocation?.tool) ?? "Tool call"),};} else if (record.category === "tool_call") {- if (record.tool_name === "exec") continue;+ if (+ record.tool_name === "exec" &&+ !parseTaskCommand(nativeCommand(record) ?? "")+ )+ continue;} else if (record.category === "reasoning") {const summary = reasoningText(record);if (!summary?.trim()) continue;@@ -93,6 +112,24 @@ function activityTimelineItems(const pair = record.tool_call_id? callPairs.get(record.tool_call_id): undefined;+ const taskCommand =+ record.category === "tool_call"+ ? parseTaskCommand(nativeCommand(record) ?? "")+ : undefined;+ if (taskCommand) {+ const taskId =+ taskCommand.taskId ??+ taskIdFromOutput(pair?.result && nativeOutput(pair.result));+ if (taskId && taskCommand.name) taskNames.set(taskId, taskCommand.name);+ const name = taskCommand.name ?? (taskId && taskNames.get(taskId));+ items.push({+ command: name ? { ...taskCommand, name } : taskCommand,+ key: `task-${record.ordinal}-${items.length}`,+ kind: "task",+ taskId,+ });+ continue;+ }if (record.category !== "tool_call") {items.push({kind: "record",@@ -195,6 +232,41 @@ function RuntimeActivityRecord({);}+/** The shell command a native tool call ran, for any Runtime's shape. */+function nativeCommand(record: TeamHubMessageActivityRecord) {+ const payload = nativePayload(record);+ const block = nativeContentBlock(record, payload);+ const input =+ asObject(block?.input) ?? parseObject(payload?.arguments) ?? payload;+ const command = input?.cmd ?? input?.command;+ if (typeof command === "string") return command;+ if (Array.isArray(command)) return command.filter(isString).join(" ");+ return undefined;+}++function nativeOutput(record: TeamHubMessageActivityRecord) {+ const payload = nativePayload(record);+ const block = nativeContentBlock(record, payload);+ return (+ stringValue(payload?.output) ??+ textContent(block?.content) ??+ textContent(payload?.content)+ );+}++function parseObject(value: unknown) {+ if (typeof value !== "string") return asObject(value);+ try {+ return asObject(JSON.parse(value));+ } catch {+ return undefined;+ }+}++function isString(value: unknown): value is string {+ return typeof value === "string";+}+function activityMessageText(record: TeamHubMessageActivityRecord) {const payload = nativePayload(record);return (diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/task-activities-panel-tab.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/task-activities-panel-tab.tsxindex 15b650d9..7310aa9a 100644--- a/apps/web/src/features/rooms/task-sidebar/adapters/task-activities-panel-tab.tsx+++ b/apps/web/src/features/rooms/task-sidebar/adapters/task-activities-panel-tab.tsx@@ -1,11 +1,6 @@import { dateTimeFormat } from "@/lib/date-format";-import { useState } from "react";import { useInfiniteQuery } from "@tanstack/react-query";-import {- Activity01Icon,- ArrowRight01Icon,- RefreshIcon,-} from "@hugeicons/core-free-icons";+import { ArrowLeft01Icon, RefreshIcon } from "@hugeicons/core-free-icons";import { Button } from "@/components/ui/button";import { Icon } from "@/components/ui/icon";import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";@@ -20,32 +15,32 @@ import {useTaskActivities,} from "@/features/work-items/use-task-activities";import { roomMessagesInfiniteQueryOptions } from "../../room-queries";-import { ActorAvatar } from "../../members/actor-avatar";-import { MessageMarkdown } from "../../chat/message-markdown";import { RuntimeActivityPath } from "../../runtime-status/runtime-activity-path-view";import { useTaskActivityEvents } from "../../runtime-status/use-task-activity-events";-import { RunningDots } from "../running-dots";import { PanelLoading } from "../panel-loading";const stageLabels: Record<TeamHubTaskExecution["status"], string> = {running: "Running",waiting_for_approval: "Waiting for approval",- idle: "Idle",+ idle: "Reported",failed: "Failed",canceled: "Stopped",};-const tabs = ["Activity", "Details"] as const;+/** One Task's activity: each of its runs, newest last, and nothing else. */export function TaskActivitiesPanelTab({hidden,+ onBack,taskId,tenantId,+ title,}: {hidden: boolean;+ onBack?: () => void;taskId: string;tenantId: string;+ title?: string;}) {- const [tab, setTab] = useState<(typeof tabs)[number]>("Activity");const data = useTaskActivities({ tenantId, taskId, enabled: !hidden });const { client } = useTeamHubRuntime();const messages = useInfiniteQuery({@@ -59,11 +54,7 @@ export function TaskActivitiesPanelTab({const publicMessages =messages.data?.pages.flatMap((page) => page.items) ?? [];const execution = data.execution.data;- const item = data.item.data;const stopped = taskExecutionStopped(execution);- const status = execution- ? stageLabels[execution.status]- : (item?.state.replaceAll("_", " ") ?? "");const refresh = () => {void data.item.refetch();void data.execution.refetch();@@ -78,191 +69,76 @@ export function TaskActivitiesPanelTab({data-testid="task-activities-panel"aria-label="Task activities">- <header className="shrink-0 border-b border-app-border px-4 pb-3 pt-4">- <div className="flex items-center gap-2 text-xs text-app-muted">- <Icon icon={Activity01Icon} size={14} />- <span>Task {item ? `#${item.number}` : ""}</span>+ <header className="flex min-h-14 shrink-0 items-center gap-2.5 border-b border-app-border px-4 py-2">+ {onBack ? (<button+ aria-label="Back to activity"+ className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-app-focus"+ onClick={onBack}+ title="Back to activity"type="button"- aria-label="Refresh task"- onClick={refresh}- className="ml-auto rounded-lg p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground">- <Icon icon={RefreshIcon} size={14} />+ <Icon icon={ArrowLeft01Icon} size={16} /></button>- </div>- <h2 className="mt-2 break-words text-sm font-semibold text-app-ink">- {item?.title ?? "Task activity"}- </h2>- <div className="mt-3 flex flex-wrap items-center gap-2 text-xs">- <span className="rounded-full bg-muted px-2 py-0.5 capitalize text-muted-foreground">- {status}- </span>- {execution?.current_attempt ? (- <span className="text-app-muted">- Attempt {execution.current_attempt.attempt_number}- </span>- ) : null}- </div>- {execution ? (- <p className="mt-2 text-2xs text-app-muted">- Updated {formatTime(execution.execution_updated_at)}- </p>) : null}+ <div className="min-w-0 flex-1">+ <h2 className="truncate text-sm font-semibold text-foreground">+ {title ?? data.item.data?.title ?? "Task"}+ </h2>+ <p className="truncate text-xs text-app-muted">+ {execution ? stageLabels[execution.status] : "Task"}+ </p>+ </div>+ <button+ type="button"+ aria-label="Refresh task"+ onClick={refresh}+ title="Refresh"+ className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"+ >+ <Icon icon={RefreshIcon} size={16} />+ </button></header>- <nav- aria-label="Task sections"- className="flex shrink-0 gap-1 border-b border-border px-3 py-2"- >- {tabs.map((value) => (- <button- type="button"- aria-current={tab === value ? "page" : undefined}- key={value}- onClick={() => setTab(value)}- className={`rounded-full px-3 py-1 text-sm font-medium transition-colors duration-150 ${tab === value ? "bg-muted text-foreground" : "text-muted-foreground hover:bg-muted/50 hover:text-foreground"}`}- >- {value}- </button>- ))}- </nav><div className="workspace-scrollbar min-h-0 flex-1 overflow-y-auto">- {data.item.error ? (- <State>Task could not be loaded.</State>- ) : data.item.isPending ? (- <State busy>Loading task…</State>+ {data.activities.error ? (+ <State>+ {isTaskActivityNotFound(data.activities.error)+ ? "You do not have access to this task’s work room activity."+ : "Activity could not be loaded. Try refreshing."}+ </State>+ ) : data.activities.isPending ? (+ <State busy>Loading activity…</State>) : (<>- {data.execution.error ? (- <State>Execution status could not be loaded.</State>- ) : null}- {tab === "Activity" ? (- <>- {data.activities.error ? (- <State>- {isTaskActivityNotFound(data.activities.error)- ? "You do not have access to this task’s work room activity."- : "Activity could not be loaded. Try refreshing."}- </State>- ) : data.activities.isPending ? (- <State busy>Loading activity…</State>- ) : (- <>- {data.roomId && !data.connected ? (- <State>Reconnecting to live activity…</State>- ) : null}- {!data.runStatuses.length ? (- <State>- No published activity yet. Earlier runs may not have an- activity history.- </State>- ) : null}- {data.roomId- ? data.runStatuses.map((runStatus) => (- <TaskActivityGroup- key={runStatus.id}- runStatus={runStatus}- tenantId={tenantId}- roomId={data.roomId!}- visible={!hidden}- stopped={stopped}- paused={- execution?.status === "waiting_for_approval"- }- messages={publicMessages}- />- ))- : null}- {data.activities.hasNextPage ? (- <div className="px-4 py-3">- <Button- size="compact"- tone="ghost"- disabled={data.activities.isFetchingNextPage}- onClick={() => void data.activities.fetchNextPage()}- >- Load earlier activity- </Button>- </div>- ) : null}- </>- )}- {data.roomId ? (- <div className="border-t border-app-border px-4 py-4">- <h3 className="mb-3 text-xs font-medium text-app-body">- Task messages- </h3>- {messages.error ? (- <p className="text-xs text-app-muted">- Messages could not be loaded.- </p>- ) : !publicMessages.length ? (- <p className="text-xs text-app-muted">- No task messages yet.- </p>- ) : (- [...publicMessages].reverse().map((message) => (- <article key={message.id} className="mb-4">- <div className="mb-1 flex gap-2 text-2xs text-app-muted">- <span>{message.author.display_name}</span>- <time dateTime={message.created_at}>- {formatTime(message.created_at)}- </time>- </div>- <MessageMarkdown- body={message.raw_message}- authorKind={message.author.kind}- />- </article>- ))- )}- {messages.hasNextPage ? (- <Button- size="compact"- tone="ghost"- disabled={messages.isFetchingNextPage}- onClick={() => void messages.fetchNextPage()}- >- Load earlier messages- </Button>- ) : null}- </div>- ) : null}- </>+ {data.roomId && !data.connected ? (+ <State>Reconnecting to live activity…</State>) : null}- {tab === "Details" && item ? (- <div className="space-y-5 p-4 text-xs text-app-body">- <dl className="space-y-3">- <Field- label="Assignees"- value={- item.assignees- .map((assignment) => assignment.actor.display_name)- .join(", ") || "Unassigned"- }+ {!data.runStatuses.length ? <State>No activity yet.</State> : null}+ {data.roomId+ ? data.runStatuses.map((runStatus) => (+ <TaskActivityGroup+ key={runStatus.id}+ runStatus={runStatus}+ tenantId={tenantId}+ roomId={data.roomId!}+ visible={!hidden}+ stopped={stopped}+ paused={execution?.status === "waiting_for_approval"}+ messages={publicMessages}+ labeled={data.runStatuses.length > 1}/>- <Field label="Priority" value={item.priority} />- <Field- label="Execution"- value={- execution- ? stageLabels[execution.status]- : "Execution is not enabled"- }- />- {execution?.reason_code ? (- <Field label="Reason" value={execution.reason_code} />- ) : null}- </dl>- {item.description ? (- <div>- <h3 className="mb-2 font-medium">Description</h3>- <MessageMarkdown- body={item.description}- authorKind="human"- />- </div>- ) : null}+ ))+ : null}+ {data.activities.hasNextPage ? (+ <div className="px-4 py-3">+ <Button+ size="compact"+ tone="ghost"+ disabled={data.activities.isFetchingNextPage}+ onClick={() => void data.activities.fetchNextPage()}+ >+ Load earlier activity+ </Button></div>) : null}</>@@ -272,6 +148,7 @@ export function TaskActivitiesPanelTab({);}+/** One run of the Task; a Task resumed more than once labels each run. */function TaskActivityGroup({runStatus,tenantId,@@ -280,6 +157,7 @@ function TaskActivityGroup({stopped,paused: taskPaused,messages,+ labeled,}: {runStatus: TeamHubRunStatus;tenantId: string;@@ -288,17 +166,16 @@ function TaskActivityGroup({stopped: boolean;paused: boolean;messages: TeamHubMessage[];+ labeled: boolean;}) {const active = runStatus.status === "active" && !stopped;const paused = runStatus.status === "active" && taskPaused;- const [opened, setOpened] = useState<boolean>();- const expanded = opened ?? active;const events = useTaskActivityEvents({tenantId,roomId,runStatusId: runStatus.id,revision: runStatus.revision,- enabled: visible && expanded,+ enabled: visible,});const interrupted =(runStatus.status === "aborted" &&@@ -312,64 +189,24 @@ function TaskActivityGroup({? "interrupted": "ended";return (- <div className="border-b border-app-border">- <button- type="button"- aria-expanded={expanded}- onClick={() => setOpened(!expanded)}- className="flex w-full items-center gap-2.5 px-4 py-3 text-left transition-colors duration-300 hover:bg-muted/70"- >- <ActorAvatar- actorId={runStatus.agent.id}- kind="agent"- name={runStatus.agent.display_name}- size="xs"- />- <span className="min-w-0 flex-1">- <span className="block truncate text-xs font-medium text-app-body">- {runStatus.agent.display_name}- </span>- <span className="text-2xs text-app-muted">- {formatTime(runStatus.created_at)} ·{" "}- {active- ? "Working"- : paused- ? "Paused"- : interrupted- ? "Interrupted"- : "Ended"}- </span>- </span>- {active ? (- <span- aria-label="Agent working"- className="flex h-3.5 items-center text-app-info"- role="img"- >- <RunningDots />- </span>- ) : (- <Icon- className={expanded ? "rotate-90 text-app-muted" : "text-app-muted"}- icon={ArrowRight01Icon}- size={14}- />- )}- </button>- {expanded ? (- events.error ? (- <State>Activity could not be loaded.</State>- ) : !events.data ? (- <State busy>Loading activity…</State>- ) : (- <RuntimeActivityPath- records={events.data.items}- messages={messages}- lifecycle={lifecycle}- embedded- />- )+ <div>+ {labeled ? (+ <p className="px-4 pt-3 text-2xs text-app-muted">+ {formatTime(runStatus.created_at)}+ </p>) : null}+ {events.error ? (+ <State>Activity could not be loaded.</State>+ ) : !events.data ? (+ <State busy>Loading activity…</State>+ ) : (+ <RuntimeActivityPath+ records={events.data.items}+ messages={messages}+ lifecycle={lifecycle}+ embedded+ />+ )}</div>);}@@ -387,14 +224,6 @@ function State({</p>);}-function Field({ label, value }: { label: string; value: string }) {- return (- <div className="flex gap-3">- <dt className="w-24 shrink-0 text-app-muted">{label}</dt>- <dd className="min-w-0 break-words capitalize">{value}</dd>- </div>- );-}function formatTime(value: string) {return dateTimeFormat({month: "short",diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/task-activity-drill-down.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/task-activity-drill-down.tsxnew file mode 100644index 00000000..e76f7eef--- /dev/null+++ b/apps/web/src/features/rooms/task-sidebar/adapters/task-activity-drill-down.tsx@@ -0,0 +1,37 @@+import { useState, type ReactNode } from "react";++import { TaskActivityLinksProvider } from "../../runtime-status/task-activity-block";+import { TaskActivitiesPanelTab } from "./task-activities-panel-tab";++/**+ * Lets the task blocks in an activity log open their Task's activity in+ * place, with a way back, instead of in another panel tab.+ */+export function TaskActivityDrillDown({+ children,+ hidden,+ tenantId,+}: {+ children: ReactNode;+ hidden: boolean;+ tenantId: string;+}) {+ const [task, setTask] = useState<{ id: string; title: string }>();+ return (+ <TaskActivityLinksProvider+ openTask={(id, title) => setTask({ id, title })}+ tenantId={tenantId}+ >+ <div className={task ? "hidden" : "contents"}>{children}</div>+ {task ? (+ <TaskActivitiesPanelTab+ hidden={hidden}+ onBack={() => setTask(undefined)}+ taskId={task.id}+ tenantId={tenantId}+ title={task.title}+ />+ ) : null}+ </TaskActivityLinksProvider>+ );+}