From 6c49ffbc2b7a235bc42f4de14cb68de10b30499b Mon Sep 17 00:00:00 2001 From: webadderall <131426131+webadderall@users.noreply.github.com> Date: Tue, 6 Oct 2026 13:14:24 +1100 Subject: [PATCH] Open capture picker only on explicit recording actions --- src/components/launch/LaunchWindow.tsx | 7 +------ tests/ui/capture-picker.spec.ts | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsx index 9121f641..505a6444 100644 --- a/src/components/launch/LaunchWindow.tsx +++ b/src/components/launch/LaunchWindow.tsx @@ -190,7 +190,6 @@ function LaunchWindowContent() { } }, [recording, countdownActive, finalizing, beginInteractiveHudAction, syncSelectedSource]); - const initialSourceChecked = useRef(false); useEffect(() => { let mounted = true; let selectionEventSeen = false; @@ -201,10 +200,6 @@ function LaunchWindowContent() { if (mounted) setSourceReady(true); if (mounted && !selectionEventSeen) { syncSelectedSource(source); - if (!initialSourceChecked.current) { - initialSourceChecked.current = true; - if (!source && !recording) void handlePickOnScreen(); - } } }) .catch(() => { @@ -223,7 +218,7 @@ function LaunchWindowContent() { mounted = false; cleanup?.(); }; - }, [syncSelectedSource, recording, handlePickOnScreen]); + }, [syncSelectedSource]); const openHome = () => { localStorage.setItem("recordly.open-dashboard", String(Date.now())); diff --git a/tests/ui/capture-picker.spec.ts b/tests/ui/capture-picker.spec.ts index f26ab845..4f9a8363 100644 --- a/tests/ui/capture-picker.spec.ts +++ b/tests/ui/capture-picker.spec.ts @@ -123,8 +123,12 @@ test("platforms without area capture keep drag selection on an existing screen", expect(await pick(page)).toMatchObject({ kind: "screen", record: false }); }); -for (const selected of [false, true]) { - test(`HUD ${selected ? "keeps the selected source and reopens on click" : "opens the picker once when no source exists"}`, async ({ +for (const { selected, trigger } of [ + { selected: false, trigger: "source" }, + { selected: false, trigger: "record" }, + { selected: true, trigger: "source" }, +]) { + test(`HUD ${selected ? "keeps the selected source" : "starts without a selected source"} and opens the picker only on ${trigger} click`, async ({ page, }) => { await installDesktopBridge(page); @@ -144,12 +148,16 @@ for (const selected of [false, true]) { }, selected); await page.goto("/?windowType=hud-overlay"); const control = page.getByRole("button", { name: "Choose recording source" }); - await expect(control).toBeVisible(); + await expect(control).toBeEnabled(); if (selected) { await expect(control).toContainText("Existing screen"); - await expect(page.locator("html")).not.toHaveAttribute("data-picker-calls"); - await control.click(); + } else { + await expect(control).toHaveText("Pick source"); } + await expect(page.locator("html")).not.toHaveAttribute("data-picker-calls"); + await (trigger === "source" + ? control + : page.getByRole("button", { name: "Record", exact: true })).click(); await expect(page.locator("html")).toHaveAttribute("data-picker-calls", "1"); await expect(control).toContainText("Selected window"); await expect(page.getByRole("button", { name: "Record", exact: true })).toBeVisible(); @@ -230,9 +238,12 @@ test("unselected source reads Pick source once and Record stays disabled while p }); }); await page.goto("/?windowType=hud-overlay"); - await expect(page.locator("html")).toHaveAttribute("data-picker-pending", "true"); const source = page.getByRole("button", { name: "Choose recording source" }); + await expect(source).toBeEnabled(); await expect(source).toHaveText("Pick source"); + await expect(page.locator("html")).not.toHaveAttribute("data-picker-pending"); + await source.click(); + await expect(page.locator("html")).toHaveAttribute("data-picker-pending", "true"); await expect(page.getByRole("button", { name: "Record", exact: true })).toBeDisabled(); await page.evaluate(() => (window as unknown as { finishPicker: () => void }).finishPicker()); await expect(page.getByRole("button", { name: "Record", exact: true })).toBeEnabled();