diff --git a/packages/app/e2e/mobile/sidebar-system-insets/toast-dismissal.mjs b/packages/app/e2e/mobile/sidebar-system-insets/toast-dismissal.mjs new file mode 100644 index 000000000..bc7914cdf --- /dev/null +++ b/packages/app/e2e/mobile/sidebar-system-insets/toast-dismissal.mjs @@ -0,0 +1,83 @@ +// Record a sidebar toast through timeout on the 2560×1600 Android tablet. +// Pass a vertical sample line through the card's plain interior, away from text, +// icons, and Android's clipboard preview, plus the visible-to-dismissed interval: +// node .../toast-dismissal.mjs recording.mp4 sample-x start-seconds end-seconds +// This checks actual native frames; a browser layout test misses this regression. +import assert from "node:assert/strict"; +import { execFileSync } from "node:child_process"; + +const [, , recording, sampleX, start, end] = process.argv; +assert(recording && sampleX && start && end, "Pass recording, sample x, start and end seconds"); +const { frames } = JSON.parse( + execFileSync( + "ffprobe", + [ + "-v", + "error", + "-select_streams", + "v", + "-show_entries", + "frame=best_effort_timestamp_time", + "-of", + "json", + recording, + ], + { encoding: "utf8" }, + ), +); +const selectedFrames = frames + .map((frame, index) => ({ time: Number(frame.best_effort_timestamp_time), index })) + .filter(({ time }) => time >= Number(start) && time <= Number(end)); +assert(selectedFrames.length > 2, "Capture at least three frames in the supplied interval"); +const firstFrame = selectedFrames[0].index; +const endFrame = selectedFrames.at(-1).index + 1; +const bytesPerFrame = 800; +// Bound both output and buffer to the requested frames, even for a long recording. +const pixels = execFileSync( + "ffmpeg", + [ + "-v", + "fatal", + "-i", + recording, + "-vf", + `trim=start_frame=${firstFrame}:end_frame=${endFrame},crop=2:400:${Number(sampleX)}:1100,format=gray`, + "-fps_mode", + "passthrough", + "-f", + "rawvideo", + "-", + ], + { maxBuffer: selectedFrames.length * bytesPerFrame + 1024 }, +); +assert.equal( + pixels.length, + selectedFrames.length * bytesPerFrame, + "Every selected frame must be decoded", +); +const positions = []; +let disappeared = false; +for (const [index, { time }] of selectedFrames.entries()) { + const column = pixels.subarray(index * bytesPerFrame, (index + 1) * bytesPerFrame); + const runs = []; + let run = []; + for (let y = 0; y < 400; y++) { + if (column[y * 2] > 250) run.push(y); + else { + if (run.length > 40) runs.push(run); + run = []; + } + } + if (run.length > 40) runs.push(run); + runs.sort((a, b) => b.length - a.length); + if (runs.length) { + const card = runs[0]; + positions.push({ time, centre: 1100 + (card[0] + card.at(-1)) / 2 }); + } else if (positions.length) disappeared = true; +} +assert(positions.length > 2, "Capture at least three visible card frames"); +assert(disappeared, "Recording must include the card disappearing"); +const centres = positions.map(({ centre }) => centre); +const shift = Math.max(...centres) - Math.min(...centres); +console.log(JSON.stringify({ positions, maximumShiftPixels: shift }, null, 2)); +assert(shift <= 2, `Toast moved ${shift}px during dismissal`); diff --git a/packages/app/src/components/sidebar-workspace-list.tsx b/packages/app/src/components/sidebar-workspace-list.tsx index bf6a06093..4c4c1575f 100644 --- a/packages/app/src/components/sidebar-workspace-list.tsx +++ b/packages/app/src/components/sidebar-workspace-list.tsx @@ -2592,7 +2592,9 @@ const styles = StyleSheet.create((theme) => ({ // Optical inset: aligns the visible Pinned/Workspaces glyph edge with the // Schedules icon across the divider; their layout boxes have different insets. paddingTop: 2, - paddingBottom: theme.spacing[4], + // Keep the last row scrollable above the sidebar toast, including a wrapped Undo row. + // This space stays present across toast changes so the scroll range never jumps. + paddingBottom: theme.spacing[24], }, projectListContainer: { width: "100%", diff --git a/packages/app/src/components/sidebar/sidebar-status-list.tsx b/packages/app/src/components/sidebar/sidebar-status-list.tsx index ecbf367d9..b271157d0 100644 --- a/packages/app/src/components/sidebar/sidebar-status-list.tsx +++ b/packages/app/src/components/sidebar/sidebar-status-list.tsx @@ -1101,7 +1101,8 @@ const styles = StyleSheet.create((theme) => ({ paddingHorizontal: theme.spacing[2], // Keep status mode's Pinned/Workspaces boundary identical to project mode. paddingTop: 2, - paddingBottom: theme.spacing[4], + // Match project grouping: permanent room to scroll the final row above sidebar toasts. + paddingBottom: theme.spacing[24], }, pinnedSection: { marginBottom: theme.spacing[1], diff --git a/packages/app/src/components/toast-host.test.tsx b/packages/app/src/components/toast-host.test.tsx index 32f1bfb8a..f72cf2981 100644 --- a/packages/app/src/components/toast-host.test.tsx +++ b/packages/app/src/components/toast-host.test.tsx @@ -32,4 +32,32 @@ describe("useToastHost", () => { act(() => dismissUploading()); expect(result.current.toast?.content).toBe("Image uploaded"); }); + + it("ends each toast's undo opportunity once, including replacement", () => { + const { result } = renderHook(() => useToastHost()); + const dismissed: string[] = []; + let dismissFirst = () => {}; + let dismissSecond = () => {}; + act(() => { + dismissFirst = result.current.api.show("First archive", { + onDismiss: () => dismissed.push("first"), + }); + }); + act(() => { + dismissSecond = result.current.api.show("Second archive", { + onDismiss: () => dismissed.push("second"), + }); + }); + expect(dismissed).toEqual(["first"]); + act(() => dismissFirst()); + expect(result.current.toast?.content).toBe("Second archive"); + expect(dismissed).toEqual(["first"]); + act(() => { + dismissSecond(); + dismissSecond(); + result.current.dismiss(); + }); + expect(result.current.toast).toBeNull(); + expect(dismissed).toEqual(["first", "second"]); + }); }); diff --git a/packages/app/src/components/toast-host.tsx b/packages/app/src/components/toast-host.tsx index 7be8273a7..bb9a04707 100644 --- a/packages/app/src/components/toast-host.tsx +++ b/packages/app/src/components/toast-host.tsx @@ -8,7 +8,7 @@ import { Platform, StyleSheet as NativeStyleSheet, Text, ToastAndroid, View } fr import Animated, { FadeIn, FadeOut } from "react-native-reanimated"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { StyleSheet, withUnistyles } from "react-native-unistyles"; -import type { Theme } from "@/styles/theme"; +import { SPACING, type Theme } from "@/styles/theme"; import { useTranslation } from "react-i18next"; import { useIsCompactFormFactor } from "@/constants/layout"; import { isWeb } from "@/constants/platform"; @@ -212,10 +212,18 @@ export function ToastViewport({ const topOffset = placement === "app-shell" ? insets.top + headerTopPadding + headerHeight : panelClearance; - const content = ( - - {toast ? ( - - - - ) : null} + + + - - ); + + ) : null; if (placement === "app-shell" && isWeb && typeof document !== "undefined") { return createPortal(content, getOverlayRoot()); @@ -294,26 +298,25 @@ function ToastCard({ } const animatedStyles = NativeStyleSheet.create({ + container: { + position: "absolute", + left: SPACING[4], + right: SPACING[4], + zIndex: OVERLAY_Z.toast, + alignItems: "center", + }, + sidebarContainer: { + position: "absolute", + left: SPACING[2], + right: SPACING[2], + bottom: SPACING[2], + zIndex: OVERLAY_Z.toast, + alignItems: "center", + }, surface: { alignSelf: "center", maxWidth: "100%" }, }); const styles = StyleSheet.create((theme) => ({ - container: (placement: Exclude, topOffset: number) => ({ - position: "absolute", - left: theme.spacing[4], - right: theme.spacing[4], - top: topOffset + (placement === "app-shell" ? theme.spacing[2] : theme.spacing[3]), - zIndex: OVERLAY_Z.toast, - alignItems: "center", - }), - sidebarContainer: { - position: "absolute", - left: theme.spacing[2], - right: theme.spacing[2], - bottom: theme.spacing[2], - zIndex: OVERLAY_Z.toast, - alignItems: "center", - }, widthBoundary: { width: "92%", maxWidth: TOAST_MAX_WIDTH,