Files
openidea/e2e/agentComposerClick.spec.ts
T
Mr0Bread 39f34ec22f fix(agents): clicking the bottom of the message box puts the caret in it (#3450)
The composer's 44 px minimum height sat on CodeMirror's scroller, while the text inside stopped at 32 px (its min-height: 100% doesn't resolve against a min-height parent), so a click in the strip below focused the bare scroller and showed no caret. The minimum height now sits on .cm-content.

Co-authored-by: Mr0Bread <55754540+Mr0Bread@users.noreply.github.com>
2026-11-15 04:05:07 +08:00

70 lines
2.4 KiB
TypeScript

import type { Page } from "@playwright/test";
import type { AgentTask } from "../src/bindings";
import { expect, test } from "./fixtures";
const task: AgentTask = {
id: "composer-click",
title: "Composer click task",
provider: "codex",
status: "ready",
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: [],
};
async function openTask(page: Page) {
await page.evaluate(async (task) => {
// These modules must load in the browser's Vite realm, not Playwright's Node process.
const storePath = "/src/features/agents/store.ts";
const ipcPath = "/src/platform/ipc.ts";
const store = await import(storePath);
const { commands } = await import(ipcPath);
commands.agentChanges = async () => ({ status: "ok", data: [] });
store.useAgents.setState({
loaded: true,
error: null,
providers: [],
tasks: new Map([[task.id, task]]),
entries: new Map([[task.id, [{ type: "agent", text: "Reply" }]]]),
composers: new Map(),
unread: new Set(),
docked: null,
homeOpen: false,
sessionLocation: "editor",
});
store.openTask(task.id);
}, task);
}
// Every row of the text area, down to the toolbar row, puts the caret in the message.
test("clicking anywhere in the composer's text area focuses the message", async ({ workbench: page }) => {
await openTask(page);
const box = page.getByRole("textbox", { name: "Message", exact: true }).filter({ visible: true });
await expect(box).toBeVisible();
const composer = page.locator("[class*='_composer_']:visible").filter({ has: box });
const bar = composer.locator("[class*='_bar_']");
const frame = (await composer.boundingBox())!;
const barTop = (await bar.boundingBox())!.y;
const history = page.locator("[class*='_stream_']:visible");
const missed: number[] = [];
for (let y = Math.ceil(frame.y) + 1; y < barTop; y++) {
await history.click({ position: { x: 12, y: 12 } });
await expect(box).not.toBeFocused();
await page.mouse.click(frame.x + frame.width / 2, y);
if (!(await box.evaluate((element) => element === document.activeElement))) missed.push(y - frame.y);
}
expect(missed).toEqual([]);
await page.keyboard.type("typed");
await expect(box).toHaveText("typed");
});