Skip to content

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): align multiline error alert controls (#5304)

t3-code[bot]cec1bb9de38a
diff --git a/apps/web/src/components/chat/ThreadErrorBanner.test.tsx b/apps/web/src/components/chat/ThreadErrorBanner.test.tsx
new file mode 100644
index 000000000..73e4c08fc
--- /dev/null
+++ b/apps/web/src/components/chat/ThreadErrorBanner.test.tsx
@@ -0,0 +1,23 @@
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it } from "vite-plus/test";
+
+import { ThreadErrorBanner } from "./ThreadErrorBanner";
+
+describe("ThreadErrorBanner", () => {
+ it("aligns the warning and dismiss icons with the first line of a multi-line error", () => {
+ const markup = renderToStaticMarkup(
+ <ThreadErrorBanner
+ error={"The first error line\ncontinues on a second line"}
+ onDismiss={() => {}}
+ />,
+ );
+
+ expect(markup).toContain('role="alert"');
+ expect(markup).toContain('aria-label="Dismiss error"');
+ expect(markup).not.toContain("controlAlignment");
+ expect(markup).toContain("flex gap-2 items-start");
+ expect(markup).toContain("min-h-7 pt-1 sm:min-h-6 sm:pt-0.5");
+ expect(markup).toContain("h-lh w-4");
+ expect(markup).toContain("h-lh self-start");
+ });
+});
diff --git a/apps/web/src/components/chat/ThreadErrorBanner.tsx b/apps/web/src/components/chat/ThreadErrorBanner.tsx
index 51bfb6266..4ec25b574 100644
--- a/apps/web/src/components/chat/ThreadErrorBanner.tsx
+++ b/apps/web/src/components/chat/ThreadErrorBanner.tsx
@@ -14,7 +14,7 @@ export const ThreadErrorBanner = memo(function ThreadErrorBanner({
if (!error) return null;
return (
<div className="mx-auto w-fit max-w-[min(48rem,calc(100%-2rem))] pt-3">
- <Alert variant="error">
+ <Alert variant="error" controlAlignment="first-line">
<CircleAlertIcon />
<AlertDescription>
<Tooltip>
diff --git a/apps/web/src/components/ui/alert.tsx b/apps/web/src/components/ui/alert.tsx
index 20be44dd3..0af402097 100644
--- a/apps/web/src/components/ui/alert.tsx
+++ b/apps/web/src/components/ui/alert.tsx
@@ -42,9 +42,13 @@ function alertChildSlot(child: React.ReactElement): string | undefined {
function Alert({
className,
variant,
+ controlAlignment = "center",
children,
...props
-}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
+}: React.ComponentProps<"div"> &
+ VariantProps<typeof alertVariants> & {
+ controlAlignment?: "center" | "first-line";
+ }) {
const icon: React.ReactNode[] = [];
const content: React.ReactNode[] = [];
const action: React.ReactNode[] = [];
@@ -71,9 +75,24 @@ function Alert({
role="alert"
{...props}
>
- <div className="flex items-center gap-2">
+ <div
+ className={cn(
+ "flex gap-2",
+ controlAlignment === "first-line" ? "items-start" : "items-center",
+ controlAlignment === "first-line" &&
+ action.length > 0 &&
+ "min-h-7 pt-1 sm:min-h-6 sm:pt-0.5",
+ )}
+ >
{icon.length > 0 && (
- <div className="flex size-4 shrink-0 items-center justify-center [&>svg]:size-full">
+ <div
+ className={cn(
+ "flex shrink-0 items-center justify-center",
+ controlAlignment === "first-line"
+ ? "h-lh w-4 [&>svg]:size-4"
+ : "size-4 [&>svg]:size-full",
+ )}
+ >
{icon}
</div>
)}
@@ -81,7 +100,14 @@ function Alert({
<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
+ className={cn(
+ "flex shrink-0 items-center",
+ controlAlignment === "first-line" ? "h-lh self-start" : "self-center",
+ )}
+ >
+ {action}
+ </div>
)}
</div>
</div>