дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
claude-agent-acp now sends AskUserQuestion as an ACP form (a choice field per question, each followed by a text field for a typed answer), and OMP's ask tool sends the same shape. They were shown as a plain form with every question stacked above the composer, at up to half the window, which in a short Agents panel left the conversation no room to scroll. Such forms are now shown as the question card in the conversation, one question at a time with Previous/Next, option descriptions and previews; the answers are turned back into the form's values (picked options as the choice, typed text in its companion field; Skip declines). Other forms stay forms, and a long one waiting above the composer now leaves the conversation a share of the panel and scrolls within itself. Fixes #7359
86 рядки
2.6 KiB
TypeScript
86 рядки
2.6 KiB
TypeScript
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<HTMLElement>("[class*='_conversation_']")!;
|
|
const stream = conversation.querySelector<HTMLElement>("[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();
|
|
});
|