From 72544413e278c606be899ae6a76feb0b71963877 Mon Sep 17 00:00:00 2001 From: mahiro72 Date: Fri, 12 Dec 2025 19:59:26 +0900 Subject: [PATCH 01/10] fix; correcting the order of function calls --- playground/shared/src/ShareButton.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/playground/shared/src/ShareButton.tsx b/playground/shared/src/ShareButton.tsx index 65fdca5da7..05a461bd48 100644 --- a/playground/shared/src/ShareButton.tsx +++ b/playground/shared/src/ShareButton.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; import AstralButton from "./AstralButton"; -export default function ShareButton({ onShare }: { onShare: () => void }) { +export default function ShareButton({ onShare }: { onShare: () => Promise }) { const [copied, setCopied] = useState(false); useEffect(() => { @@ -29,9 +29,9 @@ export default function ShareButton({ onShare }: { onShare: () => void }) { type="button" className="relative flex-none leading-6 py-1.5 px-3 shadow-xs disabled:opacity-50" disabled={copied} - onClick={() => { + onClick={async () => { + await onShare(); setCopied(true); - onShare(); }} > Date: Fri, 12 Dec 2025 20:00:01 +0900 Subject: [PATCH 02/10] fix; function signatures --- playground/ruff/src/Editor/Chrome.tsx | 4 ++-- playground/shared/src/Header.tsx | 2 +- playground/ty/src/Playground.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/playground/ruff/src/Editor/Chrome.tsx b/playground/ruff/src/Editor/Chrome.tsx index 3fc9ddca2a..a86f4e589f 100644 --- a/playground/ruff/src/Editor/Chrome.tsx +++ b/playground/ruff/src/Editor/Chrome.tsx @@ -16,12 +16,12 @@ export default function Chrome() { const [theme, setTheme] = useTheme(); - const handleShare = useCallback(() => { + const handleShare = useCallback(async () => { if (settings == null || pythonSource == null) { return; } - persist(settings, pythonSource).catch((error) => + await persist(settings, pythonSource).catch((error) => // eslint-disable-next-line no-console console.error(`Failed to share playground: ${error}`), ); diff --git a/playground/shared/src/Header.tsx b/playground/shared/src/Header.tsx index 7881fb5344..5b80f256b3 100644 --- a/playground/shared/src/Header.tsx +++ b/playground/shared/src/Header.tsx @@ -21,7 +21,7 @@ export default function Header({ version: string | null; onChangeTheme: (theme: Theme) => void; onReset?(): void; - onShare: () => void; + onShare: () => Promise; }) { return (
{ + const handleShare = useCallback(async () => { const serialized = serializeFiles(files); if (serialized != null) { - persist(serialized).catch((error) => { + await persist(serialized).catch((error) => { // eslint-disable-next-line no-console console.error("Failed to share playground", error); }); From 8c9cf99c99a3a9da68337b0069869823a55e529c Mon Sep 17 00:00:00 2001 From: mahiro72 Date: Fri, 12 Dec 2025 20:33:43 +0900 Subject: [PATCH 04/10] fix; lint --- playground/shared/src/ShareButton.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/playground/shared/src/ShareButton.tsx b/playground/shared/src/ShareButton.tsx index 05a461bd48..c6bbeeb83e 100644 --- a/playground/shared/src/ShareButton.tsx +++ b/playground/shared/src/ShareButton.tsx @@ -1,7 +1,11 @@ import { useEffect, useState } from "react"; import AstralButton from "./AstralButton"; -export default function ShareButton({ onShare }: { onShare: () => Promise }) { +export default function ShareButton({ + onShare, +}: { + onShare: () => Promise; +}) { const [copied, setCopied] = useState(false); useEffect(() => { From 1da96d6bc235114ac4862ae23d561dff1b309d55 Mon Sep 17 00:00:00 2001 From: mahiro <70263039+mahiro72@users.noreply.github.com> Date: Wed, 17 Dec 2025 02:20:30 +0900 Subject: [PATCH 05/10] Update playground/ruff/src/Editor/Chrome.tsx Co-authored-by: Micha Reiser --- playground/ruff/src/Editor/Chrome.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/playground/ruff/src/Editor/Chrome.tsx b/playground/ruff/src/Editor/Chrome.tsx index a86f4e589f..559ffedd5b 100644 --- a/playground/ruff/src/Editor/Chrome.tsx +++ b/playground/ruff/src/Editor/Chrome.tsx @@ -21,10 +21,12 @@ export default function Chrome() { return; } - await persist(settings, pythonSource).catch((error) => - // eslint-disable-next-line no-console - console.error(`Failed to share playground: ${error}`), - ); + try { + await persist(serialized); + } catch (error) { + // eslint-disable-next-line no-console + console.error("Failed to share playground", error); + } }, [pythonSource, settings]); if (initPromise.current == null) { From dbde0e72a3893f5d634714af5202f0448cdab6a3 Mon Sep 17 00:00:00 2001 From: mahiro72 Date: Wed, 17 Dec 2025 02:22:41 +0900 Subject: [PATCH 06/10] fix; args and fmt --- playground/ruff/src/Editor/Chrome.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/ruff/src/Editor/Chrome.tsx b/playground/ruff/src/Editor/Chrome.tsx index 559ffedd5b..7c8cc9b4a0 100644 --- a/playground/ruff/src/Editor/Chrome.tsx +++ b/playground/ruff/src/Editor/Chrome.tsx @@ -22,7 +22,7 @@ export default function Chrome() { } try { - await persist(serialized); + await persist(settings, pythonSource); } catch (error) { // eslint-disable-next-line no-console console.error("Failed to share playground", error); From a5c81d7207d1496bf3e70b15fa39d46a4257208c Mon Sep 17 00:00:00 2001 From: mahiro72 Date: Wed, 17 Dec 2025 02:23:15 +0900 Subject: [PATCH 07/10] fix; args and fmt --- playground/ruff/src/Editor/Chrome.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/playground/ruff/src/Editor/Chrome.tsx b/playground/ruff/src/Editor/Chrome.tsx index 7c8cc9b4a0..1f4f94548f 100644 --- a/playground/ruff/src/Editor/Chrome.tsx +++ b/playground/ruff/src/Editor/Chrome.tsx @@ -21,12 +21,12 @@ export default function Chrome() { return; } - try { - await persist(settings, pythonSource); - } catch (error) { - // eslint-disable-next-line no-console - console.error("Failed to share playground", error); - } + try { + await persist(settings, pythonSource); + } catch (error) { + // eslint-disable-next-line no-console + console.error("Failed to share playground", error); + } }, [pythonSource, settings]); if (initPromise.current == null) { From 21fe750933cfa36b4ad5616f0572c28de0b7e8c6 Mon Sep 17 00:00:00 2001 From: mahiro72 Date: Wed, 17 Dec 2025 02:46:01 +0900 Subject: [PATCH 08/10] refactor; add share status state --- playground/shared/src/ShareButton.tsx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/playground/shared/src/ShareButton.tsx b/playground/shared/src/ShareButton.tsx index c6bbeeb83e..a79ab4d0a3 100644 --- a/playground/shared/src/ShareButton.tsx +++ b/playground/shared/src/ShareButton.tsx @@ -1,21 +1,23 @@ import { useEffect, useState } from "react"; import AstralButton from "./AstralButton"; +type ShareStatus = "initial" | "copying" | "copied"; + export default function ShareButton({ onShare, }: { onShare: () => Promise; }) { - const [copied, setCopied] = useState(false); + const [status, setStatus] = useState("initial"); useEffect(() => { - if (copied) { - const timeout = setTimeout(() => setCopied(false), 2000); + if (status === "copied") { + const timeout = setTimeout(() => setStatus("initial"), 2000); return () => clearTimeout(timeout); } - }, [copied]); + }, [status]); - return copied ? ( + return status === "copied" ? ( { - await onShare(); - setCopied(true); + setStatus("copying"); + try { + await onShare(); + setStatus("copied"); + } catch (error) { + // eslint-disable-next-line no-console + console.error("Failed to share playground", error); + setStatus("initial"); + } }} > Date: Wed, 17 Dec 2025 02:47:59 +0900 Subject: [PATCH 09/10] del; try in handleshare --- playground/ruff/src/Editor/Chrome.tsx | 8 +------- playground/ty/src/Playground.tsx | 5 +---- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/playground/ruff/src/Editor/Chrome.tsx b/playground/ruff/src/Editor/Chrome.tsx index 1f4f94548f..be744f2412 100644 --- a/playground/ruff/src/Editor/Chrome.tsx +++ b/playground/ruff/src/Editor/Chrome.tsx @@ -20,13 +20,7 @@ export default function Chrome() { if (settings == null || pythonSource == null) { return; } - - try { - await persist(settings, pythonSource); - } catch (error) { - // eslint-disable-next-line no-console - console.error("Failed to share playground", error); - } + await persist(settings, pythonSource); }, [pythonSource, settings]); if (initPromise.current == null) { diff --git a/playground/ty/src/Playground.tsx b/playground/ty/src/Playground.tsx index fcb8627ab6..a04fe282ca 100644 --- a/playground/ty/src/Playground.tsx +++ b/playground/ty/src/Playground.tsx @@ -52,10 +52,7 @@ export default function Playground() { const serialized = serializeFiles(files); if (serialized != null) { - await persist(serialized).catch((error) => { - // eslint-disable-next-line no-console - console.error("Failed to share playground", error); - }); + await persist(serialized) } }, [files]); From a46b568746bbb68b41a8251d6a3bc6efaa233e84 Mon Sep 17 00:00:00 2001 From: mahiro72 Date: Wed, 17 Dec 2025 03:12:33 +0900 Subject: [PATCH 10/10] fix; lint --- playground/ty/src/Playground.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/ty/src/Playground.tsx b/playground/ty/src/Playground.tsx index a04fe282ca..1b66cba7cf 100644 --- a/playground/ty/src/Playground.tsx +++ b/playground/ty/src/Playground.tsx @@ -52,7 +52,7 @@ export default function Playground() { const serialized = serializeFiles(files); if (serialized != null) { - await persist(serialized) + await persist(serialized); } }, [files]);