From fa908de43d4f6d429249c0d7f33a985b89063f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E8=B6=85=E8=B6=85=E8=B6=85=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E5=96=9C=E6=AC=A2=E4=BD=A0=E7=9A=84=E8=BE=BE=E5=A6=AE=E5=A8=85?= <176143450+My-Denia@users.noreply.github.com> Date: Sat, 31 Oct 2026 19:03:00 +0800 Subject: [PATCH 1/3] feat(editor): show the cursor size as a percentage --- .../ai-edition/CursorPane.levels.test.tsx | 15 ++++++++++++++- src/components/ai-edition/RightPanes.tsx | 15 ++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/components/ai-edition/CursorPane.levels.test.tsx b/src/components/ai-edition/CursorPane.levels.test.tsx index bc714e2f7b..7dd35bcc24 100644 --- a/src/components/ai-edition/CursorPane.levels.test.tsx +++ b/src/components/ai-edition/CursorPane.levels.test.tsx @@ -187,7 +187,20 @@ describe("CursorPane size", () => { it("is a slider from the default up to four times it", () => { renderWithCursor({ cursorSize: 4.5 }); const slider = screen.getByRole("slider", { name: "Size" }) as HTMLInputElement; - expect([slider.min, slider.max, slider.value]).toEqual(["1.5", "6", "4.5"]); + expect([slider.min, slider.max, slider.value]).toEqual(["150", "600", "450"]); + }); + + // #1436: the value is a scale, so the pixels it draws depend on the output size. + it("shows its value as a percentage, and stores the scale", () => { + renderWithCursor({ cursorSize: 4.5 }); + expect(screen.getByText("450%")).toBeTruthy(); + + const slider = screen.getByRole("slider", { name: "Size" }); + fireEvent.change(slider, { target: { value: "345" } }); + fireEvent.mouseUp(slider); + + expect(useProjectStore.getState().document?.legacyEditor).toMatchObject({ cursorSize: 3.45 }); + expect(screen.getByText("345%")).toBeTruthy(); }); }); diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsx index 1e0c674108..32cbcd1e81 100644 --- a/src/components/ai-edition/RightPanes.tsx +++ b/src/components/ai-edition/RightPanes.tsx @@ -3867,15 +3867,16 @@ export function CursorPane() { `SETTING_BOUNDS` keeps both ends sane. */} { - setLive({ cursor: { size: v } }); - if (isNativeCompositorActive()) setNativeParam("cursorSize", v); + setLive({ cursor: { size: v / 100 } }); + if (isNativeCompositorActive()) setNativeParam("cursorSize", v / 100); }} onCommit={() => void commit()} /> From 48b382caf72f71cbd0680790575b0dbafcf02bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E8=B6=85=E8=B6=85=E8=B6=85=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E5=96=9C=E6=AC=A2=E4=BD=A0=E7=9A=84=E8=BE=BE=E5=A6=AE=E5=A8=85?= <176143450+My-Denia@users.noreply.github.com> Date: Sat, 31 Oct 2026 19:32:23 +0800 Subject: [PATCH 2/3] test(editor): check the native preview gets the cursor scale --- .../ai-edition/CursorPane.levels.test.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/ai-edition/CursorPane.levels.test.tsx b/src/components/ai-edition/CursorPane.levels.test.tsx index 7dd35bcc24..f464c411a0 100644 --- a/src/components/ai-edition/CursorPane.levels.test.tsx +++ b/src/components/ai-edition/CursorPane.levels.test.tsx @@ -6,8 +6,18 @@ import { LOCALE_STORAGE_KEY } from "@/i18n/config"; import { assetSchema, clipSchema, createEmptyDocument } from "@/lib/ai-edition/schema"; import { useProjectStore } from "@/lib/ai-edition/store/projectStore"; import { type NativeCursorType, nativeBridgeClient } from "@/native"; +import { setCurrentNativeViewId } from "@/native/nativeCompositorStore"; import { CursorPane } from "./RightPanes"; +const compositor = vi.hoisted(() => ({ + setCompositorParam: vi.fn(async () => undefined), +})); + +vi.mock("@/native/compositorViewClient", async (importOriginal) => ({ + ...(await importOriginal()), + setCompositorParam: compositor.setCompositorParam, +})); + beforeEach(() => { const store = new Map([[LOCALE_STORAGE_KEY, "en"]]); Object.defineProperty(globalThis, "localStorage", { @@ -202,6 +212,18 @@ describe("CursorPane size", () => { expect(useProjectStore.getState().document?.legacyEditor).toMatchObject({ cursorSize: 3.45 }); expect(screen.getByText("345%")).toBeTruthy(); }); + + it("sends the native preview the scale, not the percentage", () => { + setCurrentNativeViewId(7); + try { + renderWithCursor({ cursorSize: 4.5 }); + fireEvent.change(screen.getByRole("slider", { name: "Size" }), { target: { value: "345" } }); + + expect(compositor.setCompositorParam).toHaveBeenCalledWith(7, "cursorSize", 3.45); + } finally { + setCurrentNativeViewId(null); + } + }); }); describe("CursorPane click impact", () => { From 0238badc62ecd3c6e313c0e6c820055916c41403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E8=B6=85=E8=B6=85=E8=B6=85=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E5=96=9C=E6=AC=A2=E4=BD=A0=E7=9A=84=E8=BE=BE=E5=A6=AE=E5=A8=85?= <176143450+My-Denia@users.noreply.github.com> Date: Sat, 31 Oct 2026 19:39:15 +0800 Subject: [PATCH 3/3] test(editor): assert the percentage never reaches the native preview --- src/components/ai-edition/CursorPane.levels.test.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ai-edition/CursorPane.levels.test.tsx b/src/components/ai-edition/CursorPane.levels.test.tsx index f464c411a0..480f1d8edb 100644 --- a/src/components/ai-edition/CursorPane.levels.test.tsx +++ b/src/components/ai-edition/CursorPane.levels.test.tsx @@ -220,6 +220,7 @@ describe("CursorPane size", () => { fireEvent.change(screen.getByRole("slider", { name: "Size" }), { target: { value: "345" } }); expect(compositor.setCompositorParam).toHaveBeenCalledWith(7, "cursorSize", 3.45); + expect(compositor.setCompositorParam).not.toHaveBeenCalledWith(7, "cursorSize", 345); } finally { setCurrentNativeViewId(null); }