From c1df8274c27fba40f568e61d4e540da89da4906e Mon Sep 17 00:00:00 2001 From: Stephan Terning Date: Mon, 16 Nov 2026 22:00:52 +0100 Subject: [PATCH 1/2] Fix iOS viewport overlap and preview playback --- app/components/editing.tsx | 25 +++++++++++++++++++++---- app/components/workspace-player.tsx | 2 ++ app/style.css | 26 ++++++++++++++++++++------ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/app/components/editing.tsx b/app/components/editing.tsx index 392fdee..6259a00 100644 --- a/app/components/editing.tsx +++ b/app/components/editing.tsx @@ -10,6 +10,7 @@ import { useBlocker, useFetcher, type FormProps } from "react-router"; import { ConfirmDialog } from "./confirm-dialog"; import { IconButton } from "./icon-button"; import { Modal } from "./modal"; +import { useWorkspacePlayback } from "./workspace-player"; const DialogActions = createContext<{ cancel: () => void; @@ -240,11 +241,25 @@ export function PreviewLink({ label?: string; }) { const editors = useContext(Editing); + const workspace = useWorkspacePlayback(); const trigger = useRef(null); const [labels, setLabels] = useState(null); const [busy, setBusy] = useState(false); const [error, setError] = useState(""); - const open = () => window.open(href, "_blank", "noopener,noreferrer"); + const pauseDemoForPreview = () => { + // iOS can present the new tab over the installed app, leaving it playing. + if ( + window.matchMedia("(display-mode: standalone)").matches || + (navigator as Navigator & { standalone?: boolean }).standalone + ) { + workspace?.getSnapshot().playback?.pause(); + } + }; + const open = (preview?: Window | null) => { + pauseDemoForPreview(); + if (preview) preview.location.replace(href); + else window.open(href, "_blank", "noopener,noreferrer"); + }; const close = () => { if (!busy) setLabels(null); }; @@ -264,7 +279,10 @@ export function PreviewLink({ const dirty = [...(editors?.values() || [])].filter((editor) => editor.dirty(), ); - if (!dirty.length) return; + if (!dirty.length) { + pauseDemoForPreview(); + return; + } event.preventDefault(); setLabels(dirty.map((editor) => editor.label)); setError(""); @@ -320,8 +338,7 @@ export function PreviewLink({ return; } } - if (preview) preview.location.replace(href); - else open(); + open(preview); setLabels(null); } finally { setBusy(false); diff --git a/app/components/workspace-player.tsx b/app/components/workspace-player.tsx index 2a5fe3c..cf1c638 100644 --- a/app/components/workspace-player.tsx +++ b/app/components/workspace-player.tsx @@ -31,8 +31,10 @@ export function WorkspacePlayerProvider({ children }: { children: ReactNode }) { useEffect(() => { const clearCache = attachAudioCacheSession(); window.addEventListener("wavecase-access-revoked", workspace.dispose); + window.addEventListener("pagehide", workspace.dispose); return () => { window.removeEventListener("wavecase-access-revoked", workspace.dispose); + window.removeEventListener("pagehide", workspace.dispose); workspace.dispose(); clearCache(); }; diff --git a/app/style.css b/app/style.css index 5c9f1b3..e212298 100644 --- a/app/style.css +++ b/app/style.css @@ -43,6 +43,10 @@ --space-6: 32px; --space-7: 48px; --page-gutter: clamp(18px, 4vw, 72px); + --page-inset-top: env(safe-area-inset-top, 0px); + --page-inset-bottom: env(safe-area-inset-bottom, 0px); + scroll-padding-top: var(--page-inset-top); + scroll-padding-bottom: var(--page-inset-bottom); color-scheme: dark; font: var(--text-md) / var(--leading-normal) system-ui, @@ -50,6 +54,15 @@ color: var(--color-text); background: var(--color-bg); } +@supports (-webkit-touch-callout: none) { + @media (display-mode: browser) and (max-width: 600px) and (orientation: portrait) and (pointer: coarse) { + :root { + /* In-app Safari can draw its floating toolbars inside the reported viewport. */ + --page-inset-top: max(32px, env(safe-area-inset-top, 0px)); + --page-inset-bottom: max(64px, env(safe-area-inset-bottom, 0px)); + } + } +} * { box-sizing: border-box; } @@ -57,6 +70,7 @@ body { margin: 0; min-height: 100vh; min-height: 100dvh; + padding-block: var(--page-inset-top) var(--page-inset-bottom); display: flex; flex-direction: column; } @@ -537,10 +551,10 @@ button:hover:not(:disabled), /* Released music has its own artwork-led public presentation. */ :root:has(.release-mini) { - scroll-padding-bottom: calc(150px + env(safe-area-inset-bottom)); + scroll-padding-bottom: calc(150px + var(--page-inset-bottom)); } body:has(.release-mini) { - padding-bottom: calc(150px + env(safe-area-inset-bottom)); + padding-bottom: calc(150px + var(--page-inset-bottom)); } .release-mini { position: fixed; @@ -553,7 +567,7 @@ body:has(.release-mini) { flex-wrap: wrap; gap: var(--space-3); padding: var(--space-3) var(--page-gutter); - padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom)); + padding-bottom: calc(var(--space-3) + var(--page-inset-bottom)); background: var(--color-surface); border-top: 1px solid var(--color-border-control); box-shadow: 0 -8px 30px #0005; @@ -1054,8 +1068,8 @@ main:has(.workspace) { color: inherit; border: 0; border-right: 1px solid var(--color-border); - padding: max(var(--space-4), env(safe-area-inset-top)) var(--space-4) - max(var(--space-4), env(safe-area-inset-bottom)); + padding: calc(var(--space-4) + var(--page-inset-top)) var(--space-4) + calc(var(--space-4) + var(--page-inset-bottom)); overscroll-behavior: contain; } body:has(.workspace-drawer[open]) { @@ -1154,7 +1168,7 @@ body:has(.workspace-drawer[open]) { .account-menu { position: absolute; - inset: 78px var(--page-gutter) auto auto; + inset: calc(78px + var(--page-inset-top)) var(--page-gutter) auto auto; margin: 0; min-width: 180px; padding: var(--space-2); From 53a08908d6b8f2b10d943422cd99da5808f68811 Mon Sep 17 00:00:00 2001 From: Stephan Terning Date: Mon, 16 Nov 2026 23:08:27 +0100 Subject: [PATCH 2/2] Pause demos on preview launch in every browser --- app/components/editing.tsx | 9 ++------- app/style.css | 9 --------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/app/components/editing.tsx b/app/components/editing.tsx index 6259a00..8a01a24 100644 --- a/app/components/editing.tsx +++ b/app/components/editing.tsx @@ -247,13 +247,8 @@ export function PreviewLink({ const [busy, setBusy] = useState(false); const [error, setError] = useState(""); const pauseDemoForPreview = () => { - // iOS can present the new tab over the installed app, leaving it playing. - if ( - window.matchMedia("(display-mode: standalone)").matches || - (navigator as Navigator & { standalone?: boolean }).standalone - ) { - workspace?.getSnapshot().playback?.pause(); - } + // A preview can open in a separate web view, leaving the workspace mounted. + workspace?.getSnapshot().playback?.pause(); }; const open = (preview?: Window | null) => { pauseDemoForPreview(); diff --git a/app/style.css b/app/style.css index e212298..6c0507d 100644 --- a/app/style.css +++ b/app/style.css @@ -54,15 +54,6 @@ color: var(--color-text); background: var(--color-bg); } -@supports (-webkit-touch-callout: none) { - @media (display-mode: browser) and (max-width: 600px) and (orientation: portrait) and (pointer: coarse) { - :root { - /* In-app Safari can draw its floating toolbars inside the reported viewport. */ - --page-inset-top: max(32px, env(safe-area-inset-top, 0px)); - --page-inset-bottom: max(64px, env(safe-area-inset-bottom, 0px)); - } - } -} * { box-sizing: border-box; }