Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 71f77cda23 fix(agents): keep a long agent form scrollable above the composer
An agent's form (ACP elicitation, which opencode uses for its questions)
had no height limit: a form with several fields grew past the session and
pushed its last choices, its buttons and the composer out of view, with
nothing to scroll. It now shares the pinned question card's layout: at
most half the window, scrolling within. The pinned card also shrinks when
the session is shorter than that, so the composer stays in view.

Fixes #6945
2026-11-30 17:58:08 +08:00
3 змінених файлів з 53 додано та 3 видалено

No files matched your search

+47
Переглянути файл
@@ -242,3 +242,50 @@ for (const theme of ["dark", "light"] as const) {
}
}
}
test("a long agent form scrolls above the composer instead of being cut off", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1000, height: 520 });
const fields = Array.from({ length: 5 }, (_, q) => ({
name: `q${q + 1}`,
title: `Question ${q + 1}`,
kind: "choice" as const,
required: true,
options: Array.from({ length: 4 }, (_, o) => ({ value: `a${o + 1}`, label: `Answer ${q + 1}.${o + 1}` })),
}));
await page.evaluate(
async ({ task, fields }) => {
const store = await import("/src/features/agents/store.ts");
store.useAgents.setState({
loaded: true,
tasks: new Map([[task.id, task]]),
entries: new Map([
[
task.id,
[{ type: "permission", id: 1, title: "Plan the change", options: [], chosen: null, form: { fields } }],
],
]),
});
store.openTaskInEditorLocation(task.id);
},
{ task, fields },
);
const card = page.getByRole("form", { name: "Plan the change" });
await expect(card).toBeVisible();
const composer = page.getByRole("textbox", { name: "Message", exact: true });
await expect(composer).toBeInViewport();
for (let q = 1; q <= 5; q++) {
const last = card.getByRole("radio", { name: `Answer ${q}.4` });
await last.scrollIntoViewIfNeeded();
const box = (await last.boundingBox())!;
const hit = await page.evaluate(
({ x, y }) => document.elementFromPoint(x, y)?.closest("label")?.textContent ?? null,
{ x: box.x + box.width / 2, y: box.y + box.height / 2 },
);
expect(hit).toContain(`Answer ${q}.4`);
await last.check();
}
const submit = card.getByRole("button", { name: "Submit", exact: true });
await submit.scrollIntoViewIfNeeded();
await expect(submit).toBeInViewport({ ratio: 1 });
await expect(submit).toBeEnabled();
});
+2 -1
Переглянути файл
@@ -1,4 +1,5 @@
import { useId, useState } from "react";
import clsx from "clsx";
import type { AgentForm, AgentFormField, AgentTask } from "@/bindings";
import { Button, Checkbox, Input, Radio, T } from "@/ui";
import type { PermissionEntry } from "./permission";
@@ -48,7 +49,7 @@ export function FormCard({ task, entry, form }: { task: AgentTask; entry: Permis
};
return (
<form
className={styles.questionCard}
className={clsx(styles.questionCard, styles.questionCardPinned)}
aria-label={entry.title}
onSubmit={(event) => {
event.preventDefault();
+4 -2
Переглянути файл
@@ -1632,9 +1632,11 @@
font-size: var(--agent-fs-ui, var(--fs-ui));
container: question-card / inline-size;
}
/* A question that outlived its turn waits above the composer, at the composer's width. */
/* A question that outlived its turn waits above the composer, at the composer's width. It scrolls within at most
half the window, and less when the session is shorter, so the composer and the card's buttons stay in view. */
.questionCardPinned {
flex: none;
flex: 0 1 auto;
min-height: 0;
max-height: 50vh;
overflow-y: auto;
width: 100%;