LibreChat/packages/client/src/store.ts
James Todaro c9b9644163
🔔 fix: Honor Toast Duration and Support Persistent Toasts (#15049)
* 🔔 fix: Honor Toast Duration and Support Persistent Toasts

* 🔔 fix: Annotate the single-run effect in the toast spec

* 🔔 fix: Give each toast its own close deadline

- a toast replacing one still open inherited the superseded Radix deadline and could close early
- the shown-toast id keys the Radix root and gates `onOpenChange`, so a stale timer is a no-op
- drops the competing hide timer, leaving Radix as the single dismissal owner

* fix: align and emphasize persistent toast close button

---------

Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com>
2026-09-06 04:38:15 +02:00

31 lines
839 B
TypeScript

import { atom, PrimitiveAtom } from 'jotai';
import { NotificationSeverity } from '~/common';
export const chatDirectionAtom: PrimitiveAtom<string> & {
init: string;
} = atom<string>('ltr');
export const fontSizeAtom: PrimitiveAtom<string> & {
init: string;
} = atom<string>('text-base');
export type ToastState = {
open: boolean;
message: string;
severity: NotificationSeverity;
showIcon: boolean;
/** Milliseconds until the toast closes itself, or `Infinity` to require a dismissal. */
duration: number;
/** Increments per shown toast, so each one gets its own close deadline. */
id: number;
};
export const toastState: PrimitiveAtom<ToastState> & {
init: ToastState;
} = atom<ToastState>({
open: false,
message: '',
severity: NotificationSeverity.SUCCESS,
showIcon: true,
duration: 3000,
id: 0,
});