feat(vom): canvas position calculation and projection

This commit is contained in:
Ljy-0827
2026-08-31 14:22:34 +08:00
parent d660da87f3
commit 22ca308342
30 changed files with 1433 additions and 33 deletions
@@ -499,6 +499,41 @@ describe("interaction tools", () => {
]);
});
it("interact.click forwards a complete Surface capture coordinate transaction", async () => {
const { tools, calls } = setup({
...responses,
click: {
tab_id: 7,
used_ref: "e1",
x: 110,
y: 70,
capture_id: "sc_test",
image_x: 200,
image_y: 100,
},
});
await startSession(tools);
const click = tools.get("interact.click");
const value = await click?.execute(
{ target: "@e1", captureId: "sc_test", imageX: 200, imageY: 100 },
makeExec(),
);
expect(value).toMatchObject({ captureId: "sc_test", x: 110, y: 70 });
expect(calls[1].args).toEqual([
"click",
"--session",
"s1",
"--capture",
"sc_test",
"--image-x",
"200",
"--image-y",
"100",
"@e1",
]);
});
it("interact.fill passes value and --no-clear", async () => {
const { tools, calls } = setup(responses);
await startSession(tools);
@@ -923,6 +958,32 @@ describe("inspect.screenshot", () => {
expect(rendered?.every((block) => block.type === "text")).toBe(true);
});
it("returns Surface capture metadata alongside the screenshot", async () => {
const path = pngFile();
const { tools } = setup({
"session start": START_REPLY("s1"),
screenshot: {
tab_id: 7,
width: 800,
height: 600,
format: "png",
path,
byte_size: 8,
capture: { id: "sc_test", expires_at: 1700000030000 },
},
});
await startSession(tools);
const screenshot = tools.get("browser_screenshot");
const value = await screenshot?.execute({ ref: "@e1" }, makeExec());
expect(value).toMatchObject({
captureId: "sc_test",
captureExpiresAt: 1700000030000,
});
const rendered = screenshot?.output.render({ session: "s1" }, value as never);
expect(rendered?.[0]).toMatchObject({ type: "text", text: expect.stringContaining("sc_test") });
});
it("commits the image through the attachment store on an image-capable route", async () => {
const path = pngFile();
const services = {