import type { AgentEntry, AgentTask } from "../src/bindings"; import { expect, test } from "./fixtures"; const task: AgentTask = { id: "form-height", title: "Form", provider: "cursor", status: "needsInput", isolation: "local", model: null, cwd: "/dev/acme-api", branch: null, base: null, baseCommit: null, error: null, createdMs: 0, updatedMs: 0, config: [], commands: [], usage: null, queue: [], }; const field = (i: number) => ({ name: `field_${i}`, title: `Field ${i}`, description: "Something the agent needs to know before it goes on.", required: false, kind: "text" as const, options: [], default: [], min: null, max: null, }); const form: AgentEntry = { type: "permission", id: 1, title: "Fill in the details", command: null, options: [{ id: "decline", name: "Decline", kind: "reject_once" }], questions: [], form: { fields: Array.from({ length: 12 }, (_, i) => field(i)) }, chosen: null, }; // #7359: a long form waiting above the composer scrolls within itself and leaves the // conversation part of a short session, instead of half the window. test("a long pinned form leaves room for the conversation", async ({ workbench: page }) => { await page.setViewportSize({ width: 1100, height: 560 }); await page.evaluate( async ({ task, form }) => { const storePath = "/src/features/agents/store.ts"; const store = await import(/* @vite-ignore */ storePath); const entries: AgentEntry[] = [ { type: "user", text: "Set up the project.", attachments: [] }, { type: "agent", text: "I need a few details first." }, form, ]; store.useAgents.setState({ loaded: true, error: null, tasks: new Map([[task.id, task]]), entries: new Map([[task.id, entries]]), sessionLocation: "editor", }); store.openTask(task.id); }, { task, form }, ); const card = page.getByRole("form", { name: "Fill in the details" }); await expect(card).toBeVisible(); const sizes = await card.evaluate((el) => { const conversation = el.closest("[class*='_conversation_']")!; const stream = conversation.querySelector("[class*='_streamArea_']")!; return { conversation: conversation.getBoundingClientRect().height, stream: stream.getBoundingClientRect().height, scrolls: el.scrollHeight > el.clientHeight, }; }); expect(sizes.stream).toBeGreaterThanOrEqual(Math.min(sizes.conversation * 0.35, 200) - 1); expect(sizes.scrolls).toBe(true); await expect(card.getByRole("button", { name: "Submit" })).toBeAttached(); });