Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8647 perf(agents): virtualize recent work history (#9985)
DuellingSwordf230f9f55bdf
diff --git a/e2e/perf/README.md b/e2e/perf/README.mdindex 439e4caad3..ae2d86531d 100644--- a/e2e/perf/README.md+++ b/e2e/perf/README.md@@ -27,6 +27,30 @@ CHAT_LIST_BASELINE=1 PLAYWRIGHT_BASE_URL=http://localhost:3001 pnpm exec playwriits report format and comparisons are unchanged. Session data is still fetchedin full: these checks measure rendering, not API pagination or network savings.+## Agent recent work++`agent-recent-work.spec.ts` opens the real agent detail page, reveals 1,000+synthetic terminal runs using the existing Show more action and 200-run API+pages, then verifies a bounded mounted window, the last run's transcript,+Escape dismissal, and dialog survival when its opener is recycled. It covers+wide and compact layouts with the page's existing scroll owner. HTTP and+WebSocket traffic are intercepted; unexpected requests and page errors fail+the scenario. No server, daemon or real agent runs are involved.++Build with a same-origin API URL so all requests reach the synthetic boundary:++```bash+NEXT_PUBLIC_API_URL='' pnpm --filter @multica/web build+NEXT_PUBLIC_API_URL='' pnpm --filter @multica/web exec next start --port 3000+PLAYWRIGHT_BASE_URL=http://localhost:3000 pnpm exec playwright test --config=playwright.perf.config.ts agent-recent-work.spec.ts+```++For a comparison, run the same test against an unmodified main production+build with `AGENT_WORK_BASELINE=1`. Both sides keep API pagination; the baseline+asserts that all 1,000 revealed rows stay mounted while the new renderer keeps+fewer than 50. JSON attachments report the observed row counts and cursors;+these are rendering checks, not backend or network-throughput benchmarks.+## What it runs againstThe real Next.js production build, the real page, the real shell and CSS, thediff --git a/e2e/perf/agent-recent-work.spec.ts b/e2e/perf/agent-recent-work.spec.tsnew file mode 100644index 0000000000..465cbc6db8--- /dev/null+++ b/e2e/perf/agent-recent-work.spec.ts@@ -0,0 +1,216 @@+import { expect, test, type Page } from "@playwright/test";++// Real shared renderer, synthetic HTTP/WS only. No API server, account or run+// execution. Use the same scenario on main with AGENT_WORK_BASELINE=1.+const baseline = process.env.AGENT_WORK_BASELINE === "1";+const count = 1000;+const wsId = "11111111-1111-4111-8111-111111111111";+const userId = "22222222-2222-4222-8222-222222222222";+const agentId = "33333333-3333-4333-8333-333333333333";+const at = "2026-11-01T00:00:00Z";+const workspace = {+ id: wsId, name: "Perf", slug: "perf", description: null, context: null,+ settings: { github_enabled: false }, repos: [], issue_prefix: "PERF",+ avatar_url: null, created_at: at, updated_at: at,+};+const agent = {+ id: agentId, workspace_id: wsId, runtime_id: null, name: "Demo agent",+ description: "Synthetic recent work", instructions: "", avatar_url: null,+ runtime_mode: "local", runtime_config: {}, custom_args: [],+ visibility: "workspace", permission_mode: "public_to",+ invocation_targets: [{ target_type: "workspace", target_id: null }],+ status: "idle", max_concurrent_tasks: 1, model: "", owner_id: userId, skills: [],+ created_at: at, updated_at: at, archived_at: null, archived_by: null,+};+const tasks = Array.from({ length: count }, (_, i) => ({+ id: `aaaa${String(i).padStart(4, "0")}-4444-4444-8444-444444444444`,+ agent_id: agentId, runtime_id: "", issue_id: `PERF-${i + 1}`,+ status: i % 7 === 0 ? "failed" : "completed", priority: 0,+ started_at: new Date(Date.parse(at) - i * 60_000 - 12_000).toISOString(),+ completed_at: new Date(Date.parse(at) - i * 60_000).toISOString(),+ created_at: new Date(Date.parse(at) - i * 60_000 - 15_000).toISOString(),+ trigger_summary: `Synthetic run ${i + 1}`,+}));++function responseFor(path: string): unknown {+ switch (path) {+ case "/api/config": return { feature_flags: {}, allow_signup: true };+ case "/api/me": return {+ id: userId, name: "Demo User", email: "[email protected]", avatar_url: null,+ language: "en", onboarded_at: at, onboarding_questionnaire: { source: "other" },+ created_at: at, updated_at: at,+ };+ case "/api/workspaces": return [workspace];+ case "/api/agents": return [agent];+ case `/api/agents/${agentId}`: return agent;+ case "/api/agent-activity-30d": return [{+ agent_id: agentId, bucket_at: at, task_count: count,+ completed_count: 857, failed_count: 143, cancelled_count: 0,+ duration_ms: count * 12_000, duration_count: count,+ }];+ case "/api/client-usage": return {};+ case "/api/projects": return { projects: [], total: 0 };+ case "/api/issues": return { issues: [], total: 0 };+ case "/api/issue-statuses": return { statuses: [] };+ case "/api/properties": return { properties: [], total: 0 };+ case "/api/quick-actions": return { quick_actions: [] };+ case "/api/search-index/manifest": return {+ cursor: "0", issue_count: 0, comment_count: 0, project_count: 0, text_bytes: 0,+ };+ case "/api/search-index/snapshot": return {+ issues: [], comments: [], projects: [], next_after_number: 0, done: true,+ };+ case "/api/search-index/changes": return {+ issues: [], comments: [], projects: [], deleted: { issues: [], comments: [], projects: [] },+ cursor: "0", has_more: false,+ };+ case `/api/workspaces/${wsId}/members`: return [{+ id: userId, user_id: userId, workspace_id: wsId, role: "owner", name: "Demo User",+ email: "[email protected]", avatar_url: null, joined_at: at,+ }];+ case "/api/chat/sessions": case "/api/runtimes": case "/api/squads":+ case "/api/agent-task-snapshot": case "/api/invitations": case "/api/inbox":+ case "/api/inbox/unread-summary": case "/api/pins": case "/api/assignee-frequency":+ case "/api/skills": case "/api/autopilots": case "/api/agent-run-counts":+ return [];+ case "/api/chat/pending-tasks/has-any": return { has_pending: false };+ }+ if (new RegExp(`^/api/workspaces/${wsId}/(lark|slack|dingtalk|wecom|telegram)/installations$`).test(path)) {+ return { installations: [], configured: false };+ }+ const issue = /^\/api\/issues\/PERF-(\d+)$/.exec(path);+ if (issue) return {+ id: `PERF-${issue[1]}`, workspace_id: wsId, identifier: `PERF-${issue[1]}`,+ number: Number(issue[1]), title: `Synthetic work ${String(issue[1]).padStart(4, "0")}`,+ description: null, status: "done", priority: "none", assignee_type: null, assignee_id: null,+ creator_type: "user", creator_id: userId, parent_issue_id: null, project_id: null,+ position: 0, start_date: null, due_date: null, metadata: {}, properties: {},+ created_at: at, updated_at: at,+ };+ const messages = /^\/api\/tasks\/(aaaa\d{4}-4444-4444-8444-444444444444)\/messages$/.exec(path);+ if (messages) return [{+ task_id: messages[1], issue_id: "", seq: 1, type: "text",+ content: `Synthetic transcript for run ${Number(messages[1]!.slice(4, 8)) + 1}.`, created_at: at,+ }];+ return undefined;+}++async function setup(page: Page, baseURL: string) {+ const origin = new URL(baseURL).origin;+ const errors: string[] = [];+ const unexpected: string[] = [];+ const pages: string[] = [];+ page.on("pageerror", (error) => errors.push(error.message));+ await page.context().addCookies([+ { name: "multica_logged_in", value: "1", url: origin },+ { name: "last_workspace_slug", value: "perf", url: origin },+ ]);+ await page.addInitScript(() => {+ localStorage.setItem("multica:chat:floatingChatEnabled", "false");+ });+ await page.routeWebSocket(() => true, (socket) => socket.onMessage(() => {}));+ await page.route("**/*", async (route) => {+ const url = new URL(route.request().url());+ if (url.origin !== origin) {+ unexpected.push(url.origin + url.pathname);+ return route.abort();+ }+ if (!url.pathname.startsWith("/api/")) return route.continue();+ const syntheticPost = route.request().method() === "POST" &&+ ["/api/client-usage", "/api/search-index/changes"].includes(url.pathname);+ if (route.request().method() !== "GET" && !syntheticPost) {+ unexpected.push(`${route.request().method()} ${url.pathname}`);+ return route.abort();+ }+ if (url.pathname === `/api/agents/${agentId}/tasks`) {+ const before = url.searchParams.get("before");+ pages.push(before ?? "first");+ const start = before ? Number(before) : 0;+ const limit = Number(url.searchParams.get("limit"));+ const end = Math.min(start + limit, count);+ return route.fulfill({ json: tasks.slice(start, end), headers: end < count+ ? { "X-Agent-Tasks-Next-Cursor": String(end) } : {} });+ }+ const body = responseFor(url.pathname);+ if (body === undefined) {+ unexpected.push(`${route.request().method()} ${url.pathname}${url.search}`);+ return route.fulfill({ status: 404, json: {} });+ }+ return route.fulfill({ json: body });+ });+ return { errors, unexpected, pages };+}++test.use({ viewport: { width: 1440, height: 900 }, locale: "en-US", serviceWorkers: "block", actionTimeout: 10_000 });++for (const compact of [false, true]) {+ test(`recent work retains pagination and bounded rendering (${compact ? "compact" : "wide"})`, async ({ page, baseURL }) => {+ if (compact) await page.setViewportSize({ width: 390, height: 844 });+ const state = await setup(page, baseURL!);+ await page.goto(`/perf/agents/${agentId}`);+ const recent = page.locator("section").filter({ has: page.getByRole("heading", { name: "Recent work", exact: true, includeHidden: true }) });+ const rows = recent.getByRole("button", { name: "View transcript", exact: true });+ await expect(recent.getByText("Synthetic work 0001", { exact: true })).toBeVisible();+ expect(state.pages).toEqual(["first"]);+ expect(await rows.count()).toBeLessThanOrEqual(10);+ const more = recent.getByRole("button", { name: /^Show more/ });+ for (let i = 0; i < 50; i++) {+ await more.click({ timeout: 10_000 });+ if (i < 49) await expect(more).toBeEnabled();+ }+ await expect(more).toHaveCount(0);+ await expect(recent.getByText("Synthetic work 1000", { exact: true })).toBeVisible();+ expect(state.pages).toEqual(["first", "200", "400", "600", "800"]);+ const mounted = await rows.count();+ if (baseline) expect(mounted).toBe(count);+ else expect(mounted).toBeLessThan(50);+ const maxMountedWhileScrolling = await recent.evaluate(async (section) => {+ let owner = section.parentElement;+ while (owner && !/auto|scroll/.test(getComputedStyle(owner).overflowY)) owner = owner.parentElement;+ if (!owner) throw new Error("Missing page scroll owner");+ const end = section.getBoundingClientRect().bottom - owner.getBoundingClientRect().top + owner.scrollTop - owner.clientHeight;+ owner.scrollTop = 0;+ let max = 0;+ for (let frame = 0; frame <= 90; frame++) {+ owner.scrollTop = end * frame / 90;+ await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));+ max = Math.max(max, section.querySelectorAll('button[aria-label="View transcript"]').length);+ }+ return max;+ });+ if (!baseline) expect(maxMountedWhileScrolling).toBeLessThan(50);+ await expect(recent.getByText("Synthetic work 1000", { exact: true })).toBeInViewport();+ await expect(recent.getByRole("link", { name: "Open issue", exact: true }).last()).toHaveAttribute("href", "/perf/issues/PERF-1000");+ await page.screenshot({ path: test.info().outputPath("recent-work.png") });+ const last = rows.last();+ await last.click();+ await expect(page.getByRole("dialog")).toBeVisible();+ await expect(page.getByText("Synthetic transcript for run 1000.", { exact: true })).toBeVisible();+ // Model a scroll restoration/resize recycling the opener while its modal+ // is open. A normal modal prevents pointer scrolling of the page below it.+ await recent.evaluate((section) => {+ for (let parent = section.parentElement; parent; parent = parent.parentElement) {+ if (/auto|scroll/.test(getComputedStyle(parent).overflowY) && parent.clientHeight > 0) {+ parent.scrollTop = 0;+ return;+ }+ }+ throw new Error("Missing page scroll owner");+ });+ if (!baseline) await expect(recent.getByText("Synthetic work 1000", { exact: true })).toHaveCount(0);+ await expect(page.getByRole("dialog")).toBeVisible();+ await page.screenshot({ path: test.info().outputPath("transcript-retained.png") });+ await page.keyboard.press("Escape");+ await expect(page.getByRole("dialog")).toHaveCount(0);+ await expect(recent.getByText("Synthetic work 0001", { exact: true })).toBeVisible();+ await rows.first().press("Enter");+ await expect(page.getByText("Synthetic transcript for run 1.", { exact: true })).toBeVisible();+ await page.evaluate(() => window.dispatchEvent(new CustomEvent("multica:navigate")));+ await expect(page.getByRole("dialog")).toHaveCount(0);+ const report = { baseline, compact, revealed_rows: count, mounted_rows: mounted, max_mounted_while_scrolling: maxMountedWhileScrolling, task_pages: state.pages, errors: state.errors, unexpected_requests: state.unexpected };+ console.log(JSON.stringify(report));+ await test.info().attach("recent-work", { body: JSON.stringify(report, null, 2), contentType: "application/json" });+ expect(state.errors).toEqual([]);+ expect(state.unexpected).toEqual([]);+ });+}diff --git a/packages/views/agents/components/agent-detail-page.tsx b/packages/views/agents/components/agent-detail-page.tsxindex 7a8608113d..a8ca85ce3f 100644--- a/packages/views/agents/components/agent-detail-page.tsx+++ b/packages/views/agents/components/agent-detail-page.tsx@@ -116,6 +116,7 @@ interface AgentDetailPageProps {export function AgentDetailPage({ agentId }: AgentDetailPageProps) {const { t } = useT("agents");const wsId = useWorkspaceId();+ const [scrollParent, setScrollParent] = useState<HTMLDivElement | null>(null);const paths = useWorkspacePaths();const navigation = useNavigation();const qc = useQueryClient();@@ -627,6 +628,7 @@ export function AgentDetailPage({ agentId }: AgentDetailPageProps) {return (<><ObjectPage+ scrollRef={setScrollParent}layoutId={AGENT_DETAIL_LAYOUT_ID}segments={[listSegment]}leaf={@@ -674,7 +676,12 @@ export function AgentDetailPage({ agentId }: AgentDetailPageProps) {{notices.length > 0 && <div className="space-y-2">{notices}</div>}</div>- <AgentWorkSections agent={agent} onViewAll={() => openWork(true)} />+ <AgentWorkSections+ key={`${wsId}:${agent.id}`}+ agent={agent}+ scrollParent={scrollParent}+ onViewAll={() => openWork(true)}+ /><AgentInstructionsSectionagent={agent}diff --git a/packages/views/agents/components/tabs/activity-tab.render.test.tsx b/packages/views/agents/components/tabs/activity-tab.render.test.tsxindex 077b828238..ca8bb6ce6e 100644--- a/packages/views/agents/components/tabs/activity-tab.render.test.tsx+++ b/packages/views/agents/components/tabs/activity-tab.render.test.tsx@@ -1,8 +1,11 @@// @vitest-environment jsdom+import { useState } from "react";import { describe, it, expect, vi, beforeEach } from "vitest";import { render, screen, fireEvent, waitFor } from "@testing-library/react";+import { VirtuosoMockContext } from "react-virtuoso";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { api } from "@multica/core/api";import type { Agent, AgentActivityBucket, AgentTask } from "@multica/core/types";import { WorkspaceSlugProvider } from "@multica/core/paths";import { I18nProvider } from "@multica/core/i18n/react";@@ -19,8 +22,9 @@ vi.mock("@multica/core/hooks", () => ({useWorkspaceId: () => "ws-1",}));-// History fixtures have no issue links, so they need no issue-detail requests.-vi.mock("@multica/core/api", () => ({ api: {} }));+vi.mock("@multica/core/api", () => ({ api: {+ getIssue: vi.fn((id: string) => Promise.resolve({ id, title: `Issue ${id}`, identifier: id })),+} }));// Keep transcript internals out of history pagination tests while exposing// the identity of each rendered task row.@@ -65,6 +69,13 @@ const baseAgent = {const EMPTY_RECENT = "This agent hasn't completed anything yet.";+function WorkSections({ onViewAll }: { onViewAll: () => void }) {+ const [scrollParent, setScrollParent] = useState<HTMLDivElement | null>(null);+ return <div ref={setScrollParent} style={{ height: 1200, overflowY: "auto" }}>+ <AgentWorkSections agent={baseAgent} onViewAll={onViewAll} scrollParent={scrollParent} />+ </div>;+}+function renderTab(performance = false, onViewAll = vi.fn()) {const queryClient = new QueryClient({defaultOptions: { queries: { retry: false } },@@ -84,7 +95,9 @@ function renderTab(performance = false, onViewAll = vi.fn()) {<QueryClientProvider client={queryClient}><WorkspaceSlugProvider slug="acme">{performance && <AgentPerformanceSummary agent={baseAgent} />}- <AgentWorkSections agent={baseAgent} onViewAll={onViewAll} />+ <VirtuosoMockContext.Provider value={{ viewportHeight: 1600, itemHeight: 40 }}>+ <WorkSections onViewAll={onViewAll} />+ </VirtuosoMockContext.Provider></WorkspaceSlugProvider></QueryClientProvider></NavigationProvider>@@ -95,6 +108,7 @@ function renderTab(performance = false, onViewAll = vi.fn()) {beforeEach(() => {agentTasksRef.current = () => new Promise<unknown>(() => {});activityRef.current = [];+ vi.mocked(api.getIssue).mockClear();});describe("agent outcome presentation", () => {@@ -283,3 +297,37 @@ describe("AgentWorkSections section counts", () => {expect(onViewAll).toHaveBeenCalledTimes(1);});});+++describe("AgentWorkSections windowed history", () => {+ it("bounds mounted rows after repeatedly revealing cached history", async () => {+ agentTasksRef.current = () => Promise.resolve({+ tasks: Array.from({ length: 210 }, (_, i) => historyTask(i)),+ nextCursor: null,+ });+ renderTab();+ await screen.findByTestId("task-0");+ for (let i = 0; i < 10; i++) {+ fireEvent.click(screen.getByRole("button", { name: /Show more/ }));+ }+ expect(screen.queryByRole("button", { name: /Show more/ })).not.toBeInTheDocument();+ expect(screen.getAllByTestId(/^task-/).length).toBeLessThan(50);+ expect(document.querySelector("[data-virtuoso-scroller]")).toBeInTheDocument();+ });++ it("resolves issues only for the mounted window, sharing duplicate issue lookups", async () => {+ agentTasksRef.current = () => Promise.resolve({+ tasks: Array.from({ length: 210 }, (_, i) => ({ ...historyTask(i), issue_id: `issue-${Math.floor(i / 2)}` })),+ nextCursor: null,+ });+ renderTab();+ await screen.findAllByText("Issue issue-0");+ for (let i = 0; i < 10; i++) {+ fireEvent.click(screen.getByRole("button", { name: /Show more/ }));+ }+ await screen.findAllByText("Issue issue-10");+ expect(vi.mocked(api.getIssue).mock.calls.length).toBeLessThan(30);+ expect(vi.mocked(api.getIssue).mock.calls.filter(([id]) => id === "issue-0")).toHaveLength(1);+ expect(screen.queryByText("Issue issue-104")).not.toBeInTheDocument();+ });+});diff --git a/packages/views/agents/components/tabs/activity-tab.tsx b/packages/views/agents/components/tabs/activity-tab.tsxindex 7bcad49c23..dfb50327e4 100644--- a/packages/views/agents/components/tabs/activity-tab.tsx+++ b/packages/views/agents/components/tabs/activity-tab.tsx@@ -1,7 +1,7 @@"use client";import type { ReactNode } from "react";-import { useMemo, useState } from "react";+import { forwardRef, memo, useCallback, useMemo, useState } from "react";import {ArrowUpRight,CircleHelp,@@ -11,6 +11,7 @@ import {X,} from "@multica/ui/icons";import { toast } from "sonner";+import { Virtuoso, type ListProps } from "react-virtuoso";import {Tooltip,TooltipContent,@@ -19,8 +20,8 @@ import {import { Button } from "@multica/ui/components/ui/button";import { Skeleton } from "@multica/ui/components/ui/skeleton";import { cn } from "@multica/ui/lib/utils";-import { useInfiniteQuery, useQueries, useQuery } from "@tanstack/react-query";-import type { Agent, AgentTask, Issue } from "@multica/core/types";+import { useInfiniteQuery, useQuery } from "@tanstack/react-query";+import type { Agent, AgentTask } from "@multica/core/types";import {agentTaskSnapshotOptions,agentTasksOptions,@@ -32,7 +33,8 @@ import { useWorkspaceId } from "@multica/core/hooks";import { useWorkspacePaths } from "@multica/core/paths";import { issueDetailOptions } from "@multica/core/issues/queries";import { AppLink } from "../../../navigation";-import { TranscriptButton } from "../../../common/task-transcript";+import { TranscriptButton, type TimelineItem } from "../../../common/task-transcript";+import { VirtuosoSeed } from "../../../common/virtuoso-seed";import { AttributionBadge } from "../../../issues/components/attribution-badge";import {ObjectSection,@@ -47,6 +49,27 @@ import { useT, useTimeAgo } from "../../../i18n";// Reveal cached rows in small batches and fetch another page only on demand.const RECENT_INITIAL = 10;const RECENT_PAGE = 20;+const RECENT_ROW_HEIGHT = 41;+const RECENT_SCROLL_SEEK = {+ enter: (velocity: number) => Math.abs(velocity) > 2000,+ exit: (velocity: number) => Math.abs(velocity) < 300,+};+const RecentWorkList = forwardRef<HTMLDivElement, ListProps>(function RecentWorkList(+ { children, style, "data-testid": testId },+ ref,+) {+ return (+ <div ref={ref} style={style} data-testid={testId} className="divide-y">+ {children}+ </div>+ );+});+const RECENT_LIST_COMPONENTS = {+ List: RecentWorkList,+ ScrollSeekPlaceholder: RecentWorkScrollPlaceholder,+};+const recentTaskKey = (_index: number, task: AgentTask) => task.id;+// Placeholder rows shown while the lazily-loaded per-agent task list is// still in flight, so first paint is a skeleton rather than the "nothing// finished yet" empty state (which reads as a wrong answer).@@ -65,8 +88,10 @@ const TOUCH_ACTION_CLASS = "[@media(hover:none)]:p-2";export function AgentWorkSections({agent,onViewAll,+ scrollParent,}: {agent: Agent;+ scrollParent: HTMLElement | null;/** Opens every issue assigned to this agent. */onViewAll: () => void;}) {@@ -153,35 +178,9 @@ export function AgentWorkSections({);const hasMoreRecent = recentTasksAll.length > recentTasks.length || hasNextPage;- // Resolve issue identifiers + titles for any task we'll render. Going- // through `issueDetailOptions` is the same lookup the rest of the app- // uses, so the cache is shared and we don't pay for a duplicate request.- const displayedTasks = useMemo(- () => [...activeTasks, ...recentTasks],- [activeTasks, recentTasks],- );- const issueIds = useMemo(- () =>- Array.from(- new Set(displayedTasks.map((t) => t.issue_id).filter((id) => id !== "")),- ),- [displayedTasks],- );- const issueQueries = useQueries({- queries: issueIds.map((id) => issueDetailOptions(wsId, id)),- });- const issueMap = useMemo(() => {- const m = new Map<string, Issue>();- issueQueries.forEach((q, i) => {- const id = issueIds[i]!;- if (q.data) m.set(id, q.data);- });- return m;- }, [issueQueries, issueIds]);-return (<>- <NowSection tasks={activeTasks} issueMap={issueMap} agent={agent} />+ <NowSection tasks={activeTasks} agent={agent} /><RecentWorkSectiontasks={recentTasks}weekRuns={activityLoading ? null : weekRuns}@@ -201,7 +200,7 @@ export function AgentWorkSections({}}}onViewAll={onViewAll}- issueMap={issueMap}+ scrollParent={scrollParent}agent={agent}/></>@@ -318,11 +317,9 @@ export function SuccessRate({function NowSection({tasks,- issueMap,agent,}: {tasks: AgentTask[];- issueMap: Map<string, Issue>;agent: Agent;}) {const { t } = useT("agents");@@ -342,7 +339,7 @@ function NowSection({) : (<ObjectSectionCard>{tasks.map((task) => (- <LiveTaskRow key={task.id} task={task} issueMap={issueMap} agent={agent} />+ <LiveTaskRow key={task.id} task={task} agent={agent} />))}</ObjectSectionCard>)}@@ -359,9 +356,10 @@ function RecentWorkSection({fetchingMore,fetchMoreFailed,onViewAll,- issueMap,agent,+ scrollParent,}: {+ scrollParent: HTMLElement | null;tasks: AgentTask[];/** Runs in the last 7 days; `null` until the activity window has loaded. */weekRuns: number | null;@@ -371,10 +369,23 @@ function RecentWorkSection({fetchingMore: boolean;fetchMoreFailed: boolean;onViewAll: () => void;- issueMap: Map<string, Issue>;agent: Agent;}) {const { t } = useT("agents");+ const [transcript, setTranscript] = useState<{+ task: AgentTask;+ items: TimelineItem[];+ fromKeyboard: boolean;+ } | null>(null);+ const openTranscript = useCallback((task: AgentTask, items: TimelineItem[], fromKeyboard: boolean) => {+ setTranscript({ task, items, fromKeyboard });+ }, []);+ const closeTranscript = useCallback((open: boolean) => {+ if (!open) setTranscript(null);+ }, []);+ const renderRow = useCallback((_index: number, task: AgentTask) => (+ <RecentTaskRow task={task} agentName={agent.name} onOpenTranscript={openTranscript} />+ ), [agent.name, openTranscript]);return (<ObjectSectiontitle={t(($) => $.tab_body.activity.section_recent)}@@ -399,11 +410,40 @@ function RecentWorkSection({)) : (<ObjectSectionCard>- {tasks.map((task) => (- <RecentTaskRow key={task.id} task={task} issueMap={issueMap} agent={agent} />- ))}+ {scrollParent ? (+ <Virtuoso+ data={tasks}+ customScrollParent={scrollParent}+ defaultItemHeight={RECENT_ROW_HEIGHT}+ initialItemCount={Math.min(RECENT_INITIAL, tasks.length)}+ increaseViewportBy={200}+ components={RECENT_LIST_COMPONENTS}+ scrollSeekConfiguration={RECENT_SCROLL_SEEK}+ computeItemKey={recentTaskKey}+ itemContent={renderRow}+ />+ ) : (+ <VirtuosoSeed+ data={tasks}+ count={RECENT_INITIAL}+ estimatedItemHeight={RECENT_ROW_HEIGHT}+ computeItemKey={recentTaskKey}+ itemContent={renderRow}+ />+ )}</ObjectSectionCard>)}+ {transcript && (+ <TranscriptButton+ task={transcript.task}+ agentName={agent.name}+ items={transcript.items}+ renderButton={false}+ open+ finalFocus={transcript.fromKeyboard}+ onOpenChange={closeTranscript}+ />+ )}{!loading && hasMore && (<Buttontype="button"@@ -421,6 +461,16 @@ function RecentWorkSection({);}+function RecentWorkScrollPlaceholder({ height }: { height: number }) {+ return (+ <div style={{ height }} aria-hidden="true" className="flex items-center gap-3 px-3">+ <div className="size-4 shrink-0 rounded-full bg-muted" />+ <div className="h-3 w-3/5 rounded-xs bg-muted" />+ <div className="ml-auto h-3 w-24 rounded-xs bg-muted" />+ </div>+ );+}+/*** Loading placeholder for the Recent work list. Mirrors the card and the* one-line row rhythm so the skeleton settles into the real rows without a@@ -448,11 +498,15 @@ type AgentsT = ReturnType<typeof useT<"agents">>["t"];type TimeAgoFn = (dateStr: string) => string;/** What every task row shows, whichever section it sits in. */-function useTaskRowModel(task: AgentTask, issueMap: Map<string, Issue>) {+function useTaskRowModel(task: AgentTask) {const { t } = useT("agents");const cfg = taskStatusConfig[task.status] ?? taskStatusConfig.queued!;const hasIssue = task.issue_id !== "";- const issue = hasIssue ? issueMap.get(task.issue_id) : undefined;+ const wsId = useWorkspaceId();+ const { data: issue } = useQuery({+ ...issueDetailOptions(wsId, task.issue_id),+ enabled: hasIssue,+ });const isTerminalStatus =task.status === "completed" ||task.status === "failed" ||@@ -564,11 +618,9 @@ const HOVER_ACTIONS_CLASS =/** A run in progress: what it is working on, for how long, and a way in. */function LiveTaskRow({task,- issueMap,agent,}: {task: AgentTask;- issueMap: Map<string, Issue>;agent: Agent;}) {const { t } = useT("agents");@@ -576,7 +628,7 @@ function LiveTaskRow({const paths = useWorkspacePaths();const [cancelling, setCancelling] = useState(false);const { cfg, hasIssue, issue, title, SourceIcon, sourceLabel, sourceFallback, statusLabel } =- useTaskRowModel(task, issueMap);+ useTaskRowModel(task);const Icon = cfg.icon;const isRunning = task.status === "running";// Queued tasks have no messages yet — hiding the transcript button avoids@@ -680,19 +732,19 @@ function LiveTaskRow({}/** A finished run on one line: outcome, what it was, and when. */-function RecentTaskRow({+const RecentTaskRow = memo(function RecentTaskRow({task,- issueMap,- agent,+ agentName,+ onOpenTranscript,}: {task: AgentTask;- issueMap: Map<string, Issue>;- agent: Agent;+ agentName: string;+ onOpenTranscript: (task: AgentTask, items: TimelineItem[], fromKeyboard: boolean) => void;}) {const { t } = useT("agents");const timeAgo = useTimeAgo();const { cfg, hasIssue, issue, title, SourceIcon, sourceLabel, failureLabel, statusLabel } =- useTaskRowModel(task, issueMap);+ useTaskRowModel(task);const Icon = cfg.icon;let durationText: string | null = null;@@ -743,15 +795,16 @@ function RecentTaskRow({{hasIssue && <OpenIssueIconLink issueId={task.issue_id} />}<TranscriptButtontask={task}- agentName={agent.name}+ agentName={agentName}isLive={false}+ onOpenTranscript={(items, fromKeyboard) => onOpenTranscript(task, items, fromKeyboard)}title={t(($) => $.tab_body.activity.transcript_tooltip)}className={TOUCH_ACTION_CLASS}/></div></div>);-}+});function Sep() {// mx-1 puts visible whitespace around the dot; without it inline JSXdiff --git a/packages/views/common/task-transcript/transcript-button.test.tsx b/packages/views/common/task-transcript/transcript-button.test.tsxindex 568ad6a44c..54feff0f86 100644--- a/packages/views/common/task-transcript/transcript-button.test.tsx+++ b/packages/views/common/task-transcript/transcript-button.test.tsx@@ -246,3 +246,25 @@ describe("TranscriptButton", () => {);});});+++describe("TranscriptButton hosted terminal dialog", () => {+ it("hands the loaded timeline and keyboard intent to the list owner", async () => {+ listTaskMessages.mockResolvedValue([msg(1, "Read")]);+ const onOpenTranscript = vi.fn();+ renderWith(newClient(), <TranscriptButton+ task={{ ...baseTask, status: "completed" }}+ agentName="Demo agent"+ onOpenTranscript={onOpenTranscript}+ />);+ fireEvent.click(screen.getByRole("button", { name: "View transcript" }), { detail: 0 });+ await waitFor(() => expect(onOpenTranscript).toHaveBeenCalledTimes(1));+ expect(onOpenTranscript.mock.calls[0]?.[0]).toHaveLength(1);+ expect(onOpenTranscript.mock.calls[0]?.[1]).toBe(true);+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: "View transcript" }), { detail: 1 });+ expect(onOpenTranscript).toHaveBeenCalledTimes(2);+ expect(onOpenTranscript.mock.calls[1]?.[1]).toBe(false);+ expect(listTaskMessages).toHaveBeenCalledTimes(1);+ });+});diff --git a/packages/views/common/task-transcript/transcript-button.tsx b/packages/views/common/task-transcript/transcript-button.tsxindex d7f64f597f..b82684abce 100644--- a/packages/views/common/task-transcript/transcript-button.tsx+++ b/packages/views/common/task-transcript/transcript-button.tsx@@ -48,6 +48,8 @@ interface TranscriptButtonProps {* somewhere else never sees the click that would tell it.*/finalFocus?: boolean;+ /** Host a terminal transcript outside a row that may be virtualized away. */+ onOpenTranscript?: (items: TimelineItem[], fromKeyboard: boolean) => void;/*** Optional content rendered above the transcript event list. Used to* surface autopilot webhook payloads inline with the run history.@@ -80,6 +82,7 @@ export function TranscriptButton({open: controlledOpen,onOpenChange: controlledOnOpenChange,finalFocus,+ onOpenTranscript,headerSlot,}: TranscriptButtonProps) {const [uncontrolledOpen, setUncontrolledOpen] = useState(false);@@ -130,25 +133,30 @@ export function TranscriptButton({setOpen(true, keyboard);return;}+ const openTerminal = (timeline: TimelineItem[]) => {+ if (onOpenTranscript) onOpenTranscript(timeline, keyboard);+ else setOpen(true, keyboard);+ };if (providedItems !== undefined || loadedItems !== null) {- setOpen(true, keyboard);+ openTerminal(providedItems ?? loadedItems ?? []);return;}setLoading(true);api.listTaskMessages(task.id).then((msgs) => {- setLoadedItems(buildTimeline(msgs));- setOpen(true, keyboard);+ const timeline = buildTimeline(msgs);+ setLoadedItems(timeline);+ openTerminal(timeline);}).catch((err) => {console.error(err);setLoadedItems([]);- setOpen(true, keyboard);+ openTerminal([]);}).finally(() => setLoading(false));},- [liveCacheMode, providedItems, loadedItems, setOpen, task.id],+ [liveCacheMode, providedItems, loadedItems, setOpen, task.id, onOpenTranscript],);useEffect(() => {diff --git a/packages/views/layout/object-page.tsx b/packages/views/layout/object-page.tsxindex 303944ec56..a03a1377e0 100644--- a/packages/views/layout/object-page.tsx+++ b/packages/views/layout/object-page.tsx@@ -7,6 +7,7 @@ import {useState,type ComponentProps,type ReactNode,+ type Ref,} from "react";import { useDefaultLayout, usePanelRef } from "react-resizable-panels";import { ChevronRight, PanelRight, type IconComponent } from "@multica/ui/icons";@@ -53,6 +54,8 @@ interface ObjectPageProps {* keeps its place while the body changes.*/children: ReactNode;+ /** The body scroll owner, for sections that virtualize their rows. */+ scrollRef?: Ref<HTMLDivElement>;}/**@@ -61,7 +64,7 @@ interface ObjectPageProps {* right panel the header toggles — the layout the issue page already uses.* There are no tabs: what a tab would hold is a section of the body.*/-export function ObjectPage({ segments, leaf, actions, panel, layoutId, children }: ObjectPageProps) {+export function ObjectPage({ segments, leaf, actions, panel, layoutId, children, scrollRef }: ObjectPageProps) {const { t } = useT("layout");const isMobile = useIsMobile();const { defaultLayout, onLayoutChanged } = useDefaultLayout({ id: layoutId });@@ -126,7 +129,7 @@ export function ObjectPage({ segments, leaf, actions, panel, layoutId, children/>);- const body = <div className="flex min-h-0 flex-1 flex-col overflow-y-auto">{children}</div>;+ const body = <div ref={scrollRef} className="flex min-h-0 flex-1 flex-col overflow-y-auto">{children}</div>;if (!panel) {return (