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.
fix(web): show Task steps and trajectories as Runtimes report them
LeoXing54128ffee2c2
diff --git a/apps/web/src/features/rooms/chat/background-tasks-indicator.tsx b/apps/web/src/features/rooms/chat/background-tasks-indicator.tsxindex 29263fc9..16a86689 100644--- a/apps/web/src/features/rooms/chat/background-tasks-indicator.tsx+++ b/apps/web/src/features/rooms/chat/background-tasks-indicator.tsx@@ -104,12 +104,12 @@ export function BackgroundTasksPill({<ul className="flex flex-col">{tasks.map((task) => (<li- className="flex items-center gap-1 rounded-md hover:bg-muted"+ className="flex items-center gap-1.5 rounded-md hover:bg-muted"key={task.id}><buttonaria-label={`Open task ${task.title}`}- className="grid min-w-0 flex-1 grid-cols-[6px_minmax(0,1fr)_auto] items-baseline gap-x-2.5 rounded-md py-1.5 pl-2 text-left focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-app-focus disabled:cursor-default"+ className="grid min-w-0 flex-1 grid-cols-[6px_minmax(0,1fr)_auto] items-baseline gap-x-2.5 rounded-md py-1.5 pr-1 pl-2 text-left focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-app-focus disabled:cursor-default"disabled={!onOpen}onClick={() => {setOpen(false);diff --git a/apps/web/src/features/rooms/chat/cancel-task-button.tsx b/apps/web/src/features/rooms/chat/cancel-task-button.tsxindex 3e7ea4ab..bc7c8d47 100644--- a/apps/web/src/features/rooms/chat/cancel-task-button.tsx+++ b/apps/web/src/features/rooms/chat/cancel-task-button.tsx@@ -9,9 +9,12 @@ import { cn } from "@/lib/cn";*/export function CancelTaskButton({cancel,+ prominent = false,title,}: {cancel: () => Promise<void>;+ /** A dialog's own action button, rather than a quiet link in a list row. */+ prominent?: boolean;title: string;}) {const [state, setState] = useState<"idle" | "pending" | "error">("idle");@@ -23,8 +26,9 @@ export function CancelTaskButton({: `Cancel ${title}`}className={cn(- "h-7 px-1.5 text-[12px] font-medium hover:bg-transparent hover:text-app-danger",- state === "error" ? "text-app-danger" : "text-app-muted",+ !prominent &&+ "h-7 px-1.5 text-[12px] font-medium hover:bg-transparent hover:text-app-danger",+ state === "error" ? "text-app-danger" : !prominent && "text-app-muted",)}disabled={state === "pending"}onClick={() => {@@ -35,14 +39,16 @@ export function CancelTaskButton({);}}size="compact"- tone="ghost"+ tone={prominent ? "secondary" : "ghost"}type="button">{state === "pending"? "Canceling": state === "error"? "Retry"- : "Cancel"}+ : prominent+ ? "Cancel task"+ : "Cancel"}</Button>);}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 1d0249b3..ef70f166 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@@ -23,7 +23,6 @@ import {} 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,@@ -214,20 +213,17 @@ function RuntimeActivityPathRow({ item }: { item: RuntimeActivityPathItem }) {</li>);}+ if (item.kind === "task") {+ return (+ <TaskActivityBlock+ active={item.active}+ command={item.command}+ failed={item.failed}+ taskId={item.taskId}+ />+ );+ }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@@ -524,33 +520,3 @@ 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/runtime-activity-path.test.tsx b/apps/web/src/features/rooms/runtime-status/runtime-activity-path.test.tsxindex 291d6907..e89a968e 100644--- a/apps/web/src/features/rooms/runtime-status/runtime-activity-path.test.tsx+++ b/apps/web/src/features/rooms/runtime-status/runtime-activity-path.test.tsx@@ -45,6 +45,54 @@ describe("Runtime activity path", () => {expect(screen.getByText("Unconfirmed")).toBeVisible();},);+ it("keeps each Task step its own item whatever kind the Computer gave it", () => {+ const input = (command: string) => [+ {+ content: JSON.stringify({ command }),+ format: "json" as const,+ label: "Input",+ },+ ];+ const items = projectRuntimeActivityPath([+ record("1", {+ activity_id: "create",+ content: input(+ 'teamhub task create --name "Rivals" --requirement "Compare"',+ ),+ kind: "delegation",+ title: "Bash",+ type: "activity.started",+ }),+ record("2", {+ activity_id: "create",+ outcome: "succeeded",+ type: "activity.finished",+ }),+ record("3", {+ activity_id: "send",+ content: input(+ 'teamhub task send --task-id workitem_1 --message "Add pricing"',+ ),+ kind: "tool",+ title: "Bash",+ type: "activity.started",+ }),+ ]);+ expect(items).toMatchObject([+ {+ active: false,+ command: { name: "Rivals", operation: "create" },+ kind: "task",+ },+ {+ active: true,+ command: { operation: "send" },+ kind: "task",+ taskId: "workitem_1",+ },+ ]);+ });+it("positions the viewport at the bottom of the latest activity, including a tall last entry", async () => {render(<RuntimeActivityPathdiff --git a/apps/web/src/features/rooms/runtime-status/runtime-activity-path.ts b/apps/web/src/features/rooms/runtime-status/runtime-activity-path.tsindex 3bd3200c..4b922dc3 100644--- a/apps/web/src/features/rooms/runtime-status/runtime-activity-path.ts+++ b/apps/web/src/features/rooms/runtime-status/runtime-activity-path.ts@@ -7,6 +7,11 @@ import {type RuntimeActivityPresentation,type RuntimePlanPresentation,} from "./runtime-presentation-events";+import {+ parseTaskCommand,+ taskIdFromOutput,+ type TaskCommand,+} from "./task-command";export type RuntimeActivityLifecycle =| "active"@@ -48,6 +53,14 @@ export type RuntimeActivityPathItem =kind: "tool_calls";key: string;}+ | {+ active: boolean;+ command: TaskCommand;+ failed: boolean;+ key: string;+ kind: "task";+ taskId?: string;+ }| {explanation?: string;key: string;@@ -199,7 +212,8 @@ export function projectRuntimeActivityPath(active: false,unconfirmed: item.outcome === undefined,};- if (item.kind === "thinking") return { ...item, active: false };+ if (item.kind === "thinking" || item.kind === "task")+ return { ...item, active: false };if (item.kind === "plan")return {...item,@@ -256,6 +270,21 @@ function pushActivity(const entries = activity.entries ?? [];const active = activity.outcome === undefined;if (activity.kind === "response") return;+ // The Computer names a TeamHub command by what it does, so a Task step can+ // arrive as any kind; its `teamhub task` command line is what marks it.+ const task = parseTaskCommand(commandText(entries));+ if (task) {+ const taskId = task.taskId ?? taskIdFromOutput(outputText(entries));+ items.push({+ active,+ command: task,+ failed: activity.outcome === "failed",+ key: activity.activityId,+ kind: "task",+ ...(taskId ? { taskId } : {}),+ });+ return;+ }if (activity.kind === "command") {items.push({active,@@ -304,6 +333,36 @@ function pushActivity(});}+/** The command line an Activity ran, from its first code or JSON block. */+function commandText(entries: readonly RuntimeActivityEntry[]) {+ 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; a CLI receipt would be among them. */+function outputText(entries: readonly RuntimeActivityEntry[]) {+ return entries+ .map((entry) => (entry.type === "content" ? entry.block.content : ""))+ .join("\n");+}+function commandSummary(activity: RuntimeActivityPresentation) {const codeBlock = activity.entries?.find((entry) =>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.tsxindex 8dcbb902..526da863 100644--- a/apps/web/src/features/rooms/runtime-status/task-activity-block.tsx+++ b/apps/web/src/features/rooms/runtime-status/task-activity-block.tsx@@ -12,12 +12,17 @@ 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 {+ roomTasksQueryOptions,+ tenantWorkItemTargetQueryOptions,+} from "@/features/work-items/work-item-queries";import { RunningDots } from "../task-sidebar/running-dots";import type { TaskCommand } from "./task-command";interface TaskActivityLinks {+ /** The Room whose Meta ran these steps. */+ roomId: string;tenantId: string;openTask?: (taskId: string, title: string) => void;}@@ -28,10 +33,11 @@ const TaskActivityLinksContext = createContext<TaskActivityLinks | null>(null);export function TaskActivityLinksProvider({children,openTask,+ roomId,tenantId,}: TaskActivityLinks & { children: ReactNode }) {return (- <TaskActivityLinksContext.Provider value={{ openTask, tenantId }}>+ <TaskActivityLinksContext.Provider value={{ openTask, roomId, tenantId }}>{children}</TaskActivityLinksContext.Provider>);@@ -68,18 +74,32 @@ export function TaskActivityBlock({const links = useContext(TaskActivityLinksContext);const { client } = useTeamHubRuntime();const tenantId = links?.tenantId ?? "";- const readable = Boolean(taskId && tenantId) && command.operation !== "check";+ // A create step's receipt stays on the Computer, so it names no Task; the+ // Room's Tasks hold it under the same name once the step has finished.+ const named = useQuery({+ ...roomTasksQueryOptions(client, tenantId, links?.roomId ?? ""),+ enabled:+ !taskId &&+ !active &&+ command.operation === "create" &&+ Boolean(command.name && links?.roomId),+ retry: false,+ select: (page) => page.items.filter((task) => task.title === command.name),+ });+ const id =+ taskId ?? (named.data?.length === 1 ? named.data[0]!.id : undefined);+ const readable = Boolean(id && tenantId) && command.operation !== "check";const item = useQuery({- ...tenantWorkItemTargetQueryOptions(client, tenantId, taskId ?? ""),+ ...tenantWorkItemTargetQueryOptions(client, tenantId, id ?? ""),enabled: readable && !command.name,retry: false,});const execution = useQuery({- queryKey: ["teamhub", tenantId, "task-execution", taskId],+ queryKey: ["teamhub", tenantId, "task-execution", id],queryFn: () =>teamHubData(client.api.GET("/v0/tasks/{taskId}/execution", {- params: { path: { taskId: taskId ?? "" } },+ params: { path: { taskId: id ?? "" } },}),),enabled: readable,@@ -95,8 +115,8 @@ export function TaskActivityBlock({? undefined: (command.name ?? item.data?.title);const open =- taskId && title !== undefined && links?.openTask- ? () => links.openTask?.(taskId, title)+ id && title !== undefined && links?.openTask+ ? () => links.openTask?.(id, title): undefined;const row = (<>@@ -162,7 +182,7 @@ export function TaskStatusPill({case "waiting_for_approval":return <StatusPill tone="warning">Needs approval</StatusPill>;case "idle":- return <StatusPill tone="success">Reported</StatusPill>;+ return <StatusPill tone="success">Finished</StatusPill>;case "failed":return <StatusPill tone="danger">Failed</StatusPill>;case "canceled":diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsxindex d21fbeb7..a163a315 100644--- a/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsx+++ b/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsx@@ -28,6 +28,7 @@ import {} from "../../runtime-status/task-activity-block";import { useTaskActivityEvents } from "../../runtime-status/use-task-activity-events";import { PanelLoading } from "../panel-loading";+import { RunningDots } from "../running-dots";import { RuntimeTrajectoryView } from "./runtime-trajectory-view";/** Lets the task blocks in an activity log open their Task's conversation. */@@ -45,6 +46,7 @@ export function TaskConversationProvider({return (<TaskActivityLinksProvideropenTask={(id, title) => setTask({ id, title })}+ roomId={roomId}tenantId={tenantId}>{children}@@ -130,25 +132,26 @@ export function TaskConversationDialog({return (<ModalDialogcloseOnBackdrop- description={- execution ? (- <span className="inline-flex items-center gap-1">- <TaskStatusPill status={execution.status} />- {live ? (- <CancelTaskButton- cancel={async () => {- await cancel(taskId);- await data.execution.refetch();- }}- title={title}- />- ) : null}- </span>+ footer={+ live ? (+ <CancelTaskButton+ cancel={async () => {+ await cancel(taskId);+ await data.execution.refetch();+ }}+ prominent+ title={title}+ />) : undefined}onClose={onClose}size="lg"- title={title}+ title={+ <span className="flex min-w-0 items-center gap-2">+ <span className="truncate">{title}</span>+ {execution ? <TaskStatusPill status={execution.status} /> : null}+ </span>+ }><divaria-label="Task conversation"@@ -246,8 +249,13 @@ function TaskConversationRun({),retry: false,});- // Native history may lag a live turn; its published steps stand in.- const native = history.data?.status === "available" && history.data.records;+ // Native history links a turn by its tool calls, so a turn without one,+ // or a live turn the Runtime has not written yet, has none; its published+ // steps stand in.+ const native =+ history.data?.status === "available" && history.data.records.length > 0+ ? history.data.records+ : undefined;const events = useTaskActivityEvents({tenantId,roomId,@@ -268,8 +276,20 @@ function TaskConversationRun({size="sm"/><div className="min-w-0 flex-1">- <p className="mb-1 text-sm text-app-ink">+ <p className="mb-1 flex items-center gap-2 text-sm text-app-ink">{runStatus.agent.display_name}+ {active && !paused ? (+ <span className="flex items-center gap-1.5 text-xs text-app-muted">+ Working+ <span+ aria-label="Agent working"+ className="flex h-3.5 items-center text-app-info"+ role="img"+ >+ <RunningDots />+ </span>+ </span>+ ) : null}</p>{native ? (<RuntimeTrajectoryView live={active} records={native} />diff --git a/apps/web/src/features/work-items/work-item-queries.ts b/apps/web/src/features/work-items/work-item-queries.tsindex fb10e458..1a7a6371 100644--- a/apps/web/src/features/work-items/work-item-queries.ts+++ b/apps/web/src/features/work-items/work-item-queries.ts@@ -91,6 +91,34 @@ export function tenantAgentWorkItemsQueryOptions(});}+/** Every Task the Room's Meta delegated, finished ones included. */+export function roomTasksQueryOptions(+ client: Pick<TeamHubClient, "api">,+ tenantId: string,+ roomId: string,+) {+ return queryOptions({+ queryFn: () =>+ collectTeamHubCursorPages((pagination) =>+ teamHubData(+ client.api.GET("/v0/tenants/{tenantId}/work-items", {+ params: {+ path: { tenantId },+ query: {+ ...pagination,+ kind: "task",+ origin_room_id: roomId,+ scope: "tenant",+ },+ },+ }),+ ),+ ),+ queryKey: ["teamhub", tenantId, "work-items", "room-tasks", roomId],+ staleTime: 0,+ });+}+export function tenantWorkItemsDashboardQueryOptions(client: Pick<TeamHubClient, "api">,tenantId: string,