From a7ca0e0efb062c4e3d5a3c71e023eb8dc488d570 Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 25 Nov 2026 11:03:06 +0800 Subject: [PATCH] [fix] canvas: leave the example dialog once the import finishes Importing an example ended with the dialog still on screen, every entry marked done, and the newly created project waiting behind it. The import had already opened the example, so the only thing left to do in that dialog was to close it by hand. The dialog now closes itself half a second after an import reports done, which is long enough to read the completion line. The close callback is held in a ref so a parent re-render does not restart the timer, and the timer is cleared on unmount and when the done state goes away. --- src/canvas/workspace/example/ExampleCanvasDialog.tsx | 10 ++++++++++ tests/browser/example_canvas_picker.mjs | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/canvas/workspace/example/ExampleCanvasDialog.tsx b/src/canvas/workspace/example/ExampleCanvasDialog.tsx index 3293fcf24..45666ace5 100644 --- a/src/canvas/workspace/example/ExampleCanvasDialog.tsx +++ b/src/canvas/workspace/example/ExampleCanvasDialog.tsx @@ -36,6 +36,16 @@ export function ExampleCanvasDialog({ }, []); const busy = entries.some((entry) => isRunning(entry.id)); + // A finished import already opened the example, so the dialog leaves on its + // own: keeping it up asked for a second click to reach what was just made. + const done = entries.some((entry) => statuses[entry.id]?.phase === "done"); + const closeRef = useRef(onClose); + closeRef.current = onClose; + useEffect(() => { + if (!done) return; + const timer = window.setTimeout(() => closeRef.current(), 600); + return () => window.clearTimeout(timer); + }, [done]); return ( document.querySelectorAll(".react-flow__node").length === 2); // 3. A page instead of an archive is reported inline, and nothing is imported. await page.unroute(samplePattern);