Skip to content

Commit abe0204

Browse files
authored
Merge pull request #405 from krishsharma-code/feat/toast-notifications-25
Feat/toast notifications 25
2 parents 0b8cf69 + bf80c2b commit abe0204

4 files changed

Lines changed: 34 additions & 4 deletions

File tree

frontend/src/app/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@import "tailwindcss";
22
@import "tw-animate-css";
33
@import "shadcn/tailwind.css";
4-
@plugin "@tailwindcss/typography";
4+
55

66
@custom-variant dark (&:is(.dark *));
77

frontend/src/app/layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default function RootLayout({
3939
<I18nProvider>
4040
<TooltipProvider>
4141
{children}
42-
<Toaster richColors position="top-right" closeButton />
4342
</TooltipProvider>
4443
</I18nProvider>
4544
</AuthProvider>

frontend/src/components/chat/ChatPanel.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22

3+
import { toast } from "sonner";
34
import { useState, useRef, useEffect } from "react";
45
import { useTranslation } from "react-i18next";
56
import type { DocInfo } from "@/app/dashboard/page";
@@ -242,21 +243,29 @@ export default function ChatPanel({ activeDoc, onCitationClick }: Props) {
242243
}
243244
}
244245
} catch (err) {
246+
const message = err instanceof Error ? err.message : "Unknown error";
245247
setIsTyping(false);
246248
setMessages((prev) =>
247249
prev.map((m) =>
248250
m.id === assistantId
249251
? {
250252
...m,
251253
content: t("chat.fallbackError", {
252-
message: err instanceof Error ? err.message : "Unknown error",
254+
message,
253255
}),
254256
isStreaming: false,
255257
}
256258
: m
257259
)
258260
);
261+
262+
if (message.toLowerCase().includes("connect") || message.toLowerCase().includes("network")) {
263+
toast.error("Network error. Please check your connection.");
264+
} else {
265+
toast.error(`Upload failed: ${message}`);
266+
}
259267
} finally {
268+
260269
setStreaming(false);
261270
setIsTyping(false);
262271
}
@@ -267,8 +276,9 @@ export default function ChatPanel({ activeDoc, onCitationClick }: Props) {
267276
try {
268277
await api.delete(`/api/v1/chat/history/${activeDoc.id}`);
269278
setMessages([]);
279+
toast.info("Chat history cleared");
270280
} catch {
271-
//silent fail
281+
// silent fail preserved; no additional toast for this scenario
272282
}
273283
};
274284

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use client";
2+
3+
import { Toaster } from "sonner";
4+
5+
export function SonnerToaster() {
6+
return (
7+
<Toaster
8+
richColors
9+
closeButton
10+
position="top-right"
11+
toastOptions={{
12+
classNames: {
13+
toast: "rounded-xl border border-border/60 bg-popover/90 backdrop-blur supports-[backdrop-filter]:bg-popover/60",
14+
title: "font-semibold",
15+
description: "text-muted-foreground",
16+
},
17+
}}
18+
/>
19+
);
20+
}
21+

0 commit comments

Comments
 (0)