From afc2c4b84a29cb334f0322b29ea68d9374424dd2 Mon Sep 17 00:00:00 2001 From: LHagfoss Date: Tue, 24 Nov 2026 10:53:07 +0100 Subject: [PATCH 1/2] feat(desktop): restyle toasts on composer glass and add a position setting --- apps/desktop/src/index.css | 39 +++++- apps/desktop/src/lib/toastDrag.test.ts | 8 ++ apps/desktop/src/lib/toastDrag.ts | 32 +++-- apps/desktop/src/state/toastPosition.test.ts | 23 ++++ apps/desktop/src/state/toastPosition.ts | 37 ++++++ apps/desktop/src/ui/SettingsAppearance.tsx | 2 + apps/desktop/src/ui/ToastPositionSetting.tsx | 33 +++++ apps/desktop/src/ui/Toaster.tsx | 128 +++++++++++-------- apps/desktop/src/ui/settingsIndex.ts | 5 + docs/design.md | 41 +++--- 10 files changed, 261 insertions(+), 87 deletions(-) create mode 100644 apps/desktop/src/state/toastPosition.test.ts create mode 100644 apps/desktop/src/state/toastPosition.ts create mode 100644 apps/desktop/src/ui/ToastPositionSetting.tsx diff --git a/apps/desktop/src/index.css b/apps/desktop/src/index.css index 2c844387d..7642e3185 100644 --- a/apps/desktop/src/index.css +++ b/apps/desktop/src/index.css @@ -1251,8 +1251,14 @@ 0 0 0 1px var(--rc-separator); transition: background-color 160ms ease-out; } +/* A toast is a small sibling of the composer: its surface, its edge and a lift that reads over the + panel or transcript under it. */ .rc-toast { - background: var(--rc-glass-bg-strong); + background: var(--rc-composer-bg); + box-shadow: + 0 3px 12px -4px var(--rc-shadow-soft), + 0 10px 28px -14px var(--rc-shadow-soft), + 0 0 0 1px var(--rc-separator); } /* The composer and the question panel over it share the sidebar surface, glass, shadow and corner. */ .rc-composer-card, @@ -1405,7 +1411,7 @@ height: 56px; background: linear-gradient(to bottom, transparent 0, var(--rc-bg) 56px); } -/* A toast rises into the window's bottom-right corner and drops away. */ +/* A toast rises into its corner and drops away. */ @keyframes rc-toast-in { from { opacity: 0; @@ -1424,13 +1430,31 @@ .rc-toast-out { animation: rc-toast-out 140ms ease-in forwards; } +/* At a top position it drops in from above and lifts away. */ +@keyframes rc-toast-in-top { + from { + opacity: 0; + transform: translateY(-10px) scale(0.98); + } +} +@keyframes rc-toast-out-top { + to { + opacity: 0; + transform: translateY(-8px); + } +} +.rc-toast-in-top { + animation: rc-toast-in-top 220ms var(--ease-snappy); +} +.rc-toast-out-top { + animation: rc-toast-out-top 140ms ease-in forwards; +} /* * The stack: only the front card is in flow, so the stack is one card tall; the cards behind * it are absolute, 6px higher and a touch smaller each, so they peek over its top edge and * fan up over each other when the pointer or the keyboard is on the stack. */ .rc-toast-slot { - transform-origin: bottom center; transition: transform 220ms var(--ease-snappy); } @@ -1667,6 +1691,12 @@ transform: translateY(10px); } } +@keyframes rc-toast-in-top-flat { + from { + opacity: 0; + transform: translateY(-10px); + } +} /* The decorative blurs are macOS's alone: on Windows and Linux the reveal fades without its 4px. */ :root:is([data-platform="windows"], [data-platform="linux"]) .rc-reveal { animation-name: rc-fade; @@ -1678,6 +1708,9 @@ :root[data-platform="linux"] .rc-toast-in { animation-name: rc-toast-in-flat; } +:root[data-platform="linux"] .rc-toast-in-top { + animation-name: rc-toast-in-top-flat; +} :root[data-platform="linux"] [role="dialog"].rc-whatsnew[data-state="open"] { animation-name: rc-fade; } diff --git a/apps/desktop/src/lib/toastDrag.test.ts b/apps/desktop/src/lib/toastDrag.test.ts index e745bfbbe..b3fb7d60b 100644 --- a/apps/desktop/src/lib/toastDrag.test.ts +++ b/apps/desktop/src/lib/toastDrag.test.ts @@ -33,6 +33,14 @@ describe("toast drag", () => { expect(dragState(0, -60).dy).toBe(-10); }); + test("in the left corner the card swipes left instead", () => { + expect(dragState(-(TOAST_DISMISS_PX + 1), 0, Number.POSITIVE_INFINITY, -1).dismiss).toBe(true); + expect(dragState(TOAST_DISMISS_PX + 1, 0, Number.POSITIVE_INFINITY, -1).dismiss).toBe(false); + expect(dragState(-30, 0, 40, -1).dismiss).toBe(true); + expect(dragState(-40, 0, Number.POSITIVE_INFINITY, -1)).toMatchObject({ dx: -40, away: 40 }); + expect(dragState(60, 0, Number.POSITIVE_INFINITY, -1)).toMatchObject({ dx: 10, away: 0 }); + }); + test("the card fades as it travels but never below a fifth", () => { expect(dragOpacity(0)).toBe(1); expect(dragOpacity(100)).toBe(0.5); diff --git a/apps/desktop/src/lib/toastDrag.ts b/apps/desktop/src/lib/toastDrag.ts index 8559372cb..d4dc45e57 100644 --- a/apps/desktop/src/lib/toastDrag.ts +++ b/apps/desktop/src/lib/toastDrag.ts @@ -1,5 +1,6 @@ -// Pure drag math and one DOM guard (ui/Toaster.tsx): the card slides right -// only and rubber-bands any other way; past 48px or a quick flick right it +// Pure drag math and one DOM guard (ui/Toaster.tsx): the card slides toward +// its own edge only (right, or left for the bottom-left corner) and +// rubber-bands any other way; past 48px or a quick flick that way it // dismisses, and a barely-moving press is a click. A drag never selects text: // the guard turns selection off and blocks `selectstart` until released, and // every way a drag ends releases it. @@ -26,15 +27,24 @@ export interface DragState { dismiss: boolean; } -/** `ms` is how long the drag has lasted, for a flick; omit it while the pointer moves. */ -export function dragState(dx: number, dy: number, ms = Number.POSITIVE_INFINITY): DragState { - const followX = dx > 0 ? dx : dx / RESIST; - const flick = dx >= TOAST_FLICK_PX && dx / Math.max(ms, 1) > TOAST_FLICK_SPEED; +/** + * `ms` is how long the drag has lasted, for a flick; omit it while the pointer moves. `sign` is + * the dismissing side: 1 for right, -1 for left. + */ +export function dragState( + dx: number, + dy: number, + ms = Number.POSITIVE_INFINITY, + sign: 1 | -1 = 1, +): DragState { + const toward = dx * sign; + const followX = toward > 0 ? dx : dx / RESIST; + const flick = toward >= TOAST_FLICK_PX && toward / Math.max(ms, 1) > TOAST_FLICK_SPEED; return { dx: followX, dy: dy / RESIST, - away: Math.max(0, dx), - dismiss: dx > TOAST_DISMISS_PX || flick, + away: Math.max(0, toward), + dismiss: toward > TOAST_DISMISS_PX || flick, }; } @@ -43,8 +53,10 @@ export function dragOpacity(away: number): number { return Math.max(0.2, 1 - away / 200); } -/** Where a dismissed card flies to: off the window's right edge. */ -export const TOAST_EXIT = "translateX(120%)"; +/** Where a dismissed card flies to: off the window's edge on its side. */ +export function toastExit(sign: 1 | -1): string { + return `translateX(${sign * 120}%)`; +} /** A press and release this close together is a click on the card: it dismisses. */ export function isClick(dx: number, dy: number): boolean { diff --git a/apps/desktop/src/state/toastPosition.test.ts b/apps/desktop/src/state/toastPosition.test.ts new file mode 100644 index 000000000..8cece6c95 --- /dev/null +++ b/apps/desktop/src/state/toastPosition.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, test } from "bun:test"; +import { DEFAULT_TOAST_POSITION, toastFromTop, toastPosition, toastSwipeSign } from "./toastPosition"; + +describe("toast position", () => { + test("reads a stored position leniently", () => { + expect(toastPosition("top-center")).toBe("top-center"); + expect(toastPosition("bottom-left")).toBe("bottom-left"); + expect(toastPosition("middle")).toBe(DEFAULT_TOAST_POSITION); + expect(toastPosition(undefined)).toBe("bottom-right"); + }); + + test("top positions stack downward", () => { + expect(toastFromTop("top-right")).toBe(true); + expect(toastFromTop("top-center")).toBe(true); + expect(toastFromTop("bottom-right")).toBe(false); + }); + + test("a card swipes toward its own edge", () => { + expect(toastSwipeSign("bottom-left")).toBe(-1); + expect(toastSwipeSign("bottom-right")).toBe(1); + expect(toastSwipeSign("top-right")).toBe(1); + }); +}); diff --git a/apps/desktop/src/state/toastPosition.ts b/apps/desktop/src/state/toastPosition.ts new file mode 100644 index 000000000..9076fd0df --- /dev/null +++ b/apps/desktop/src/state/toastPosition.ts @@ -0,0 +1,37 @@ +// Where toasts appear (Settings › Appearance › Toast position), kept in localStorage beside the +// sidebar's view preferences and read by ui/Toaster.tsx. + +import { usePref } from "./sidebarPrefs"; + +export const TOAST_POSITION_PREF = "rustcode.toasts.position"; + +export type ToastPosition = "bottom-right" | "bottom-left" | "top-right" | "top-center"; + +export const TOAST_POSITIONS: readonly { id: ToastPosition; label: string }[] = [ + { id: "bottom-right", label: "Bottom right" }, + { id: "bottom-left", label: "Bottom left" }, + { id: "top-right", label: "Top right" }, + { id: "top-center", label: "Top center" }, +]; + +export const DEFAULT_TOAST_POSITION: ToastPosition = "bottom-right"; + +/** A stored position, read leniently: anything unknown is the default. */ +export function toastPosition(raw: unknown): ToastPosition { + return TOAST_POSITIONS.some((p) => p.id === raw) ? (raw as ToastPosition) : DEFAULT_TOAST_POSITION; +} + +/** Top positions stack downward and enter from above. */ +export function toastFromTop(position: ToastPosition): boolean { + return position.startsWith("top"); +} + +/** The side a card is swiped toward to dismiss it: left in the left corner, right elsewhere. */ +export function toastSwipeSign(position: ToastPosition): 1 | -1 { + return position === "bottom-left" ? -1 : 1; +} + +export function useToastPosition() { + const [raw, set] = usePref(TOAST_POSITION_PREF, DEFAULT_TOAST_POSITION); + return [toastPosition(raw), set as (next: ToastPosition) => void] as const; +} diff --git a/apps/desktop/src/ui/SettingsAppearance.tsx b/apps/desktop/src/ui/SettingsAppearance.tsx index a4210e351..ef44ce4f9 100644 --- a/apps/desktop/src/ui/SettingsAppearance.tsx +++ b/apps/desktop/src/ui/SettingsAppearance.tsx @@ -25,6 +25,7 @@ import { LiveBackgroundGroup } from "./LiveBackgroundGroup"; import { cx, noTextHelpers, Switch } from "./primitives"; import { SettleAfterSetting, SidebarDensitySetting, SidebarToolbarSetting } from "./SidebarDensitySetting"; import { Action, Choice, fieldClass, Group, Row, SectionTitle, Slider } from "./settingsKit"; +import { ToastPositionSetting } from "./ToastPositionSetting"; // hidden and inert, so closing Settings shows the thread exactly where it was. // A grouped nav on the left searches every row's title and keywords @@ -295,6 +296,7 @@ export function AppearancePage() { + { + setPosition(next); + toast("Toasts show here", "info", { id: "toast-position-sample" }); + }; + return ( + pick(DEFAULT_TOAST_POSITION) : undefined} + subtitle="Where short notices like Copied or Pull request opened appear." + > + ({ value: p.id, label: p.label }))} + /> + + ); +} diff --git a/apps/desktop/src/ui/Toaster.tsx b/apps/desktop/src/ui/Toaster.tsx index ffe5c9112..bce14a1ce 100644 --- a/apps/desktop/src/ui/Toaster.tsx +++ b/apps/desktop/src/ui/Toaster.tsx @@ -1,11 +1,14 @@ -// Up to three toasts, newest in front (state/toasts.ts keeps the queue), frosted -// like the composer, in the window's bottom-right corner, away from the -// transcript being read. At rest the cards behind the front one take its -// height and hide their text, so only their edges peek above it. Info and -// success leave after 2.5 s, errors after 5 s. +// Up to three toasts, newest in front (state/toasts.ts keeps the queue), on the +// composer's glass, in the corner Settings › Appearance › Toast position picks +// (bottom right by default, away from the transcript being read). A coloured dot +// says the tone; the × shows on hover or focus. At rest the cards behind the +// front one take its height and hide their text, so only their edges peek past +// it, above it at the bottom and below it at the top. Info and success leave +// after 2.5 s, errors after 5 s. // The pointer or focus on the stack, a drag, or the window in the background -// stops the clock. A click anywhere on the card, ×, Escape, or a drag right past -// 48px (or a quick flick right) dismisses; a drag never selects text anywhere. +// stops the clock. A click anywhere on the card, ×, Escape, or a drag toward the +// card's own edge past 48px (or a quick flick that way) dismisses; a drag never +// selects text anywhere. import { type CSSProperties, type ReactNode, useCallback, useEffect, useRef, useState } from "react"; import { observeSize } from "../lib/resize"; @@ -16,28 +19,21 @@ import { isClick, startsDrag, TOAST_DRAG_MS, - TOAST_EXIT, + toastExit, } from "../lib/toastDrag"; import { dismissToast, expireToasts, setToastsPaused, type Toast, useApp } from "../state/store"; +import { type ToastPosition, toastFromTop, toastSwipeSign, useToastPosition } from "../state/toastPosition"; import { nextExpiry } from "../state/toasts"; -import { - ArrowUpRight, - CircleAlert, - CircleCheck, - ExternalLink, - FolderOpen, - Info, - RotateCcw, - Undo2, - X, -} from "./icons"; +import { X } from "./icons"; import { cx, Spinner } from "./primitives"; -/** How far the cards behind the front one peek over its top edge, and how much smaller each is. */ +/** How far the cards behind the front one peek past its edge, and how much smaller each is. */ const TOAST_PEEK = 6; const TOAST_SHRINK = 0.04; -/** The stack's distance from the window's bottom and right edges. */ +/** The stack's distance from the window's edges. */ const TOAST_INSET = 16; +/** At the top, the stack clears the window's header. */ +const TOAST_TOP = 52; /** The 8px between fanned-out cards. */ const TOAST_GAP = 8; /** A quiet settle on the check after a spinner finishes. */ @@ -65,11 +61,17 @@ interface DragSession { function ToastCard({ toast, compactHeight, + sign, + fromTop, onDrag, }: { toast: Toast; /** A card behind the front one at rest: drawn at the front card's height with its text hidden. */ compactHeight?: number; + /** The side a swipe dismisses toward: 1 right, -1 left. */ + sign: 1 | -1; + /** Anchored at the top: it drops in from above. */ + fromTop: boolean; onDrag: (dragging: boolean) => void; }) { const ref = useRef(null); @@ -92,7 +94,7 @@ function ToastCard({ } if (flyOut && session && el) { el.style.transition = `transform ${TOAST_DRAG_MS}ms var(--ease-snappy), opacity ${TOAST_DRAG_MS}ms ease-out`; - el.style.transform = TOAST_EXIT; + el.style.transform = toastExit(sign); el.style.opacity = "0"; setFlung(true); dismissToast(toast.id); @@ -104,7 +106,7 @@ function ToastCard({ el.style.opacity = ""; } }, - [onDrag, toast.id], + [onDrag, sign, toast.id], ); useEffect(() => () => end(false), [end]); @@ -142,7 +144,7 @@ function ToastCard({ if (!session || !el || session.pointerId !== e.pointerId) return; session.dx = e.clientX - session.x; session.dy = e.clientY - session.y; - const state = dragState(session.dx, session.dy); + const state = dragState(session.dx, session.dy, Number.POSITIVE_INFINITY, sign); el.style.transition = "none"; el.style.transform = `translate(${state.dx}px, ${state.dy}px)`; el.style.opacity = String(dragOpacity(state.away)); @@ -159,7 +161,7 @@ function ToastCard({ dismissToast(toast.id); return; } - end(dragState(session.dx, session.dy, e.timeStamp - session.at).dismiss); + end(dragState(session.dx, session.dy, e.timeStamp - session.at, sign).dismiss); }; const onPointerCancel = () => end(false); @@ -168,9 +170,8 @@ function ToastCard({ }; const error = toast.tone === "error"; - const Icon = error ? CircleAlert : toast.tone === "success" ? CircleCheck : Info; // A promise-style toast (the engine's start) is replaced in place by its success; the spinner - // it had morphs into the check instead of swapping between two unrelated icons. + // it had settles into the green dot instead of swapping between two unrelated marks. const spinning = toast.progress !== undefined && !error; const wasSpinning = useRef(spinning); const [settled, setSettled] = useState(false); @@ -183,6 +184,8 @@ function ToastCard({ return () => clearTimeout(timer); }, [spinning, toast.tone]); const compact = compactHeight !== undefined; + const edge = fromTop ? "-top" : ""; + const motion = toast.leaving ? (flung ? "" : `rc-toast-out${edge}`) : `rc-toast-in${edge}`; return (
-
- +
+ {spinning ? ( - + ) : ( - )} @@ -225,12 +228,14 @@ function ToastCard({
{toast.action && } + {/* Out of the way until the card is hovered or the button is focused: a click on the + card already dismisses it, so the × is the visible way, not the only one. */} @@ -248,18 +253,9 @@ function ToastCard({ ); } -const ACTION_ICONS: Record ReactNode> = { - Undo: Undo2, - Open: ArrowUpRight, - "Release page": ExternalLink, - Restart: RotateCcw, - "Move…": FolderOpen, -}; - function ToastActionButton({ toast, compact }: { toast: Toast; compact: boolean }) { const action = toast.action; if (!action) return null; - const ActionIcon = ACTION_ICONS[action.label]; return ( ); } +/** The stack's place in the window for a position. */ +function anchorStyle(position: ToastPosition): CSSProperties { + switch (position) { + case "bottom-left": + return { left: TOAST_INSET, bottom: TOAST_INSET }; + case "top-right": + return { right: TOAST_INSET, top: TOAST_TOP }; + case "top-center": + return { left: "50%", top: TOAST_TOP, transform: "translateX(-50%)" }; + default: + return { right: TOAST_INSET, bottom: TOAST_INSET }; + } +} + export function Toaster() { const toasts = useApp((s) => s.toasts); + const [position] = useToastPosition(); + const fromTop = toastFromTop(position); + // Toward the stack's open side: up from the bottom, down from the top. + const away = fromTop ? 1 : -1; + const sign = toastSwipeSign(position); const section = useRef(null); const [hovering, setHovering] = useState(false); const [focused, setFocused] = useState(false); @@ -358,8 +372,9 @@ export function Toaster() {
setHovering(true)} onPointerLeave={() => setHovering(false)} onFocus={() => setFocused(true)} @@ -372,7 +387,7 @@ export function Toaster() { up to a card behind, so the stack does not fold before it is reached. */} {expanded && stackHeight > 0 && ( @@ -382,16 +397,21 @@ export function Toaster() { key={toast.id} id={toast.id} onHeight={measure} - className={index === 0 ? "relative" : "absolute inset-x-0 bottom-0"} + className={cx( + index === 0 ? "relative" : cx("absolute inset-x-0", fromTop ? "top-0" : "bottom-0"), + fromTop ? "origin-top" : "origin-bottom", + )} style={{ zIndex: toasts.length - index, transform: expanded - ? `translateY(${-(offsets[index] ?? 0)}px) scale(1)` - : `translateY(${-index * TOAST_PEEK}px) scale(${Math.max(0.9, 1 - index * TOAST_SHRINK)})`, + ? `translateY(${away * (offsets[index] ?? 0)}px) scale(1)` + : `translateY(${away * index * TOAST_PEEK}px) scale(${Math.max(0.9, 1 - index * TOAST_SHRINK)})`, }} > 0 ? heights[toasts[0]?.id ?? ""] : undefined} onDrag={setDragging} /> diff --git a/apps/desktop/src/ui/settingsIndex.ts b/apps/desktop/src/ui/settingsIndex.ts index 4ee19e833..3fb7520bb 100644 --- a/apps/desktop/src/ui/settingsIndex.ts +++ b/apps/desktop/src/ui/settingsIndex.ts @@ -382,6 +382,11 @@ export const SETTINGS_INDEX: SettingEntry[] = [ title: "Reduce transparency", keywords: "glass blur frosted translucent solid mica acrylic vibrancy accessibility contrast", }, + { + section: "appearance", + title: "Toast position", + keywords: "notification notice toast corner top bottom left right center placement", + }, { section: "appearance", title: "Transparency", diff --git a/docs/design.md b/docs/design.md index 021576d0c..d46ef64f5 100644 --- a/docs/design.md +++ b/docs/design.md @@ -467,8 +467,9 @@ that change use `tabular`. `transform`, `opacity` and those two; never `filter` or `box-shadow` on something that moves every frame. - Toasts rise in with `rc-toast-in` (220ms, from 10px below) and drop away - in 140ms `ease-in`; a drag slides it right only (other ways rubber-band at - a sixth) and it snaps back or flies off the right edge in 160ms, and a card shown meanwhile takes the top of the stack. At rest only + in 140ms `ease-in` (at a top position `rc-toast-in-top` and `rc-toast-out-top`, from and to + above); a drag slides it toward its edge only (other ways rubber-band at + a sixth) and it snaps back or flies off that edge in 160ms, and a card shown meanwhile takes the top of the stack. At rest only the front card is in flow, the ones behind peeking 6px above it; hovering or focusing the stack fans them out 8px apart (`transform` only). - A new transcript row rises in with `rc-row-in` (260ms, fade + 6px), once: @@ -726,27 +727,27 @@ a raw element. `?catalog` in a dev build shows them all on one page. Pickers, long command names and destructive actions stay as ordinary rows. **Popover:** `popoverSurface` (`elevated p-3`). - **Dialog:** `elevated rounded-xl p-5` over a `bg-bg/60` scrim. -- **Toast:** `.rc-toast rounded-2xl` (strong glass and a slight shadow), 380px wide, `py-1.5 pl-3 pr-1.5 text-callout`: an icon - (info `text-fg-muted`, success `text-success`, error `text-danger`, a - spinner while it has progress), the text in `text-fg` (up to 3 lines), at - most one action as a tinted button on the close button's row (`h-6 - bg-accent/12 text-accent`, the action's icon before its label: Undo ↶, - Open ↗), and a quiet close button. The card is as tall as its text. - Progress is a 2px accent bar along its foot. `Toaster` shows at most three - (`state/toasts.ts` enforces the queue), newest on top: at rest only the - front card is fully shown, the others taking its height with their text - hidden and peeking 6px above it, and hovering or - focusing the stack fans them out 8px apart, upward. In the window's - bottom-right corner, 16px in, away from the transcript being read. No timer - line: a card's clock is not drawn. A card replaced in place from spinner to check settles - onto the check. The same message again refreshes its card and - restarts its time instead of stacking; past three, the oldest is dropped. +- **Toast:** `.rc-toast rounded-2xl` (the composer's surface, edge and glass with a soft lift), + 340px wide, `py-2 pl-4 pr-2 text-callout`: a 6px tone dot (info `bg-fg-muted`, success + `bg-success`, error `bg-danger`, a spinner while it has progress), the text in `text-fg` (up to 3 + lines), at most one action as an outlined pill (`h-6 rounded-full ring-1 ring-border-strong + text-sub`, label only), and a close button that is collapsed until the card is hovered or the + button focused. The card is as tall as its text. Progress is a 2px accent bar along its foot. + `Toaster` shows at most three (`state/toasts.ts` enforces the queue), newest in front: at rest + only the front card is fully shown, the others taking its height with their text hidden and + peeking 6px past it, and hovering or focusing the stack fans them out 8px apart, away from the + window edge. Settings › Appearance › Toast position puts the stack 16px in from the bottom-right + corner (the default, away from the transcript being read), the bottom-left, the top-right or the + top center (52px down, under the header); at the top it stacks and enters downward. No timer + line: a card's clock is not drawn. A card replaced in place from spinner to dot settles onto the + dot. The same message again refreshes its card and restarts its time instead of stacking; past + three, the oldest is dropped. Info and success leave after 2.5s, errors after 5s. The pointer or focus on the stack, a drag, and a window in the background stop every clock, which resumes with what was left. A click anywhere on the card, ×, Escape (after a - draft or an open overlay has taken it), or a drag right past 48px or a quick - flick right dismisses; the card slides right only, rubber-bands any other - way, snaps back in 160ms, and never selects text. Use a + draft or an open overlay has taken it), or a drag toward the card's edge (left + in the bottom-left corner, right elsewhere) past 48px or a quick flick that way + dismisses; the card slides that way only, rubber-bands any other way, snaps back in 160ms, and never selects text. Use a toast for what is not tied to a message (copied, engine events, errors of an action), not to repeat what the screen already shows (no pin, archive, theme, harness-switch or steering notice); an error about a thread's turn From 5809e077dd94cea4e28b08c01ccac102a5d2b14a Mon Sep 17 00:00:00 2001 From: LHagfoss Date: Tue, 24 Nov 2026 10:54:56 +0100 Subject: [PATCH 2/2] fix(desktop): drop new comments from the toast change --- apps/desktop/src/lib/toastDrag.ts | 11 +++++----- apps/desktop/src/state/toastPosition.ts | 3 --- apps/desktop/src/ui/ToastPositionSetting.tsx | 3 --- apps/desktop/src/ui/Toaster.tsx | 21 +++++++------------- scripts/comment-baseline.txt | 2 +- 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/apps/desktop/src/lib/toastDrag.ts b/apps/desktop/src/lib/toastDrag.ts index d4dc45e57..45a68e12e 100644 --- a/apps/desktop/src/lib/toastDrag.ts +++ b/apps/desktop/src/lib/toastDrag.ts @@ -1,9 +1,8 @@ -// Pure drag math and one DOM guard (ui/Toaster.tsx): the card slides toward -// its own edge only (right, or left for the bottom-left corner) and -// rubber-bands any other way; past 48px or a quick flick that way it -// dismisses, and a barely-moving press is a click. A drag never selects text: -// the guard turns selection off and blocks `selectstart` until released, and -// every way a drag ends releases it. +// Pure drag math and one DOM guard (ui/Toaster.tsx): the card slides toward its own edge only +// (left in the bottom-left corner) and rubber-bands any other way; past 48px or a quick flick that +// way it dismisses, and a barely-moving press is a click. A drag never selects text: the guard +// turns selection off and blocks `selectstart` until released, and every way a drag ends +// releases it. /** How far a drag must travel to dismiss the toast. */ export const TOAST_DISMISS_PX = 48; diff --git a/apps/desktop/src/state/toastPosition.ts b/apps/desktop/src/state/toastPosition.ts index 9076fd0df..91be7ec1b 100644 --- a/apps/desktop/src/state/toastPosition.ts +++ b/apps/desktop/src/state/toastPosition.ts @@ -1,6 +1,3 @@ -// Where toasts appear (Settings › Appearance › Toast position), kept in localStorage beside the -// sidebar's view preferences and read by ui/Toaster.tsx. - import { usePref } from "./sidebarPrefs"; export const TOAST_POSITION_PREF = "rustcode.toasts.position"; diff --git a/apps/desktop/src/ui/ToastPositionSetting.tsx b/apps/desktop/src/ui/ToastPositionSetting.tsx index bae8d561a..9b1682eae 100644 --- a/apps/desktop/src/ui/ToastPositionSetting.tsx +++ b/apps/desktop/src/ui/ToastPositionSetting.tsx @@ -1,6 +1,3 @@ -// Settings › Appearance › Toast position: the corner toasts appear in (state/toastPosition.ts). -// Picking one shows a sample there, so the choice is seen rather than described. - import { toast } from "../state/store"; import { DEFAULT_TOAST_POSITION, diff --git a/apps/desktop/src/ui/Toaster.tsx b/apps/desktop/src/ui/Toaster.tsx index bce14a1ce..32fb17926 100644 --- a/apps/desktop/src/ui/Toaster.tsx +++ b/apps/desktop/src/ui/Toaster.tsx @@ -1,14 +1,10 @@ -// Up to three toasts, newest in front (state/toasts.ts keeps the queue), on the -// composer's glass, in the corner Settings › Appearance › Toast position picks -// (bottom right by default, away from the transcript being read). A coloured dot -// says the tone; the × shows on hover or focus. At rest the cards behind the -// front one take its height and hide their text, so only their edges peek past -// it, above it at the bottom and below it at the top. Info and success leave -// after 2.5 s, errors after 5 s. -// The pointer or focus on the stack, a drag, or the window in the background -// stops the clock. A click anywhere on the card, ×, Escape, or a drag toward the -// card's own edge past 48px (or a quick flick that way) dismisses; a drag never -// selects text anywhere. +// Up to three toasts, newest in front (state/toasts.ts keeps the queue), on the composer's glass in +// the corner Settings › Appearance › Toast position picks (bottom right by default). A dot says the +// tone; the × shows on hover or focus. At rest the cards behind the front one take its height and +// hide their text, so only their edges peek past it. Info and success leave after 2.5 s, errors +// after 5 s. The pointer or focus on the stack, a drag, or the window in the background stops the +// clock. A click on the card, ×, Escape, or a drag toward the card's own edge past 48px (or a quick +// flick that way) dismisses; a drag never selects text anywhere. import { type CSSProperties, type ReactNode, useCallback, useEffect, useRef, useState } from "react"; import { observeSize } from "../lib/resize"; @@ -228,8 +224,6 @@ function ToastCard({
{toast.action && } - {/* Out of the way until the card is hovered or the button is focused: a click on the - card already dismisses it, so the × is the visible way, not the only one. */}