Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): hide provider Update toast action while an update is running (#6544)
Mark Griffin3cde99b25924
diff --git a/apps/web/src/components/ProviderUpdatePrimaryNotification.tsx b/apps/web/src/components/ProviderUpdatePrimaryNotification.tsxindex 64399679a..00112ccec 100644--- a/apps/web/src/components/ProviderUpdatePrimaryNotification.tsx+++ b/apps/web/src/components/ProviderUpdatePrimaryNotification.tsx@@ -20,7 +20,7 @@ import {providerUpdateNotificationKey,type ProviderUpdateToastView,} from "./ProviderUpdateLaunchNotification.logic";-import { stackedThreadToast, toastManager } from "./ui/toast";+import { hiddenToastActionProps, stackedThreadToast, toastManager } from "./ui/toast";import { useAtomCommand } from "../state/use-atom-command";const seenProviderUpdateNotificationKeys = new Set<string>();@@ -68,10 +68,10 @@ function updateProviderUpdateToast(input: {title: input.view.title,description: input.view.description,timeout: 0,- // Base UI merges toast updates with the existing toast. Explicitly clear- // the prompt action so its guarded Update handler cannot linger as a- // visible no-op while the update is running (or after it succeeds).- actionProps: undefined,+ // Base UI merges toast updates and omits `undefined` keys, so `undefined`+ // would leave the prompt's Update button in place. Replace it with a+ // defined empty action so the CTA cannot linger while the update runs.+ actionProps: hiddenToastActionProps,data: {hideCopyButton: true,...(input.view.dismissAfterVisibleMs !== undefineddiff --git a/apps/web/src/components/ui/toast.logic.test.ts b/apps/web/src/components/ui/toast.logic.test.tsindex 576b970bb..f711d2b32 100644--- a/apps/web/src/components/ui/toast.logic.test.ts+++ b/apps/web/src/components/ui/toast.logic.test.ts@@ -2,10 +2,23 @@ import type { ScopedThreadRef } from "@t3tools/contracts";import { assert, describe, it } from "vite-plus/test";import {buildVisibleToastLayout,+ hasVisibleToastAction,shouldHideCollapsedToastContent,shouldRenderThreadScopedToast,} from "./toast.logic";+describe("hasVisibleToastAction", () => {+ it("treats a labeled action as visible", () => {+ assert.equal(hasVisibleToastAction({ children: "Update" }), true);+ });++ it("hides an explicit empty action used to clear a previous CTA", () => {+ assert.equal(hasVisibleToastAction({ children: null }), false);+ assert.equal(hasVisibleToastAction({ children: "" }), false);+ assert.equal(hasVisibleToastAction(undefined), false);+ });+});+describe("shouldHideCollapsedToastContent", () => {it("keeps a single visible toast readable", () => {assert.equal(shouldHideCollapsedToastContent(0, 1), false);diff --git a/apps/web/src/components/ui/toast.logic.ts b/apps/web/src/components/ui/toast.logic.tsindex 80f23970c..62c1a8af7 100644--- a/apps/web/src/components/ui/toast.logic.ts+++ b/apps/web/src/components/ui/toast.logic.ts@@ -1,5 +1,21 @@import type { ScopedThreadRef, ThreadId } from "@t3tools/contracts";+/**+ * Base UI toast updates omit `undefined` fields, so callers that need to remove+ * an action must pass a defined `actionProps` whose `children` are empty.+ * Treat that payload (and missing children) as "no visible action".+ */+export function hasVisibleToastAction(actionProps: unknown): boolean {+ if (actionProps == null || typeof actionProps !== "object") {+ return false;+ }+ if (!("children" in actionProps)) {+ return false;+ }+ const children = actionProps.children;+ return children != null && children !== false && children !== "";+}+export function shouldHideCollapsedToastContent(visibleToastIndex: number,visibleToastCount: number,diff --git a/apps/web/src/components/ui/toast.tsx b/apps/web/src/components/ui/toast.tsxindex 232349d45..69fd0ebf3 100644--- a/apps/web/src/components/ui/toast.tsx+++ b/apps/web/src/components/ui/toast.tsx@@ -32,6 +32,7 @@ import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";import { resolveThreadRouteTarget } from "~/threadRoutes";import {buildVisibleToastLayout,+ hasVisibleToastAction,shouldHideCollapsedToastContent,shouldRenderThreadScopedToast,} from "./toast.logic";@@ -288,7 +289,7 @@ function deriveToastBodyDescriptor(toast: {}): ToastBodyDescriptor {const Icon = toast.type ? TOAST_ICONS[toast.type as keyof typeof TOAST_ICONS] : null;const stackedActionLayout =- toast.actionProps !== undefined && toast.data?.actionLayout === "stacked-end";+ hasVisibleToastAction(toast.actionProps) && toast.data?.actionLayout === "stacked-end";const actionVariant: NonNullable<ThreadToastData["actionVariant"]> =toast.data?.actionVariant ?? "default";const secondaryActionVariant: NonNullable<ThreadToastData["secondaryActionVariant"]> =@@ -301,7 +302,7 @@ function deriveToastBodyDescriptor(toast: {const hasSecondaryAction = toast.data?.secondaryActionProps !== undefined;const hasTrailingControls =copyErrorText !== null ||- toast.actionProps !== undefined ||+ hasVisibleToastAction(toast.actionProps) ||hasAdditionalActions ||hasSecondaryAction;const inlineContentEndPad = hasTrailingControls ? "pr-6" : "pr-10";@@ -400,12 +401,12 @@ function ToastBodyContent({variant={secondaryActionVariant}/>) : null}- {actionProps ? (+ {hasVisibleToastAction(actionProps) ? (<Toast.ActionclassName={cn(buttonVariants({ size: "xs", variant: actionVariant }), "shrink-0")}data-slot="toast-action">- {actionProps.children}+ {actionProps?.children}</Toast.Action>) : null}</div>@@ -798,7 +799,7 @@ function AnchoredToasts() {);}-export { stackedThreadToast } from "./toastHelpers";+export { hiddenToastActionProps, stackedThreadToast } from "./toastHelpers";export type { StackedThreadToastOptions } from "./toastHelpers";export {diff --git a/apps/web/src/components/ui/toastHelpers.test.ts b/apps/web/src/components/ui/toastHelpers.test.tsnew file mode 100644index 000000000..c356aef40--- /dev/null+++ b/apps/web/src/components/ui/toastHelpers.test.ts@@ -0,0 +1,21 @@+import { assert, describe, it } from "vite-plus/test";++import { hiddenToastActionProps, stackedThreadToast } from "./toastHelpers";++describe("hiddenToastActionProps", () => {+ it("is a defined update payload so Base UI can replace a previous action", () => {+ assert.equal(hiddenToastActionProps.children, null);+ assert.equal(+ "actionProps" in stackedThreadToast({ type: "loading", title: "Updating" }),+ false,+ );+ assert.deepEqual(+ stackedThreadToast({+ type: "loading",+ title: "Updating",+ actionProps: hiddenToastActionProps,+ }).actionProps,+ hiddenToastActionProps,+ );+ });+});diff --git a/apps/web/src/components/ui/toastHelpers.ts b/apps/web/src/components/ui/toastHelpers.tsindex 4ec5d1410..70e77ccd3 100644--- a/apps/web/src/components/ui/toastHelpers.ts+++ b/apps/web/src/components/ui/toastHelpers.ts@@ -17,6 +17,14 @@ export type StackedThreadToastOptions = {data?: Omit<ThreadToastData, "actionLayout">;};+/**+ * Defined `actionProps` that hide a previous toast CTA on `toastManager.update`.+ * Passing `actionProps: undefined` is a no-op because updates omit undefined keys.+ */+export const hiddenToastActionProps = {+ children: null,+} as const satisfies Pick<ComponentPropsWithoutRef<"button">, "children">;+/*** Thread toast using the stacked body + bottom action row (copy for errors, CTA on its own row).*/