papi-dts
    Preparing search index...

    Data needed to display a notification to the user

    interface PlatformNotification {
        clickCommand?: keyof CommandHandlers;
        clickCommandLabel?: string;
        dismissClickCommand?: keyof CommandHandlers;
        dismissible?: boolean;
        duration?: number;
        message: string;
        notificationId?: string | number;
        position?:
            | "top-left"
            | "top-right"
            | "bottom-left"
            | "bottom-right"
            | "top-center"
            | "bottom-center";
        secondaryClickCommand?: keyof CommandHandlers;
        secondaryClickCommandLabel?: string;
        severity: Severity;
        webViewId?: string;
    }
    Index

    Properties

    clickCommand?: keyof CommandHandlers

    Optional command to run if users click on the label in the notification. The command will be sent one argument:

    • NotificationId: The ID of the notification that was clicked

    The command handler should have the type signature NotificationClickCommandHandler.

    clickCommandLabel?: string

    Optional label for users to click when the notification shows. Always rendered as the notification's PRIMARY action button - the visually emphasized one - while secondaryClickCommandLabel always gets the muted secondary styling.

    Automatically localized if this is a LocalizeKey.

    dismissClickCommand?: keyof CommandHandlers

    Optional command to run if the user dismisses the notification themselves - by swiping/dragging it away, or by clicking the close button that a notification with no time limit shows. Sent no arguments other than the notification id, like clickCommand:

    • NotificationId: The ID of the notification that was dismissed

    The command handler should have the type signature NotificationClickCommandHandler.

    IMPORTANT: this fires when the user dismisses the notification themselves (swiping/dragging it away, or clicking the close button of a notification with no time limit) AND when the notification auto-closes because its duration elapsed - a timeout is treated as an implicit dismissal, so a must-answer toast that times out still runs this command instead of vanishing silently. It does NOT fire when the notification is dismissed programmatically via INotificationService.dismiss, nor when the user clicks clickCommand / secondaryClickCommand. Use this to treat a swipe-away (or timeout) as an explicit decision - e.g. pairing it with a "postpone" command lets a two-button, must-answer-style toast keep dismissible true (see the warning on dismissible). If you need the toast to persist until the user actually answers, also set duration to 0.

    dismissible?: boolean

    Whether the user can dismiss the notification directly (e.g. by swiping/dragging it away, or via a close button). Defaults to true.

    The host toast library (Sonner) gates both the secondaryClickCommand button and the user-dismiss gesture that fires dismissClickCommand on this same flag, so a naive dismissible: false would silently turn those controls into dead buttons. To prevent that, the platform IGNORES dismissible: false when the notification renders a secondary action button (a secondaryClickCommand paired with its secondaryClickCommandLabel) or has a dismissClickCommand - the notification stays user-dismissible so those controls keep working. dismissible: false therefore only takes effect on a notification with no secondary button and no dismiss command. For a notification the user must explicitly answer, prefer leaving dismissible: true and using dismissClickCommand so a swipe-away still counts as a real (e.g. "postpone") decision.

    NOTE: dismissible: false does not keep the notification on screen. Auto-close is governed solely by duration (when omitted, 10-35 seconds computed from message length), so a non-dismissible notification still auto-closes on that timer. Also set duration to 0 (or less) if the notification must stay up until it is answered or programmatically dismissed via INotificationService.dismiss.

    duration?: number

    Optional duration in milliseconds for how long the notification is displayed. To make the notification show indefinitely, specify a duration of 0 or less. Such a notification gets a close button, so it can be closed without a mouse, unless it is not user-dismissible (see dismissible, which also says when false is ignored).

    When omitted, duration is computed from message length (minimum 10 seconds, maximum 35 seconds).

    message: string

    Text to display to the user.

    Automatically localized if this is a LocalizeKey.

    notificationId?: string | number

    Optional ID of a previous notification to update instead of showing a new notification.

    On an update (a send reusing an id that is still showing), any optional field you omit keeps the value it had on the previous send for that id - omitting a field never clears it. Pass the field explicitly to change it.

    The one exception is webViewId: which window a send runs in is decided in the main process before the renderer ever sees the notification to merge it, so omitting webViewId on an update does NOT keep routing to the window the original send resolved to - it always routes by the rules webViewId documents, using only what this call passed. An update that lands in a different window updates nothing: that window has never seen the id, so it opens a second notification with no merge applied, and the original stays up in the window it was routed to. Pass the same webViewId on every send that shares an id.

    position?:
        | "top-left"
        | "top-right"
        | "bottom-left"
        | "bottom-right"
        | "top-center"
        | "bottom-center"

    Optional placement of the notification on screen. When omitted, the app's default placement is used.

    secondaryClickCommand?: keyof CommandHandlers

    Optional command to run if users click on the secondary label in the notification. Like clickCommand, the command is sent one argument:

    • NotificationId: The ID of the notification that was clicked

    The command handler should have the type signature NotificationClickCommandHandler.

    secondaryClickCommandLabel?: string

    Optional label for a second action button, shown alongside clickCommandLabel. Provide this together with secondaryClickCommand to give the notification two actions.

    Always rendered as the visually SECONDARY button (muted styling, like the shadcn secondary button variant) so the clickCommandLabel button keeps the emphasis - the platform decides each button's styling from which field it came from, never from ordering.

    Automatically localized if this is a LocalizeKey.

    severity: Severity

    Severity of the notification

    webViewId?: string

    Optional id of a web view this notification is about. When provided, the notification is routed to the window that owns that web view instead of the focused window — for a notification or prompt raised about a specific project or editor that may not be the one the user is currently looking at. Falls back to the focused window whenever the web view's window cannot be determined — it is open nowhere, a window that might have it could not be asked, or it is moving between windows.

    Omit for a generic notice, which should keep routing to the focused window — where the user is looking is the right place for something that is not about anything in particular.

    The narrowest key available: a notification about a project with no web view currently open has no webViewId to name, and routes to the focused window like a generic notice would.