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.
Polish dialog/alert surfaces and unauthenticated provider banner (#3016)
Julius Marminge238715fd6fb1
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex df5d5e4a2..0214f7fe8 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -1843,7 +1843,11 @@ export default function ChatView(props: ChatViewProps) {// `codex_personal`) surfaces its own status/message in the banner rather// than the default Codex's. Falls back to first-match-by-kind when no// saved instance id is available or the instance no longer exists.+ const selectedProviderInstanceId =+ providerStatuses.find((status) => status.instanceId === selectedProviderByThreadId)+ ?.instanceId ?? null;const activeProviderInstanceId =+ selectedProviderInstanceId ??activeThread?.session?.providerInstanceId ??activeThread?.modelSelection.instanceId ??activeProject?.defaultModelSelection?.instanceId ??diff --git a/apps/web/src/components/chat/ProviderStatusBanner.tsx b/apps/web/src/components/chat/ProviderStatusBanner.tsxindex a88294258..546c48661 100644--- a/apps/web/src/components/chat/ProviderStatusBanner.tsx+++ b/apps/web/src/components/chat/ProviderStatusBanner.tsx@@ -1,7 +1,7 @@import { type ServerProvider } from "@t3tools/contracts";import { memo } from "react";-import { Alert, AlertDescription, AlertTitle } from "../ui/alert";-import { CircleAlertIcon } from "lucide-react";+import { InfoIcon } from "lucide-react";+import { cn } from "~/lib/utils";import { formatProviderDriverKindLabel } from "../../providerModels";export const ProviderStatusBanner = memo(function ProviderStatusBanner({@@ -13,22 +13,37 @@ export const ProviderStatusBanner = memo(function ProviderStatusBanner({return null;}- const providerLabel = status.displayName?.trim() || formatProviderDriverKindLabel(status.driver);- const defaultMessage =- status.status === "error"- ? `${providerLabel} provider is unavailable.`- : `${providerLabel} provider has limited availability.`;- const title = `${providerLabel} provider status`;+ const providerName = status.displayName?.trim() || formatProviderDriverKindLabel(status.driver);+ const isUnauthenticated = status.status === "error" && status.auth.status === "unauthenticated";+ const title = isUnauthenticated+ ? `${providerName} is unauthenticated`+ : `${providerName} provider status`;+ const message = isUnauthenticated+ ? "Sign in via the CLI to authenticate again."+ : (status.message ??+ (status.status === "error"+ ? `${providerName} provider is unavailable.`+ : `${providerName} provider has limited availability.`));return (- <div className="pt-3 mx-auto max-w-3xl">- <Alert variant={status.status === "error" ? "error" : "warning"}>- <CircleAlertIcon />- <AlertTitle>{title}</AlertTitle>- <AlertDescription className="line-clamp-3" title={status.message ?? defaultMessage}>- {status.message ?? defaultMessage}- </AlertDescription>- </Alert>+ <div className="mx-auto w-fit max-w-[calc(100%-2rem)] pt-3">+ <div+ className={cn(+ "inline-flex items-center gap-3 rounded-xl border px-3.5 py-3 text-card-foreground text-sm",+ status.status === "warning"+ ? "border-warning/32 bg-warning/4 [&_svg]:text-warning"+ : "border-destructive/32 bg-destructive/4 text-destructive-foreground [&_svg]:text-destructive",+ )}+ role="alert"+ >+ <InfoIcon className="size-4 shrink-0" aria-hidden />+ <div className="flex min-w-0 flex-col gap-1">+ <div className="font-medium">{title}</div>+ <div className="line-clamp-3 text-muted-foreground" title={message}>+ {message}+ </div>+ </div>+ </div></div>);});diff --git a/apps/web/src/components/chat/ThreadErrorBanner.tsx b/apps/web/src/components/chat/ThreadErrorBanner.tsxindex b48412453..fbd1620a0 100644--- a/apps/web/src/components/chat/ThreadErrorBanner.tsx+++ b/apps/web/src/components/chat/ThreadErrorBanner.tsx@@ -1,5 +1,6 @@import { memo } from "react";import { Alert, AlertAction, AlertDescription } from "../ui/alert";+import { Button } from "../ui/button";import { CircleAlertIcon, XIcon } from "lucide-react";export const ThreadErrorBanner = memo(function ThreadErrorBanner({@@ -19,14 +20,9 @@ export const ThreadErrorBanner = memo(function ThreadErrorBanner({</AlertDescription>{onDismiss && (<AlertAction>- <button- type="button"- aria-label="Dismiss error"- className="inline-flex size-6 items-center justify-center rounded-md text-destructive/60 transition-colors hover:text-destructive"- onClick={onDismiss}- >- <XIcon className="size-3.5" />- </button>+ <Button variant="ghost" size="icon-xs" aria-label="Dismiss error" onClick={onDismiss}>+ <XIcon className="text-destructive" />+ </Button></AlertAction>)}</Alert>diff --git a/apps/web/src/components/ui/alert-dialog.tsx b/apps/web/src/components/ui/alert-dialog.tsxindex 84bcff963..c92f1b808 100644--- a/apps/web/src/components/ui/alert-dialog.tsx+++ b/apps/web/src/components/ui/alert-dialog.tsx@@ -17,8 +17,9 @@ function AlertDialogTrigger(props: AlertDialogPrimitive.Trigger.Props) {function AlertDialogBackdrop({ className, ...props }: AlertDialogPrimitive.Backdrop.Props) {return (<AlertDialogPrimitive.Backdrop+ forceRenderclassName={cn(- "fixed inset-0 z-50 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",+ "fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",className,)}data-slot="alert-dialog-backdrop"@@ -31,7 +32,7 @@ function AlertDialogViewport({ className, ...props }: AlertDialogPrimitive.Viewpreturn (<AlertDialogPrimitive.ViewportclassName={cn(- "fixed inset-0 z-50 grid grid-rows-[1fr_auto_3fr] justify-items-center bg-white/48 p-4 backdrop-blur-[2px] dark:bg-black/28",+ "fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4",className,)}data-slot="alert-dialog-viewport"diff --git a/apps/web/src/components/ui/alert.tsx b/apps/web/src/components/ui/alert.tsxindex 41013f95b..20be44dd3 100644--- a/apps/web/src/components/ui/alert.tsx+++ b/apps/web/src/components/ui/alert.tsx@@ -1,55 +1,101 @@import { cva, type VariantProps } from "class-variance-authority";+import { Children, isValidElement } from "react";import type * as React from "react";import { cn } from "~/lib/utils";-const alertVariants = cva(- "relative grid w-full items-start gap-x-2 gap-y-0.5 rounded-xl border px-3.5 py-3 text-card-foreground text-sm has-[>svg]:has-data-[slot=alert-action]:grid-cols-[calc(var(--spacing)*4)_1fr_auto] has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-data-[slot=alert-action]:grid-cols-[1fr_auto] has-[>svg]:gap-x-2 [&>svg]:h-lh [&>svg]:w-4",- {- defaultVariants: {- variant: "default",- },- variants: {- variant: {- default: "bg-transparent dark:bg-input/32 [&>svg]:text-muted-foreground",- error: "border-destructive/32 bg-destructive/4 [&>svg]:text-destructive",- info: "border-info/32 bg-info/4 [&>svg]:text-info",- success: "border-success/32 bg-success/4 [&>svg]:text-success",- warning: "border-warning/32 bg-warning/4 [&>svg]:text-warning",- },+const alertVariants = cva("relative rounded-xl border px-3.5 py-3 text-card-foreground text-sm", {+ defaultVariants: {+ variant: "default",+ },+ variants: {+ variant: {+ default: "bg-transparent dark:bg-input/32 [&_svg]:text-muted-foreground",+ error:+ "border-destructive/32 bg-destructive/4 text-destructive-foreground [&_[data-slot=alert-description]]:text-destructive-foreground/80 [&_svg]:text-destructive",+ info: "border-info/32 bg-info/4 [&_svg]:text-info",+ success: "border-success/32 bg-success/4 [&_svg]:text-success",+ warning: "border-warning/32 bg-warning/4 [&_svg]:text-warning",},},-);+});++function alertChildSlot(child: React.ReactElement): string | undefined {+ const propsSlot = (child.props as Record<string, string | undefined>)["data-slot"];+ if (propsSlot) {+ return propsSlot;+ }++ const type = child.type as { displayName?: string; name?: string };+ switch (type.displayName ?? type.name) {+ case "AlertAction":+ return "alert-action";+ case "AlertTitle":+ return "alert-title";+ case "AlertDescription":+ return "alert-description";+ default:+ return undefined;+ }+}function Alert({className,variant,+ children,...props}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {+ const icon: React.ReactNode[] = [];+ const content: React.ReactNode[] = [];+ const action: React.ReactNode[] = [];++ Children.forEach(children, (child) => {+ if (!isValidElement(child)) {+ content.push(child);+ return;+ }+ const slot = alertChildSlot(child);+ if (slot === "alert-action") {+ action.push(child);+ } else if (slot === "alert-title" || slot === "alert-description") {+ content.push(child);+ } else {+ icon.push(child);+ }+ });+return (<divclassName={cn(alertVariants({ variant }), className)}data-slot="alert"role="alert"{...props}- />+ >+ <div className="flex items-center gap-2">+ {icon.length > 0 && (+ <div className="flex size-4 shrink-0 items-center justify-center [&>svg]:size-full">+ {icon}+ </div>+ )}+ {content.length > 0 && (+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">{content}</div>+ )}+ {action.length > 0 && (+ <div className="flex shrink-0 items-center self-center">{action}</div>+ )}+ </div>+ </div>);}function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {- return (- <div- className={cn("font-medium [svg~&]:col-start-2", className)}- data-slot="alert-title"- {...props}- />- );+ return <div className={cn("font-medium", className)} data-slot="alert-title" {...props} />;}function AlertDescription({ className, ...props }: React.ComponentProps<"div">) {return (<div- className={cn("flex flex-col gap-2.5 text-muted-foreground [svg~&]:col-start-2", className)}+ className={cn("flex flex-col gap-2.5 text-muted-foreground", className)}data-slot="alert-description"{...props}/>@@ -57,16 +103,11 @@ function AlertDescription({ className, ...props }: React.ComponentProps<"div">)}function AlertAction({ className, ...props }: React.ComponentProps<"div">) {- return (- <div- className={cn(- "flex gap-1 max-sm:col-start-2 max-sm:mt-2 sm:row-start-1 sm:row-end-3 sm:self-center sm:[[data-slot=alert-description]~&]:col-start-2 sm:[[data-slot=alert-title]~&]:col-start-2 sm:[svg~&]:col-start-2 sm:[svg~[data-slot=alert-description]~&]:col-start-3 sm:[svg~[data-slot=alert-title]~&]:col-start-3",- className,- )}- data-slot="alert-action"- {...props}- />- );+ return <div className={cn("flex gap-1", className)} data-slot="alert-action" {...props} />;}+AlertTitle.displayName = "AlertTitle";+AlertDescription.displayName = "AlertDescription";+AlertAction.displayName = "AlertAction";+export { Alert, AlertTitle, AlertDescription, AlertAction };diff --git a/apps/web/src/components/ui/command.tsx b/apps/web/src/components/ui/command.tsxindex 9a9a57ef0..ad05bc2a6 100644--- a/apps/web/src/components/ui/command.tsx+++ b/apps/web/src/components/ui/command.tsx@@ -30,7 +30,7 @@ function CommandDialogBackdrop({ className, ...props }: CommandDialogPrimitive.Breturn (<CommandDialogPrimitive.BackdropclassName={cn(- "fixed inset-0 z-50 bg-background/60 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",+ "fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",className,)}data-slot="command-dialog-backdrop"diff --git a/apps/web/src/components/ui/dialog.tsx b/apps/web/src/components/ui/dialog.tsxindex bebe1b0ee..3e1b3d69c 100644--- a/apps/web/src/components/ui/dialog.tsx+++ b/apps/web/src/components/ui/dialog.tsx@@ -23,8 +23,9 @@ function DialogClose(props: DialogPrimitive.Close.Props) {function DialogBackdrop({ className, ...props }: DialogPrimitive.Backdrop.Props) {return (<DialogPrimitive.Backdrop+ forceRenderclassName={cn(- "fixed inset-0 z-50 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",+ "fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",className,)}data-slot="dialog-backdrop"@@ -37,7 +38,7 @@ function DialogViewport({ className, ...props }: DialogPrimitive.Viewport.Props)return (<DialogPrimitive.ViewportclassName={cn(- "fixed inset-0 z-50 grid grid-rows-[1fr_auto_3fr] justify-items-center bg-white/48 p-4 backdrop-blur-[2px] dark:bg-black/28",+ "fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4",className,)}data-slot="dialog-viewport"diff --git a/apps/web/src/components/ui/sheet.tsx b/apps/web/src/components/ui/sheet.tsxindex dfa3d6db1..9d0436b66 100644--- a/apps/web/src/components/ui/sheet.tsx+++ b/apps/web/src/components/ui/sheet.tsx@@ -22,7 +22,7 @@ function SheetBackdrop({ className, ...props }: SheetPrimitive.Backdrop.Props) {return (<SheetPrimitive.BackdropclassName={cn(- "fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",+ "fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0",className,)}data-slot="sheet-backdrop"