Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): open subtask details from task content
chengyongru0978ccd50f33
diff --git a/webui/browser/subagent-dock.spec.ts b/webui/browser/subagent-dock.spec.tsindex 3ba463230..975ebcfad 100644--- a/webui/browser/subagent-dock.spec.ts+++ b/webui/browser/subagent-dock.spec.ts@@ -50,7 +50,7 @@ for (const width of [1440, 390]) {await page.mouse.move(1, 1);await page.screenshot({ path: info.outputPath("subtask-tree.png") });const row = tree.locator('[data-subagent-id="preview-0"]');- await row.click();+ await tree.getByText("read_file", { exact: true }).click();const detail = page.getByRole("dialog", { name: "检查项目实现", exact: true });await expect(detail).toBeVisible();await expect(detail).toBeFocused();@@ -138,18 +138,10 @@ for (const width of [1440, 390]) {expect(dimensions.scrollWidth).toBe(dimensions.clientWidth);expect(dimensions.scrollHeight).toBeGreaterThan(dimensions.clientHeight);await page.screenshot({ path: info.outputPath("result-markdown-start.png") });- const copy = await tree.getByRole("button", { name: "Copy code", exact: true }).elementHandle();- await tree.evaluate((node, copyButton) => {- const header = node.querySelector('[data-subagent-id="preview-0"]')!.getBoundingClientRect();- const bounds = copyButton!.getBoundingClientRect();- node.scrollTop += bounds.y + bounds.height / 2 - header.y - header.height / 2;- }, copy);- expect(await row.evaluate((node, copyButton) => {- const header = node.getBoundingClientRect();- const bounds = copyButton!.getBoundingClientRect();- return node.contains(document.elementFromPoint(bounds.x + bounds.width / 2, header.y + header.height / 2));- }, copy)).toBe(true);- await tree.evaluate(node => { node.scrollTop = 0; });+ await page.context().grantPermissions(["clipboard-read", "clipboard-write"]);+ await tree.getByRole("button", { name: "Copy code", exact: true }).click();+ await expect(tree.getByRole("button", { name: "Copied", exact: true })).toBeVisible();+ await expect(page.getByRole("dialog")).toHaveCount(0);const beforeScroll = await messages.evaluate(node => node.scrollTop);const tail = tree.getByText("最后一条完整结论:以上结果均可继续核对。", { exact: true });await tail.scrollIntoViewIfNeeded();@@ -158,19 +150,25 @@ for (const width of [1440, 390]) {await expect(tree.locator("pre")).toContainText("checked_at: 2026-10-25T20:52:00+08:00");expect(await messages.evaluate(node => node.scrollTop)).toBe(beforeScroll);await page.screenshot({ path: info.outputPath("result-markdown-end.png") });- await expect(row).toBeInViewport();- expect(await row.evaluate(node => {- const bounds = node.getBoundingClientRect();- return node.contains(document.elementFromPoint(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2));- })).toBe(true);- await tail.dblclick();+ const tailBounds = (await tail.boundingBox())!;+ await page.mouse.move(tailBounds.x + 2, tailBounds.y + tailBounds.height / 2);+ await page.mouse.down();+ await page.mouse.move(tailBounds.x + Math.min(120, tailBounds.width - 2), tailBounds.y + tailBounds.height / 2, { steps: 6 });+ await page.mouse.up();expect(await page.evaluate(() => window.getSelection()?.toString())).toBeTruthy();await expect(page.getByRole("dialog")).toHaveCount(0);+ await page.route("https://example.com/weather", route => route.fulfill({ body: "Weather source" }));+ const sourceOpened = page.waitForEvent("popup");+ await tree.getByRole("link", { name: "天气来源", exact: true }).click();+ const source = await sourceOpened;+ await expect(source).toHaveURL("https://example.com/weather");+ await source.close();+ await expect(page.getByRole("dialog")).toHaveCount(0);const readingPosition = await tree.evaluate(node => node.scrollTop);const input = page.getByRole("textbox").first();await input.fill("继续阅读完整结果,同时输入下一条消息");await expect(trigger).toHaveAttribute("aria-expanded", "true");- await row.click();+ await tail.click();const detail = page.getByRole("dialog", { name: "检查项目实现", exact: true });await expect(detail.getByRole("heading", { level: 2, name: "天气结果" })).toBeVisible();await expect(detail).toHaveAccessibleDescription("Completed");@@ -523,9 +521,33 @@ test.describe("touch task drawer", () => {await swipe(tree, -100);await expect.poll(() => tree.evaluate(node => node.scrollTop)).toBeGreaterThan(0);await expect(trigger).toHaveAttribute("aria-expanded", "true");+ await expect(page.getByRole("dialog")).toHaveCount(0);await cdp.detach();});+ test("opens task details by tapping tool activity and scrolled result content", async ({ page }) => {+ await page.goto("/browser/fixture.html?case=subagent-dock&markdown-result");+ await page.getByTestId("subagent-task-dock-trigger").tap();+ const tree = page.getByTestId("subagent-task-tree");+ await settledMotion(page.getByTestId("subagent-task-dock"));+ await tree.getByText("read_file", { exact: true }).tap();+ const detail = page.getByRole("dialog", { name: "检查项目实现", exact: true });+ await expect(detail).toHaveAccessibleDescription("Running");+ await detail.getByRole("button", { name: "Close", exact: true }).tap();+ await expect(detail).toHaveCount(0);+ await page.getByRole("button", { name: "全部完成", exact: true }).evaluate(node => (node as HTMLButtonElement).click());+ const tail = tree.getByText("最后一条完整结论:以上结果均可继续核对。", { exact: true });+ await tail.scrollIntoViewIfNeeded();+ await settledMotion(page.getByTestId("subagent-task-dock"));+ const readingPosition = await tree.evaluate(node => node.scrollTop);+ await tail.tap();+ await expect(detail).toHaveAccessibleDescription("Completed");+ await detail.getByRole("button", { name: "Close", exact: true }).tap();+ await expect(detail).toHaveCount(0);+ expect(await tree.evaluate(node => node.scrollTop)).toBeCloseTo(readingPosition, 0);+ await expect(tail).toBeInViewport();+ });+test("preserves completion feedback when an opening drag is cancelled", async ({ page }) => {await page.emulateMedia({ reducedMotion: "reduce", colorScheme: "dark" });await page.goto("/browser/fixture.html?case=subagent-dock&dark");diff --git a/webui/src/components/thread/SubagentTaskDock.tsx b/webui/src/components/thread/SubagentTaskDock.tsxindex b54b3fce2..e4beeace3 100644--- a/webui/src/components/thread/SubagentTaskDock.tsx+++ b/webui/src/components/thread/SubagentTaskDock.tsx@@ -210,8 +210,16 @@ function TaskTree({ tasks, maxHeight }: { tasks: ObservedSubagentTask[]; maxHeigreturn <div data-testid="subagent-task-tree" style={{ maxHeight }} className="min-h-0 overflow-y-auto overscroll-contain p-1.5 pt-0 scrollbar-thin"><ol className="space-y-0.5">{tasks.map(task => <li key={task.task_id} data-task-state={task.state}- className="rounded-lg transition-colors duration-150 hover:bg-muted/50 focus-within:bg-muted/50 motion-reduce:transition-none">- <div className="sticky top-0 z-20 flex min-w-0 items-center gap-0.5 bg-card">+ onClick={event => {+ const target = event.target;+ if (event.defaultPrevented || !(target instanceof Element) || !event.currentTarget.contains(target)+ || target.closest("button, a[href], input, textarea, select, summary, [role=button], [role=link], [contenteditable=true]")) return;+ const selection = window.getSelection();+ if (selection && !selection.isCollapsed && selection.containsNode(event.currentTarget, true)) return;+ context.open(task, event.currentTarget.querySelector<HTMLButtonElement>("[data-subagent-id]")!);+ }}+ className="cursor-pointer rounded-lg transition-colors duration-150 hover:bg-muted/50 focus-within:bg-muted/50 motion-reduce:transition-none">+ <div className="flex min-w-0 items-center gap-0.5"><SubagentTaskButton task={task} surface="activity" />{task.state === "queued" || task.state === "running" ? <HoverHint content={t("thread.subagents.stopTask", { label: task.label })}><Button type="button" variant="ghost" size="icon"diff --git a/webui/src/tests/subagent-tasks.test.tsx b/webui/src/tests/subagent-tasks.test.tsxindex b31bedd40..bfde04dc8 100644--- a/webui/src/tests/subagent-tasks.test.tsx+++ b/webui/src/tests/subagent-tasks.test.tsx@@ -432,10 +432,30 @@ describe("session-owned task UI", () => {expect(evidence).toHaveAttribute("rel", "noreferrer noopener");expect(within(tree).queryByRole("link", { name: "Unsafe link" })).not.toBeInTheDocument();expect(tree.querySelector("pre")?.textContent).toContain("const verified = true;");- await user.click(within(tree).getByRole("button", { name: /Config check Completed/ }));+ await user.click(within(tree).getByText("Final finding after the long result."));expect(await within(screen.getByRole("dialog", { name: "Config check" })).findByRole("link", { name: /Full evidence/ })).toHaveAttribute("href", "https://example.com/evidence");});+ it("opens the owning task from tool activity and error content", async () => {+ vi.mocked(fetch).mockImplementation(async () => response([+ task({ tool_events: [{ name: "read_file", status: "running" }] }),+ task({ task_id: "sibling", label: "Sibling check", created_at: 101, tool_events: [{ name: "exec", status: "running" }] }),+ ]));+ const user = userEvent.setup();+ render(layout());+ const tree = await openTaskList(user);+ await user.click(within(tree).getByText("exec"));+ expect(screen.getByRole("dialog", { name: "Sibling check" })).toBeVisible();+ await user.keyboard("{Escape}");+ await user.click(within(tree).getByText("read_file"));+ expect(screen.getByRole("dialog", { name: "Config check" })).toBeVisible();+ await user.keyboard("{Escape}");+ emitTask(task({ revision: 2, state: "error", error: "Cannot read configuration", completed_at: 102 }));+ await user.click(within(tree).getByText("Cannot read configuration"));+ expect(screen.getByRole("dialog", { name: "Config check" })).toBeVisible();+ expect(requestMutation).not.toHaveBeenCalled();+ });+it("keeps result-owned image portals inside the drawer interaction boundary", async () => {await preloadMarkdownText();const user = userEvent.setup();@@ -444,8 +464,8 @@ describe("session-owned task UI", () => {emitTask(task({ revision: 2, state: "done", completed_at: 102, result: "" }));await user.click(await within(tree).findByRole("button", { name: "View image: Result image" }));const viewer = screen.getByRole("dialog", { name: "Result image" });- fireEvent.pointerDown(within(viewer).getByRole("img", { name: "Result image" }));- expect(viewer).toBeInTheDocument();+ await user.click(within(viewer).getByRole("img", { name: "Result image" }));+ expect(screen.getAllByRole("dialog")).toEqual([viewer]);expect(screen.getByTestId("subagent-task-dock-trigger")).toHaveAttribute("aria-expanded", "true");await user.keyboard("{Escape}");expect(screen.queryByRole("dialog")).not.toBeInTheDocument();