Skip to content

Your lightweight open-source personal agent.

fix(webui): keep subtask details reachable in long results

chengyongru23c4acc21609
diff --git a/webui/browser/subagent-dock-fixture.tsx b/webui/browser/subagent-dock-fixture.tsx
index 5a90d0895..941c12f69 100644
--- a/webui/browser/subagent-dock-fixture.tsx
+++ b/webui/browser/subagent-dock-fixture.tsx
@@ -96,8 +96,8 @@ export function SubagentDockFixture({ parameters }: { parameters: URLSearchParam
state: "done", phase: "done", tool_events: [], completed_at: Date.now() / 1000,
result: index === 0 && parameters.has("image-result") ? "## Image result\n\n![Result image](https://example.com/dock-result.svg)"
: index === 0 && parameters.has("markdown-result")
- ? "## 天气结果\n\n**北京**:约 **10°C**,有小雨。\n\n" + "这是完整的多行查询结果,保留原始段落、文字样式和详细说明,阅读时可以滚动任务列表。".repeat(30)
- + "\n\n- **南京**:约 18°C,有雾。\n- **天津**:约 12°C,多云。\n\n[天气来源](https://example.com/weather)\n\n```text\nchecked_at: 2026-10-25T20:52:00+08:00\n```\n\n最后一条完整结论:以上结果均可继续核对。"
+ ? "## 天气结果\n\n**北京**:约 **10°C**,有小雨。\n\n```text\nchecked_at: 2026-10-25T20:52:00+08:00\n```\n\n" + "这是完整的多行查询结果,保留原始段落、文字样式和详细说明,阅读时可以滚动任务列表。".repeat(30)
+ + "\n\n- **南京**:约 18°C,有雾。\n- **天津**:约 12°C,多云。\n\n[天气来源](https://example.com/weather)\n\n最后一条完整结论:以上结果均可继续核对。"
: ["已核对面板的位置与滚动边界。", "定向检查已完成,保留详情与单任务停止。", "建议让任务入口始终留在输入区附近。"][index % 3],
});
});
diff --git a/webui/browser/subagent-dock.spec.ts b/webui/browser/subagent-dock.spec.ts
index 76826c842..3ba463230 100644
--- a/webui/browser/subagent-dock.spec.ts
+++ b/webui/browser/subagent-dock.spec.ts
@@ -138,6 +138,18 @@ 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; });
const beforeScroll = await messages.evaluate(node => node.scrollTop);
const tail = tree.getByText("最后一条完整结论:以上结果均可继续核对。", { exact: true });
await tail.scrollIntoViewIfNeeded();
@@ -146,6 +158,15 @@ 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();
+ expect(await page.evaluate(() => window.getSelection()?.toString())).toBeTruthy();
+ 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");
@@ -166,6 +187,13 @@ for (const width of [1440, 390]) {
await title.locator("..").screenshot({ path: info.outputPath("completed-detail-header.png") });
await page.keyboard.press("Escape");
await expect(row).toBeFocused();
+ expect(await tree.evaluate(node => node.scrollTop)).toBeCloseTo(readingPosition, 0);
+ await expect(tail).toBeInViewport();
+ const nextRow = tree.locator('[data-subagent-id="preview-1"]');
+ await nextRow.scrollIntoViewIfNeeded();
+ await expect(nextRow).toBeInViewport();
+ await nextRow.click();
+ await expect(page.getByRole("dialog", { name: "核对回归测试", exact: true })).toBeVisible();
});
}
diff --git a/webui/src/components/thread/SubagentTaskDock.tsx b/webui/src/components/thread/SubagentTaskDock.tsx
index 587bc7662..b54b3fce2 100644
--- a/webui/src/components/thread/SubagentTaskDock.tsx
+++ b/webui/src/components/thread/SubagentTaskDock.tsx
@@ -211,7 +211,7 @@ function TaskTree({ tasks, maxHeight }: { tasks: ObservedSubagentTask[]; maxHeig
<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="flex min-w-0 items-center gap-0.5">
+ <div className="sticky top-0 z-20 flex min-w-0 items-center gap-0.5 bg-card">
<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"