diff --git a/e2e/agentMarkdown.spec.ts b/e2e/agentMarkdown.spec.ts index cd09673a45..eac8f4f84e 100644 --- a/e2e/agentMarkdown.spec.ts +++ b/e2e/agentMarkdown.spec.ts @@ -413,8 +413,7 @@ test("keeps chat history readable and selections free of timestamps and status l expect(selected).not.toMatch(/AM|PM|5s|Reasoning|Requesting task context/); await page.keyboard.press("ControlOrMeta+c"); expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(selected); - // The finished turn's reasoning is folded with its work. - await stream.locator("[class*='_turnFold_'] > summary").click(); + // The latest turn stays open: its reasoning shows as its own collapsed row. await stream.locator("[class*='_thought_'] > summary").click(); await expect(stream.locator("[class*='_thoughtPreview_']")).toHaveText("Requesting task context"); await expect(stream.locator("[class*='_thoughtBody_'] strong")).toHaveText("Requesting task context"); @@ -795,8 +794,7 @@ test("Find in Conversation skips user-select:none summaries and closed
}, TASK); const stream = page.locator("[class*='_stream_']:visible"); - const runSummary = stream.locator("details[class*='_processRun_'] > summary"); - await runSummary.click(); + // A command is its own row, outside the reasoning's run. await expect(stream.getByText("stop_bash")).toBeVisible(); await stream.focus(); @@ -894,13 +892,14 @@ test("indents process-run thoughts and tool calls clearly and aligns output-less entries: new Map([ [ task.id, + // Reasoning and read-only calls group into one run; commands and edits would be rows of their own. [ { type: "thought", text: "**Checking CI Status**\n\nInspecting workflow runs." }, { type: "tool", id: "t1", title: "gh pr checks 3631 --repo l0ng-ai/openidea", - kind: "execute", + kind: "fetch", status: "completed", locations: [], output: "All checks pending", @@ -911,7 +910,7 @@ test("indents process-run thoughts and tool calls clearly and aligns output-less type: "tool", id: "t2", title: "read_bash", - kind: "other", + kind: "read", status: "completed", locations: [], output: "E2E pass", @@ -921,7 +920,7 @@ test("indents process-run thoughts and tool calls clearly and aligns output-less type: "tool", id: "t3", title: "read_bash", - kind: "other", + kind: "read", status: "running", locations: [], output: "", diff --git a/e2e/agentScroll.spec.ts b/e2e/agentScroll.spec.ts index aa2929ef5c..0ce3fca63f 100644 --- a/e2e/agentScroll.spec.ts +++ b/e2e/agentScroll.spec.ts @@ -40,13 +40,17 @@ const entries: AgentEntry[] = Array.from({ length: 80 }, (_, turn): AgentEntry[] }, ]).flat(); -async function openHistory(page: Page) { +/** Opens the 80-turn chat; `foldTurns` folds each earlier turn's work into one row. */ +async function openHistory(page: Page, foldTurns = false) { await page.goto("/"); await page.getByRole("tree", { name: "Project" }).waitFor(); await page.evaluate( - async ({ task, entries }) => { + async ({ task, entries, foldTurns }) => { const path = "/src/features/agents/store.ts"; + const projectPath = "/src/platform/project.ts"; const store = await import(path); + const { useProject } = await import(projectPath); + useProject.setState({ settings: { agents: { foldTurns } } }); store.useAgents.setState({ loaded: true, error: null, @@ -58,10 +62,12 @@ async function openHistory(page: Page) { }); store.openTaskInEditorLocation(task.id); }, - { task, entries }, + { task, entries, foldTurns }, ); const stream = page.locator("[class*='_stream_']:visible"); - await expect(stream.locator(":scope > *")).toHaveCount(80 * 3); + // A turn shows its request, the read and the reasoning runs, the command, the edit and the reply; + // folded, its work is one row. The latest turn stays open. + await expect(stream.locator(":scope > *")).toHaveCount(foldTurns ? 79 * 3 + 6 : 80 * 6); await page.evaluate(() => document.fonts.ready); return stream; } @@ -85,7 +91,7 @@ for (const placement of ["editor", "toolWindow"] as const) { ); // The working indicator ends the conversation, after its rows; the turn ends with a reply. await expect(stream.getByRole("status").getByText("Writing…", { exact: true })).toBeVisible(); - await expect(stream.locator(":scope > *")).toHaveCount(80 * 3 + 1); + await expect(stream.locator(":scope > *")).toHaveCount(80 * 6 + 1); await expect.poll(() => stream.evaluate((el) => el.scrollHeight - el.clientHeight - el.scrollTop)).toBeLessThan(2); const timer = await page.evaluate(async (id) => { const path = "/src/features/agents/store.ts"; @@ -186,7 +192,7 @@ for (const selected of [false, true]) { } test("opens a folded turn with the keyboard and jumps back to the latest reply", async ({ page }) => { - const stream = await openHistory(page); + const stream = await openHistory(page, true); await stream.evaluate((el) => { el.scrollTop = 0; }); @@ -197,9 +203,8 @@ test("opens a folded turn with the keyboard and jumps back to the latest reply", await summary.focus(); await page.keyboard.press("Enter"); await expect(fold).toHaveAttribute("open", ""); - const run = fold.locator("[class*='_processRun_']").first(); - await expect(run).toBeVisible(); - await run.locator(":scope > summary").click(); + // A folded turn lists its work without nesting runs. + await expect(fold.locator("[class*='_processRun_']")).toHaveCount(0); await expect(fold.getByText("read src/module-0.ts", { exact: true })).toBeVisible(); await summary.focus(); await page.keyboard.press("Space"); diff --git a/src/features/agents/session/Stream.tsx b/src/features/agents/session/Stream.tsx index e09a16f2ef..a90ad7a411 100644 --- a/src/features/agents/session/Stream.tsx +++ b/src/features/agents/session/Stream.tsx @@ -132,6 +132,14 @@ function useOffscreenRows( mark(); const rows = new MutationObserver(mark); rows.observe(el, { childList: true }); + // Earlier rows load in front of the first one shown, which then loses its author header while + // it may be off-screen: lay it out again, or it keeps the height it had with the header. + const authors = new MutationObserver((records) => { + for (const { target } of records) + if (target.parentNode === el) (target as Element).removeAttribute("data-measured"); + mark(); + }); + authors.observe(el, { subtree: true, attributes: true, attributeFilter: ["data-author"] }); const resize = new ResizeObserver(() => { window.clearTimeout(timer); timer = window.setTimeout(() => { @@ -144,6 +152,7 @@ function useOffscreenRows( cancelAnimationFrame(frame); window.clearTimeout(timer); rows.disconnect(); + authors.disconnect(); resize.disconnect(); }; }, [ref, visible, enabled, fitWindowWidth, fontZoom]);