Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
refactor(toast): move to options rather than position args, tweak styles for mobile toasts (#3347)
Seamus6d32ae7d71e7
diff --git a/js/app/packages/app/component/EmailAuth.tsx b/js/app/packages/app/component/EmailAuth.tsxindex 9851eabb88..e27fa80489 100644--- a/js/app/packages/app/component/EmailAuth.tsx+++ b/js/app/packages/app/component/EmailAuth.tsx@@ -67,10 +67,9 @@ function EmailSignupCallback(props: Pick<EmailAuthParams, 'successPath'>) {onSuccess();return;}- toast.alert(- 'Failed to connect email',- 'Select email permissions on sign-in to enable'- );+ toast.alert('Failed to connect email', {+ subtext: 'Select email permissions on sign-in to enable',+ });navigateToSuccess();});},diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsxindex b6bffaf09f..6930ca5fff 100644--- a/js/app/packages/app/component/Root.tsx+++ b/js/app/packages/app/component/Root.tsx@@ -5,7 +5,6 @@ import { globalSplitManager } from '@app/signal/splitLayout';import { ChatAttachmentsInit } from '@core/component/AI/signal/globalAttachments';import { toast } from '@core/component/Toast/Toast';import { ToastRegion } from '@core/component/Toast/ToastRegion';-import { ENABLE_MOBILE_TOAST } from '@core/constant/featureFlags';import { ChannelsContextProvider } from '@core/context/channels';import {UserContextProvider,@@ -13,7 +12,6 @@ import {useUserInfo,} from '@core/context/user';import { IosPushNotificationModal } from '@core/mobile/IosPushNotificationModal';-import { isMobile } from '@core/mobile/isMobile';import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { createBlockOrchestrator } from '@core/orchestrator';import { formatTabTitle, tabTitleSignal } from '@core/signal/tabTitle';@@ -68,7 +66,6 @@ import {onCleanup,onMount,type ParentProps,- Show,Suspense,Switch,} from 'solid-js';@@ -507,9 +504,7 @@ export function Root() {}}</IsomorphicRouter></Suspense>- <Show when={!isMobile() || ENABLE_MOBILE_TOAST}>- <ToastRegion />- </Show>+ <ToastRegion /></SearchProvider></QuickAccessProvider></CallProvider>diff --git a/js/app/packages/app/component/auth/Signup.tsx b/js/app/packages/app/component/auth/Signup.tsxindex c5d25b7d6d..16501d4e8c 100644--- a/js/app/packages/app/component/auth/Signup.tsx+++ b/js/app/packages/app/component/auth/Signup.tsx@@ -20,10 +20,9 @@ function PostSignupRedirect() {() => {},(err) => {if (err.tag !== 'AlreadyInitialized') {- toast.alert(- 'Failed to connect email',- 'Select email permissions on sign-in to enable'- );+ toast.alert('Failed to connect email', {+ subtext: 'Select email permissions on sign-in to enable',+ });}});diff --git a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts b/js/app/packages/app/component/next-soup/actions/make-delete-action.tsindex cd6fa47101..19ac5a5c18 100644--- a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts+++ b/js/app/packages/app/component/next-soup/actions/make-delete-action.ts@@ -78,21 +78,22 @@ export const makeDeleteAction = (options: MakeDeleteOptions) => {emailEntities.length > 1? `Moved ${emailEntities.length} items to Trash`: 'Moved to Trash',- undefined,- [- {- label: 'Undo',- icon: ArrowCounterClockwise,- onClick: () => {- if (toastId != null) toast.dismiss(toastId);- handle.undo().then(- () => toast.success('Restored from Trash'),- () => toast.failure('Failed to restore from Trash')- );+ {+ actions: [+ {+ label: 'Undo',+ icon: ArrowCounterClockwise,+ onClick: () => {+ if (toastId != null) toast.dismiss(toastId);+ handle.undo().then(+ () => toast.success('Restored from Trash'),+ () => toast.failure('Failed to restore from Trash')+ );+ },},- },- ],- 10_000+ ],+ duration: 10_000,+ });// Surface background API failuresdiff --git a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.tsindex 28c86f9d71..69ecdd6b05 100644--- a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts+++ b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts@@ -104,10 +104,8 @@ export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {let toastId: number | undefined;const showToast = () => {- toastId = toast.success(- message,- undefined,- [+ toastId = toast.success(message, {+ actions: [{label: 'Undo',icon: ArrowCounterClockwise,@@ -118,9 +116,9 @@ export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {},},],- 3_000,- true- );+ duration: 3_000,+ stack: true,+ });};showToast();diff --git a/js/app/packages/app/util/handleFileUpload.ts b/js/app/packages/app/util/handleFileUpload.tsindex 8aa886da0f..f08842cfae 100644--- a/js/app/packages/app/util/handleFileUpload.ts+++ b/js/app/packages/app/util/handleFileUpload.ts@@ -37,17 +37,19 @@ export function useHandleFileUpload({refetchSoupEntity(createdProjectId, 'project', { includeRoot: true });refetchHistory();- toast.success(`Uploaded ${upload.name}`, undefined, [- {- label: 'Open folder',- onClick: () => {- openWithSplit(- { type: 'project', id: createdProjectId },- { referredFrom: 'file-upload', activate: true }- );+ toast.success(`Uploaded ${upload.name}`, {+ actions: [+ {+ label: 'Open folder',+ onClick: () => {+ openWithSplit(+ { type: 'project', id: createdProjectId },+ { referredFrom: 'file-upload', activate: true }+ );+ },},- },- ]);+ ],+ });});}diff --git a/js/app/packages/block-automation/component/Automation.tsx b/js/app/packages/block-automation/component/Automation.tsxindex f015329c19..a2c103feb2 100644--- a/js/app/packages/block-automation/component/Automation.tsx+++ b/js/app/packages/block-automation/component/Automation.tsx@@ -148,7 +148,9 @@ export function Automation() {const updateMutation = useUpdateScheduleMutation({onError: (error) =>- toast.alert('Failed to update automation', getErrorMessage(error)),+ toast.alert('Failed to update automation', {+ subtext: getErrorMessage(error),+ }),});const save = () => {@@ -192,7 +194,7 @@ export function Automation() {const runNowMutation = useRunScheduleNowMutation({onError: (error) =>- toast.alert('Failed to start run', getErrorMessage(error)),+ toast.alert('Failed to start run', { subtext: getErrorMessage(error) }),});// Treat an action as "running" when the server has a fresh claim on it.diff --git a/js/app/packages/block-automation/component/AutomationComposer.tsx b/js/app/packages/block-automation/component/AutomationComposer.tsxindex 74e7c8e42a..18eccdbd12 100644--- a/js/app/packages/block-automation/component/AutomationComposer.tsx+++ b/js/app/packages/block-automation/component/AutomationComposer.tsx@@ -111,10 +111,14 @@ export function AutomationComposer() {{ referredFrom: 'launcher' });}- toast.success('Automation created', 'The automation is now scheduled.');+ toast.success('Automation created', {+ subtext: 'The automation is now scheduled.',+ });},onError: (error) => {- toast.alert('Failed to create automation', getErrorMessage(error));+ toast.alert('Failed to create automation', {+ subtext: getErrorMessage(error),+ });},});diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsxindex c09e72b7f7..6afc7784bf 100644--- a/js/app/packages/block-email/component/BaseInput.tsx+++ b/js/app/packages/block-email/component/BaseInput.tsx@@ -547,10 +547,8 @@ export function BaseInput(props: {if (draftSaveTimer) window.clearTimeout(draftSaveTimer);pendingSend = false;const draftId = message.db_id;- const toastId = toast.success(- 'Email sent',- undefined,- draftId+ const toastId = toast.success('Email sent', {+ actions: draftId? [{label: 'Undo',@@ -562,8 +560,9 @@ export function BaseInput(props: {},]: undefined,- 10_000- );+ duration: 10_000,+ mobile: true,+ });pendingMentions.forEach((mention) => {trackMention(blockId, 'document', mention.documentId);});@@ -1200,10 +1199,9 @@ export function BaseInput(props: {currentAttachmentsByteSize + attachmentsToAddByteSize >=MAX_ATTACHMENTS_BYTES_SIZE) {- toast.failure(- "Can't add more attachments",- 'Total attachments exceed 18MB limit'- );+ toast.failure("Can't add more attachments", {+ subtext: 'Total attachments exceed 18MB limit',+ });return;}@@ -1275,7 +1273,9 @@ export function BaseInput(props: {// Ensure draft is saved before schedulingconst draftID = currentDraft ?? (await executeSaveDraft());if (!draftID) {- toast.failure('Failed to schedule message', 'Draft required');+ toast.failure('Failed to schedule message', {+ subtext: 'Draft required',+ });return;}diff --git a/js/app/packages/block-email/component/TopBar.tsx b/js/app/packages/block-email/component/TopBar.tsxindex 5a373d0690..785d652cbb 100644--- a/js/app/packages/block-email/component/TopBar.tsx+++ b/js/app/packages/block-email/component/TopBar.tsx@@ -88,10 +88,8 @@ export function TopBar(props: {openEntityInSplitFromUnifiedList(nextRow.original, {});}- const toastId = toast.success(- 'Moved to Trash',- undefined,- [+ const toastId = toast.success('Moved to Trash', {+ actions: [{label: 'Undo',icon: ArrowCounterClockwise,@@ -104,8 +102,8 @@ export function TopBar(props: {},},],- 10_000- );+ duration: 10_000,+ });handle.done.catch(() => {toast.failure('Failed to move to Trash');diff --git a/js/app/packages/block-email/component/compose/Compose.tsx b/js/app/packages/block-email/component/compose/Compose.tsxindex 9af212a276..1de8d279c5 100644--- a/js/app/packages/block-email/component/compose/Compose.tsx+++ b/js/app/packages/block-email/component/compose/Compose.tsx@@ -315,10 +315,8 @@ export function EmailCompose(props: EmailComposeProps) {const sendMutation = useSendMessageMutation({onSuccess: (data) => {const draftId = data.message.db_id;- const toastId = toast.success(- 'Email sent',- undefined,- draftId+ const toastId = toast.success('Email sent', {+ actions: draftId? [{label: 'Undo',@@ -330,8 +328,9 @@ export function EmailCompose(props: EmailComposeProps) {},]: undefined,- 10_000- );+ duration: 10_000,+ mobile: true,+ });if (data.message.thread_db_id) {replaceSplit({content: { type: 'email', id: data.message.thread_db_id },@@ -472,7 +471,9 @@ export function EmailCompose(props: EmailComposeProps) {if (date) {const draftID = currentDraft ?? (await executeSaveDraft());if (!draftID) {- toast.failure('Failed to schedule message', 'Draft required');+ toast.failure('Failed to schedule message', {+ subtext: 'Draft required',+ });return;}diff --git a/js/app/packages/block-email/component/compose/ComposeToolbar.tsx b/js/app/packages/block-email/component/compose/ComposeToolbar.tsxindex 434f29aa27..b2e31a127b 100644--- a/js/app/packages/block-email/component/compose/ComposeToolbar.tsx+++ b/js/app/packages/block-email/component/compose/ComposeToolbar.tsx@@ -53,10 +53,9 @@ export function EmailComposeToolbar(props: {currentAttachmentsByteSize + attachmentsToAddByteSize >=MAX_ATTACHMENTS_BYTES_SIZE) {- toast.failure(- "Can't add more attachments",- 'Total attachments exceed 18MB limit'- );+ toast.failure("Can't add more attachments", {+ subtext: 'Total attachments exceed 18MB limit',+ });return;}diff --git a/js/app/packages/block-email/util/makeAttachmentPublic.ts b/js/app/packages/block-email/util/makeAttachmentPublic.tsindex 9ddf8398bd..a8381ebe63 100644--- a/js/app/packages/block-email/util/makeAttachmentPublic.ts+++ b/js/app/packages/block-email/util/makeAttachmentPublic.ts@@ -21,15 +21,13 @@ export const makeAttachmentPublic = async (attachmentId: string) => {},});if (!isErr(result)) {- toast.success(- 'Recipients can now view this file',- 'File share permissions have been updated to public view-only'- );+ toast.success('Recipients can now view this file', {+ subtext: 'File share permissions have been updated to public view-only',+ });} else {- toast.alert(- 'Recipients may not be able to view this file',- 'Please consult the document owner to change share permissions'- );+ toast.alert('Recipients may not be able to view this file', {+ subtext: 'Please consult the document owner to change share permissions',+ });logger.error('Failed to make attachment public', result);}};diff --git a/js/app/packages/block-md/component/TopBar.tsx b/js/app/packages/block-md/component/TopBar.tsxindex 24c47688f6..d0f17d3076 100644--- a/js/app/packages/block-md/component/TopBar.tsx+++ b/js/app/packages/block-md/component/TopBar.tsx@@ -77,10 +77,10 @@ export function TopBar() {const copyLink = () => {const url = buildSimpleEntityUrl({ id: blockId, type: blockAliasedName });navigator.clipboard.writeText(url);- toast.success(- 'Link copied to clipboard.',- 'Sending this link in a Macro message will automatically update permissions to include recipients.'- );+ toast.success('Link copied to clipboard.', {+ subtext:+ 'Sending this link in a Macro message will automatically update permissions to include recipients.',+ });};const copyBranchName = () => copyBranchNameToClipboard(blockId);diff --git a/js/app/packages/block-video/definition.ts b/js/app/packages/block-video/definition.tsindex 007d343b69..93ec23130b 100644--- a/js/app/packages/block-video/definition.ts+++ b/js/app/packages/block-video/definition.ts@@ -86,10 +86,9 @@ export const definition = defineBlock({versionId: documentMetadata.documentVersionId,});} else {- toast.failure(- 'Video playback is not supported for this file type',- `File type: ${fileType}`- );+ toast.failure('Video playback is not supported for this file type', {+ subtext: `File type: ${fileType}`,+ });}return ok({ documentMetadata, userAccessLevel, videoUrl });diff --git a/js/app/packages/channel/Channel/Channel.tsx b/js/app/packages/channel/Channel/Channel.tsxindex 86b9f05fd1..806527e2cd 100644--- a/js/app/packages/channel/Channel/Channel.tsx+++ b/js/app/packages/channel/Channel/Channel.tsx@@ -155,10 +155,9 @@ export function Channel(props: ChannelProps) {if (!loadAroundMessageId || !isMissingChannelMessageError(error))return;- toast.alert(- 'Message no longer available',- 'Showing the latest messages instead.'- );+ toast.alert('Message no longer available', {+ subtext: 'Showing the latest messages instead.',+ });clearStaleRestoredChannelData(props.channelId);targetMessageController.reset();}diff --git a/js/app/packages/core/component/ForwardToChannel.tsx b/js/app/packages/core/component/ForwardToChannel.tsxindex 08aa7b5aee..c3c29ca3f4 100644--- a/js/app/packages/core/component/ForwardToChannel.tsx+++ b/js/app/packages/core/component/ForwardToChannel.tsx@@ -309,12 +309,14 @@ export function ForwardToChannel(props: ForwardToChannelProps) {submitChannelPermissions(channelId);props.refetch?.();- toast.success('Message sent successfully', undefined, [- {- label: 'View in channel',- onClick: navigateToChannel,- },- ]);+ toast.success('Message sent successfully', {+ actions: [+ {+ label: 'View in channel',+ onClick: navigateToChannel,+ },+ ],+ });analytics.track('share_entity', { location: 'forward_to_channel' });});} else {@@ -340,12 +342,14 @@ export function ForwardToChannel(props: ForwardToChannelProps) {props.refetch?.();if (!multipleMessages) {const { navigateToChannel } = res;- toast.success('Message sent successfully', undefined, [- {- label: 'View in channel',- onClick: () => navigateToChannel(),- },- ]);+ toast.success('Message sent successfully', {+ actions: [+ {+ label: 'View in channel',+ onClick: () => navigateToChannel(),+ },+ ],+ });}analytics.track('share_entity', {location: 'forward_to_channel',@@ -369,12 +373,14 @@ export function ForwardToChannel(props: ForwardToChannelProps) {props.refetch?.();if (!multipleMessages) {- toast.success('Message sent successfully', undefined, [- {- label: 'View in channel',- onClick: () => navigateToChannel(),- },- ]);+ toast.success('Message sent successfully', {+ actions: [+ {+ label: 'View in channel',+ onClick: () => navigateToChannel(),+ },+ ],+ });}analytics.track('share_entity', { location: 'forward_to_channel' });});diff --git a/js/app/packages/core/component/Toast/Toast.tsx b/js/app/packages/core/component/Toast/Toast.tsxindex 0c796392a2..800f47ed64 100644--- a/js/app/packages/core/component/Toast/Toast.tsx+++ b/js/app/packages/core/component/Toast/Toast.tsx@@ -1,3 +1,4 @@+import { isMobile } from '@core/mobile/isMobile';import { Toast, toaster } from '@kobalte/core/toast';import CheckIcon from '@phosphor/check.svg';import ExclamationIcon from '@phosphor/exclamation-mark.svg';@@ -113,6 +114,26 @@ export interface ToastAction {onClick: () => void;}+/**+ * Common options for all toast calls.+ *+ * Note: by default, toasts do NOT render on mobile. Pass `mobile: true` to opt+ * in to the mobile-styled toast region (centered above the mobile dock).+ */+export interface ToastOptions {+ subtext?: string;+ /** Auto-dismiss duration in ms. When omitted, the toast uses a default 3s timer. */+ duration?: number;+ /** When true, render this toast on mobile (in the mobile-specific region). */+ mobile?: boolean;+}++export interface ToastSuccessOptions extends ToastOptions {+ actions?: ToastAction[];+ /** When true, bypasses the 3s dedupe so repeated calls stack instead of replacing. */+ stack?: boolean;+}+/*** Config for a fully custom toast.* Replaces the icon, title, and accent color of the standard layout while@@ -147,6 +168,11 @@ const MAX_VISIBLE_TOASTS = 3;* oldest first. Used to evict the oldest toast when the limit is exceeded.*/const activeToastIds: number[] = [];+/**+ * The currently-visible mobile toast. The mobile region only shows one toast+ * at a time — each new mobile toast dismisses the previous one immediately.+ */+let activeMobileToastId: number | undefined;function createToastKey(message: string, type: ToastType): string {return `${type}:${message}`;@@ -169,21 +195,10 @@ function dismissIfRecent(message: string, type: ToastType): void {// Tell users that an action has successfully completedfunction success(message: string,- subtext?: string,- actions?: ToastAction[],- duration?: number,- /** When true, bypasses the 3s dedupe so repeated calls stack instead of replacing. */- stack?: boolean+ options?: ToastSuccessOptions): number | undefined {- if (!stack) dismissIfRecent(message, ToastType.SUCCESS);- return createToast(- message,- ToastType.SUCCESS,- subtext,- actions,- duration,- stack- );+ if (!options?.stack) dismissIfRecent(message, ToastType.SUCCESS);+ return createToast(message, ToastType.SUCCESS, options);}function dismiss(toastId: number) {@@ -191,28 +206,34 @@ function dismiss(toastId: number) {}// Tell users that an action has failed, because of us-function failure(message: string, subtext?: string, duration?: number) {+function failure(message: string, options?: ToastOptions) {dismissIfRecent(message, ToastType.FAILURE);- createToast(message, ToastType.FAILURE, subtext, undefined, duration);+ createToast(message, ToastType.FAILURE, options);}// Tell users that an action has failed, because of them-function alert(message: string, subtext?: string, duration?: number) {+function alert(message: string, options?: ToastOptions) {dismissIfRecent(message, ToastType.ALERT);- createToast(message, ToastType.ALERT, subtext, undefined, duration);+ createToast(message, ToastType.ALERT, options);}-function ActionButtons(props: { actions: ToastAction[] }) {+function ActionButtons(props: { actions: ToastAction[]; mobile?: boolean }) {return (<For each={props.actions}>{(action) => (<Button+ size={props.mobile ? 'sm' : 'md'}onClick={action.onClick}- variant="base"- class="flex items-center gap-1.5 rounded py-1 px-2 text-sm font-semibold shrink-0"+ variant={props.mobile ? 'ghost' : 'base'}+ class={cn('px-2 py-1', props.mobile && 'text-panel text-xs')}><Show when={action.icon}>- {(icon) => <Dynamic component={icon()} class="size-3.5 shrink-0" />}+ {(icon) => (+ <Dynamic+ component={icon()}+ class="size-[1em] touch:min-h-0! touch:min-w-0!"+ />+ )}</Show>{action.label}</Button>@@ -221,6 +242,32 @@ function ActionButtons(props: { actions: ToastAction[] }) {);}+function ToastBodyWrapper(props: {+ mobile?: boolean;+ accentColor: string;+ children: JSX.Element;+}) {+ return (+ <Show+ when={props.mobile}+ fallback={+ <Surface+ highlightColor={props.accentColor}+ active+ class="relative w-[90vw] sm:w-md p-2 sm:p-3"+ depth={2}+ >+ {props.children}+ </Surface>+ }+ >+ <div class="relative w-full p-2 text-xs rounded bg-ink text-surface shadow-md">+ {props.children}+ </div>+ </Show>+ );+}+function ToastContent(props: {toastId: number;toastType?: ToastType;@@ -232,6 +279,8 @@ function ToastContent(props: {duration?: number;embed?: Component;custom?: CustomToastConfig;+ /** Render the mobile variant (no highlight border, text-xs, simplified). */+ mobile?: boolean;/** Called when this toast is removed from the DOM, so callers can clean up tracking. */onDismiss?: () => void;}) {@@ -302,19 +351,17 @@ function ToastContent(props: {return (<ToasttoastId={props.toastId}- class={`relative overflow-visible pointer-events-auto shadow-md rounded+ class={cn(+ `relative overflow-visible pointer-events-auto shadow-md roundeddata-opened:animate-slide-in transition-[transform,opacity] duration-100 ease-in data-closed:opacity-0 data-[swipe=move]:translate-x-(--kb-toast-swipe-move-x)- data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:ease-out data-[swipe=cancel]:duration-200 data-[swipe=end]:animate-swipe-out`}+ data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:ease-out data-[swipe=cancel]:duration-200 data-[swipe=end]:animate-swipe-out`,+ props.mobile && 'w-full'+ )}persistent={true}onMouseEnter={() => setIsHovered(true)}onMouseLeave={() => setIsHovered(false)}>- <Surface- highlightColor={accentColor()}- active- class="relative w-[90vw] sm:w-md p-2 sm:p-3"- depth={2}- >+ <ToastBodyWrapper mobile={props.mobile} accentColor={accentColor()}><Switch>{/* ── Embed layout ── */}<Match when={props.embed}>@@ -335,26 +382,39 @@ function ToastContent(props: {{(customConfig) => (<><div class="flex items-center gap-2 justify-between">- <Show when={customConfig().icon}>- {(icon) => (- <div class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75">- <Dynamic component={icon()} />- </div>- )}+ <Show when={customConfig().icon && !props.mobile}>+ {(_) => {+ const icon = customConfig().icon!;+ return (+ <div class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75">+ <Dynamic component={icon} />+ </div>+ );+ }}</Show>- <Toast.Title class="font-semibold text-ink grow shrink truncate">+ <Toast.Title+ class={cn(+ 'font-semibold grow shrink truncate text-left',+ props.mobile ? 'text-xs' : 'text-ink'+ )}+ >{customConfig().title}</Toast.Title><Show when={customConfig().actions?.length}>- <ActionButtons actions={customConfig().actions!} />+ <ActionButtons+ actions={customConfig().actions!}+ mobile={props.mobile}+ />+ </Show>+ <Show when={!props.mobile}>+ <Toast.CloseButton>+ <Button variant="ghost" size="icon-sm" class="rounded-xs">+ <XIcon />+ </Button>+ </Toast.CloseButton></Show>- <Toast.CloseButton>- <Button variant="ghost" size="icon-sm" class="rounded-xs">- <XIcon />- </Button>- </Toast.CloseButton></div>- <Show when={customConfig().content}>+ <Show when={customConfig().content && !props.mobile}><div class="my-2 ml-7">{customConfig().content?.()}</div></Show></>@@ -366,33 +426,45 @@ function ToastContent(props: {{(s) => (<><div class="flex items-center gap-2 justify-between">- <div- class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75"- style={{ 'background-color': s().borderColor }}+ <Show when={!props.mobile}>+ <div+ class="size-5 flex shrink-0 justify-center items-center rounded-full p-0.75"+ style={{ 'background-color': s().borderColor }}+ >+ <Dynamic+ component={s().icon}+ class={cn(+ 'size-3.5 text-surface',+ props.toastType === ToastType.LOADING+ ? 'animate-spin'+ : ''+ )}+ />+ </div>+ </Show>+ <Toast.Title+ class={cn(+ 'font-semibold grow shrink truncate text-left',+ props.mobile ? 'text-xs' : 'text-ink'+ )}>- <Dynamic- component={s().icon}- class={cn(- 'size-3.5 text-surface',- props.toastType === ToastType.LOADING- ? 'animate-spin'- : ''- )}- />- </div>- <Toast.Title class="font-semibold text-ink grow shrink truncate">{props.message}</Toast.Title><Show when={props.actions?.length}>- <ActionButtons actions={props.actions!} />+ <ActionButtons+ actions={props.actions!}+ mobile={props.mobile}+ />+ </Show>+ <Show when={!props.mobile}>+ <Toast.CloseButton>+ <Button variant="ghost" size="icon-sm" class="rounded-xs">+ <XIcon />+ </Button>+ </Toast.CloseButton></Show>- <Toast.CloseButton>- <Button variant="ghost" size="icon-sm" class="rounded-xs">- <XIcon />- </Button>- </Toast.CloseButton></div>- <Show when={props.subtext}>+ <Show when={props.subtext && !props.mobile}><Toast.Description class="text-sm text-ink-extra-muted ml-7">{props.subtext}</Toast.Description>@@ -412,7 +484,7 @@ function ToastContent(props: {}}/></Show>- </Surface>+ </ToastBodyWrapper></Toast>);}@@ -427,8 +499,12 @@ async function promise<T>(error?: string | ((error: any) => string);toastTypeDeterminer?: (result: T) => ToastType;subtext?: string;+ mobile?: boolean;}): Promise<T> {+ const useMobile = options.mobile && isMobile();+ const region = useMobile ? 'mobile-toast-region' : 'toast-region';+const toastId = toaster.show((props) => (<ToastContent@@ -437,9 +513,10 @@ async function promise<T>(message={options.loading}subtext={options.subtext}persistent={true}+ mobile={useMobile}/>),- { region: 'toast-region' }+ { region });return promiseArg@@ -455,7 +532,7 @@ async function promise<T>(const toastType =options.toastTypeDeterminer?.(result) ?? ToastType.SUCCESS;- createToast(successMessage, toastType);+ createToast(successMessage, toastType, { mobile: options.mobile });}return result;@@ -467,7 +544,7 @@ async function promise<T>(typeof options.error === 'function'? options.error(error): options.error;- failure(errorMessage);+ failure(errorMessage, { mobile: options.mobile });}throw error;});@@ -478,14 +555,13 @@ async function promise<T>(function createToast(message: string,toastType: ToastType,- subtext?: string,- actions?: ToastAction[],- // When undefined, the toast auto-dismisses after a default delay but shows NO progress bar.- // When explicitly set, the toast uses that duration AND shows the progress bar.- duration?: number,- /** Skip recentToasts tracking so this toast never dedupes against a future call. */- stack?: boolean+ options?: ToastSuccessOptions) {+ const { subtext, actions, duration, stack, mobile } = options ?? {};++ // On mobile, toasts only render when explicitly opted in via `mobile: true`.+ if (isMobile() && !mobile) return undefined;+if (!stack) {const key = createToastKey(message, toastType);const existingToast = recentToasts.get(key);@@ -494,11 +570,21 @@ function createToast(}}- // Evict the oldest visible toast when the display limit is reached, so the- // newest toast always appears immediately instead of being queued.- if (activeToastIds.length >= MAX_VISIBLE_TOASTS) {- const oldestId = activeToastIds.shift();- if (oldestId !== undefined) toaster.dismiss(oldestId);+ const useMobile = mobile && isMobile();+ const region = useMobile ? 'mobile-toast-region' : 'toast-region';++ if (useMobile) {+ // Mobile region shows only the latest toast — dismiss the previous one.+ if (activeMobileToastId !== undefined) {+ toaster.dismiss(activeMobileToastId);+ }+ } else {+ // Evict the oldest visible toast when the display limit is reached, so the+ // newest toast always appears immediately instead of being queued.+ if (activeToastIds.length >= MAX_VISIBLE_TOASTS) {+ const oldestId = activeToastIds.shift();+ if (oldestId !== undefined) toaster.dismiss(oldestId);+ }}const toastId = toaster.show(@@ -512,16 +598,27 @@ function createToast(// Pass duration only when explicitly provided — this is what gates the progress bar.// When undefined, ToastContent falls back to its own default dismiss timing internally.duration={duration}+ mobile={useMobile}onDismiss={() => {- const idx = activeToastIds.indexOf(props.toastId);- if (idx !== -1) activeToastIds.splice(idx, 1);+ if (useMobile) {+ if (activeMobileToastId === props.toastId) {+ activeMobileToastId = undefined;+ }+ } else {+ const idx = activeToastIds.indexOf(props.toastId);+ if (idx !== -1) activeToastIds.splice(idx, 1);+ }}}/>),- { region: 'toast-region' }+ { region });- activeToastIds.push(toastId);+ if (useMobile) {+ activeMobileToastId = toastId;+ } else {+ activeToastIds.push(toastId);+ }if (!stack) {const key = createToastKey(message, toastType);@@ -550,8 +647,12 @@ function embed(persistent?: boolean;duration?: number;region?: string;+ mobile?: boolean;}) {+ const useMobile = options?.mobile && isMobile();+ const region =+ options?.region ?? (useMobile ? 'mobile-toast-region' : 'toast-region');return toaster.show((props) => (<ToastContent@@ -559,9 +660,10 @@ function embed(embed={component}persistent={options?.persistent}duration={options?.duration}+ mobile={useMobile}/>),- { region: options?.region || 'toast-region' }+ { region });}@@ -578,8 +680,12 @@ function custom(persistent?: boolean;duration?: number;region?: string;+ mobile?: boolean;}): number {+ const useMobile = options?.mobile && isMobile();+ const region =+ options?.region ?? (useMobile ? 'mobile-toast-region' : 'toast-region');return toaster.show((props) => (<ToastContent@@ -587,9 +693,10 @@ function custom(custom={config}persistent={options?.persistent}duration={options?.duration}+ mobile={useMobile}/>),- { region: options?.region || 'toast-region' }+ { region });}diff --git a/js/app/packages/core/component/Toast/ToastRegion.tsx b/js/app/packages/core/component/Toast/ToastRegion.tsxindex ba2e4f57a1..83ee0af38b 100644--- a/js/app/packages/core/component/Toast/ToastRegion.tsx+++ b/js/app/packages/core/component/Toast/ToastRegion.tsx@@ -16,6 +16,26 @@ export function ToastRegion() {<Toast.List class="absolute bottom-0 right-0 flex flex-col p-2 sm:p-4 gap-2" /></Toast.Region></div>++ {/*+ Mobile-only region: centered above the mobile dock. Only one toast is+ ever visible — Toast.tsx dismisses the previous mobile toast as soon+ as a new one is shown, so no stacking is needed here.+ */}+ <div+ class="fixed left-1/2 -translate-x-1/2 w-full max-w-[420px] px-4 pointer-events-none z-toast-region"+ style={{+ bottom: 'calc(var(--safe-bottom, 0px) + 104px)',+ }}+ >+ <Toast.Region+ regionId="mobile-toast-region"+ duration={Infinity}+ pauseOnInteraction={false}+ >+ <Toast.List class="flex flex-col" />+ </Toast.Region>+ </div></Portal>);}diff --git a/js/app/packages/core/component/TopBar/ShareButton.tsx b/js/app/packages/core/component/TopBar/ShareButton.tsxindex 626d6d2de3..2db331d40d 100644--- a/js/app/packages/core/component/TopBar/ShareButton.tsx+++ b/js/app/packages/core/component/TopBar/ShareButton.tsx@@ -583,10 +583,10 @@ export function ShareModal(props: ShareModalProps) {params);navigator.clipboard.writeText(url);- toast.success(- 'Link copied to clipboard.',- 'Sending this link in a Macro message will automatically update permissions to include recipients.'- );+ toast.success('Link copied to clipboard.', {+ subtext:+ 'Sending this link in a Macro message will automatically update permissions to include recipients.',+ });});const [channelNamesResource] = createResource(@@ -659,12 +659,13 @@ export function ShareModal(props: ShareModalProps) {});if (!isErr(result)) {refetch();- toast.success(- 'Removed channel access',- 'Channel no longer has access to this chat'- );+ toast.success('Removed channel access', {+ subtext: 'Channel no longer has access to this chat',+ });} else {- toast.alert('Failed to remove channel access', 'Please try again');+ toast.alert('Failed to remove channel access', {+ subtext: 'Please try again',+ });console.error(result);}} else if (props.itemType === 'document') {@@ -681,12 +682,13 @@ export function ShareModal(props: ShareModalProps) {});if (!isErr(result)) {refetch();- toast.success(- 'Removed channel access',- 'Channel no longer has access to this document'- );+ toast.success('Removed channel access', {+ subtext: 'Channel no longer has access to this document',+ });} else {- toast.alert('Failed to remove channel access', 'Please try again');+ toast.alert('Failed to remove channel access', {+ subtext: 'Please try again',+ });console.error(result);}} else if (props.itemType === 'project') {@@ -705,7 +707,9 @@ export function ShareModal(props: ShareModalProps) {refetch();toast.success('Removed folder access');} else {- toast.alert('Failed to remove folder access', 'Please try again');+ toast.alert('Failed to remove folder access', {+ subtext: 'Please try again',+ });console.error(result);}}@@ -777,13 +781,14 @@ export function ShareModal(props: ShareModalProps) {if (result && isOk(result)) {refetch();if (!hideSuccessToast) {- toast.success(- 'Changed channel access level',- accessLevelText(accessLevel)- );+ toast.success('Changed channel access level', {+ subtext: accessLevelText(accessLevel),+ });}} else {- toast.alert('Failed to change channel access', 'Please try again');+ toast.alert('Failed to change channel access', {+ subtext: 'Please try again',+ });console.error(result);}}@@ -813,15 +818,13 @@ export function ShareModal(props: ShareModalProps) {refetch();if (accessLevel === null) {- toast.success(- 'Made chat private',- 'Only shared users can access this chat'- );+ toast.success('Made chat private', {+ subtext: 'Only shared users can access this chat',+ });} else {- toast.success(- 'Updated public link sharing',- `Anyone with the link can ${accessLevel} this chat`- );+ toast.success('Updated public link sharing', {+ subtext: `Anyone with the link can ${accessLevel} this chat`,+ });analytics.track('share_entity', {entityType: 'chat',@@ -830,7 +833,9 @@ export function ShareModal(props: ShareModalProps) {});}} else {- toast.alert('Failed to change chat access', 'Please try again');+ toast.alert('Failed to change chat access', {+ subtext: 'Please try again',+ });console.error(result);}} else if (props.itemType === 'document') {@@ -844,15 +849,13 @@ export function ShareModal(props: ShareModalProps) {if (!isErr(result)) {refetch();if (accessLevel === null) {- toast.success(- 'Made document private',- 'Only shared users can access this document'- );+ toast.success('Made document private', {+ subtext: 'Only shared users can access this document',+ });} else {- toast.success(- 'Updated public link sharing',- `Anyone with the link can ${accessLevel} this document`- );+ toast.success('Updated public link sharing', {+ subtext: `Anyone with the link can ${accessLevel} this document`,+ });analytics.track('share_entity', {entityType: 'document',@@ -861,7 +864,9 @@ export function ShareModal(props: ShareModalProps) {});}} else {- toast.alert('Failed to change document access', 'Please try again');+ toast.alert('Failed to change document access', {+ subtext: 'Please try again',+ });console.error(result);}} else if (props.itemType === 'project') {@@ -875,15 +880,13 @@ export function ShareModal(props: ShareModalProps) {if (!isErr(result)) {refetch();if (accessLevel === null) {- toast.success(- 'Made folder private',- 'Only shared users can access this folder'- );+ toast.success('Made folder private', {+ subtext: 'Only shared users can access this folder',+ });} else {- toast.success(- 'Updated public link sharing',- `Anyone with the link can ${accessLevel} this folder`- );+ toast.success('Updated public link sharing', {+ subtext: `Anyone with the link can ${accessLevel} this folder`,+ });analytics.track('share_entity', {entityType: 'project',@@ -892,7 +895,9 @@ export function ShareModal(props: ShareModalProps) {});}} else {- toast.alert('Failed to change folder access', 'Please try again');+ toast.alert('Failed to change folder access', {+ subtext: 'Please try again',+ });console.error(result);}}@@ -1226,10 +1231,10 @@ export function ShareTrigger(props: { copyLink?: () => void }) {if (props.copyLink) return props.copyLink();navigator.clipboard.writeText(defaultUrl());analytics.track('copy_share_link', { blockType });- toast.success(- 'Link copied to clipboard.',- 'Sending this link in a Macro message will automatically update permissions to include recipients.'- );+ toast.success('Link copied to clipboard.', {+ subtext:+ 'Sending this link in a Macro message will automatically update permissions to include recipients.',+ });});const ShareLinkAction = createMemo(() => ({diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex d0bc6173f3..26996e5a55 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -351,8 +351,3 @@ export const ENABLE_MARKDOWN_SIDE_PANEL = resolveFeatureFlag('ENABLE_MARKDOWN_SIDE_PANEL',true);--export const ENABLE_MOBILE_TOAST = resolveFeatureFlag(- 'ENABLE_MOBILE_TOAST',- false-);diff --git a/js/app/packages/entity/src/extractors-notification/notification-actions.tsx b/js/app/packages/entity/src/extractors-notification/notification-actions.tsxindex 64512f436f..78b91a0d9b 100644--- a/js/app/packages/entity/src/extractors-notification/notification-actions.tsx+++ b/js/app/packages/entity/src/extractors-notification/notification-actions.tsx@@ -43,10 +43,8 @@ export function useNotificationStackActions(props: NotificationActionsProps) {let toastId: number | undefined;const showToast = () => {- toastId = toast.success(- 'Marked as done',- undefined,- [+ toastId = toast.success('Marked as done', {+ actions: [{label: 'Undo',icon: ArrowCounterClockwise,@@ -59,9 +57,9 @@ export function useNotificationStackActions(props: NotificationActionsProps) {},},],- 10_000,- true- );+ duration: 10_000,+ stack: true,+ });};showToast();diff --git a/js/app/packages/queries/call/call.ts b/js/app/packages/queries/call/call.tsindex 38aa185d67..8cc4834630 100644--- a/js/app/packages/queries/call/call.ts+++ b/js/app/packages/queries/call/call.ts@@ -27,10 +27,9 @@ export function useJoinCallMutation() {error instanceof MaybeResultError &&error.errors[0]?.code === 'CONFLICT') {- toast.alert(- "You're already in another call",- 'Leave your current call before joining a new one.'- );+ toast.alert("You're already in another call", {+ subtext: 'Leave your current call before joining a new one.',+ });return;}toast.failure('Failed to join call');diff --git a/js/app/packages/queries/email/thread.ts b/js/app/packages/queries/email/thread.tsindex ab2a6eac98..04ca22ac25 100644--- a/js/app/packages/queries/email/thread.ts+++ b/js/app/packages/queries/email/thread.ts@@ -383,14 +383,13 @@ export async function blockSenderWithToast(senderEmail: string) {});if (isErr(result)) {- toast.failure('Failed to block sender', senderEmail);+ toast.failure('Failed to block sender', { subtext: senderEmail });return;}- toast.success(- 'Sender blocked',- `All new messages will be trashed for ${senderEmail}`,- [+ toast.success('Sender blocked', {+ subtext: `All new messages will be trashed for ${senderEmail}`,+ actions: [{label: 'Undo',icon: ArrowCounterClockwise,@@ -399,14 +398,14 @@ export async function blockSenderWithToast(senderEmail: string) {email_address: senderEmail,});if (isErr(undoResult)) {- toast.failure('Failed to unblock sender', senderEmail);+ toast.failure('Failed to unblock sender', { subtext: senderEmail });} else {toast.success('Sender unblocked');}},},- ]- );+ ],+ });}async function upsertSenderFilterWithToast(@@ -421,17 +420,18 @@ async function upsertSenderFilterWithToast(});if (isErr(result)) {- toast.failure(`Failed to mark sender as ${label}`, senderEmail);+ toast.failure(`Failed to mark sender as ${label}`, {+ subtext: senderEmail,+ });return;}const filterId = result[1].filter.id;invalidateAllSoup();- toast.success(- `Sender marked as ${label}`,- `Messages from ${senderEmail} will appear in ${label}`,- [+ toast.success(`Sender marked as ${label}`, {+ subtext: `Messages from ${senderEmail} will appear in ${label}`,+ actions: [{label: 'Undo',icon: ArrowCounterClockwise,@@ -440,15 +440,15 @@ async function upsertSenderFilterWithToast(id: filterId,});if (isErr(undoResult)) {- toast.failure('Failed to undo', senderEmail);+ toast.failure('Failed to undo', { subtext: senderEmail });} else {invalidateAllSoup();toast.success('Sender filter removed');}},},- ]- );+ ],+ });}export const markSenderSignalWithToast = (senderEmail: string) =>diff --git a/js/app/packages/ui/components/Button.tsx b/js/app/packages/ui/components/Button.tsxindex f9b0350926..f1365b13ea 100644--- a/js/app/packages/ui/components/Button.tsx+++ b/js/app/packages/ui/components/Button.tsx@@ -41,7 +41,7 @@ const sizeStyles: Record<ButtonSize, string> = {'sm': 'h-6 px-2 [&_:where(svg)]:size-4 gap-1 text-xs ','icon-lg': 'size-11 p-2 [&_:where(svg)]:size-7 ', /* unused */'icon-md': 'size-9 p-1.5 [&_:where(svg)]:size-6 ',- 'icon-sm': 'size-6 p-0.5 [&_:where(svg)]:size-5 ',+ 'icon-sm': 'size-6 p-0.5 [&_:where(svg)]:size-5 ',};export const Button = (props: ButtonProps) => {