Skip to content

Commit 1311741

Browse files
authored
♻️ Delete Radix UI Dependency: Button #2079
2 parents 92ee255 + 96b9702 commit 1311741

File tree

18 files changed

+168
-499
lines changed

18 files changed

+168
-499
lines changed

backend/consts/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,4 @@ class VectorDatabaseType(str, Enum):
287287

288288

289289
# APP Version
290-
APP_VERSION = "v1.7.8.1"
290+
APP_VERSION = "v1.7.9"

frontend/app/[locale]/chat/components/chatInput.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "@ant-design/icons";
1616

1717
import { Input } from "@/components/ui/input";
18-
import { Button } from "@/components/ui/button";
18+
import { Button } from "antd";
1919
import { Tooltip } from "@/components/ui/tooltip";
2020
import { Textarea } from "@/components/ui/textarea";
2121
import { conversationService } from "@/services/conversationService";
@@ -1037,11 +1037,12 @@ export function ChatInput({
10371037
}
10381038
>
10391039
<Button
1040-
variant="ghost"
1041-
size="icon"
1042-
className="h-10 w-10 text-slate-700 flex items-center justify-center rounded-full border border-slate-300 hover:bg-slate-200 transition-colors"
1043-
onClick={toggleRecording}
1044-
disabled={recordingStatus === "connecting" || isStreaming}
1040+
type="default"
1041+
shape="circle"
1042+
size="middle"
1043+
className="h-10 w-10 text-slate-700 flex items-center justify-center rounded-full border border-slate-300 hover:bg-slate-200 transition-colors"
1044+
onClick={toggleRecording}
1045+
disabled={recordingStatus === "connecting" || isStreaming}
10451046
>
10461047
{isRecording ? (
10471048
<MicOff className="h-5 w-5" />
@@ -1054,8 +1055,9 @@ export function ChatInput({
10541055
{/* Upload file button */}
10551056
<Tooltip title={t("chatInput.uploadFiles")}>
10561057
<Button
1057-
variant="ghost"
1058-
size="icon"
1058+
type="default"
1059+
shape="circle"
1060+
size="middle"
10591061
className="h-10 w-10 text-slate-700 flex items-center justify-center rounded-full border border-slate-300 hover:bg-slate-200 transition-colors"
10601062
onClick={() =>
10611063
document.getElementById("file-upload-regular")?.click()
@@ -1081,7 +1083,9 @@ export function ChatInput({
10811083
>
10821084
<Button
10831085
onClick={onStop}
1084-
size="icon"
1086+
type="primary"
1087+
shape="circle"
1088+
size="middle"
10851089
className="h-10 w-10 bg-red-500 hover:bg-red-600 text-white rounded-full"
10861090
>
10871091
<Square className="h-5 w-5" />
@@ -1091,7 +1095,9 @@ export function ChatInput({
10911095
<Button
10921096
onClick={handleSend}
10931097
disabled={!input.trim() || isLoading || !selectedAgentId}
1094-
size="icon"
1098+
type="primary"
1099+
shape="circle"
1100+
size="middle"
10951101
className={`h-10 w-10 ${
10961102
hasUnsupportedFiles || !selectedAgentId
10971103
? "bg-gray-400 cursor-not-allowed"

frontend/app/[locale]/chat/components/chatLeftSidebar.tsx

Lines changed: 77 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@ import {
1010
} from "lucide-react";
1111
import { useRouter } from "next/navigation";
1212

13-
import { Button } from "@/components/ui/button";
14-
import {
15-
DropdownMenu,
16-
DropdownMenuContent,
17-
DropdownMenuItem,
18-
DropdownMenuTrigger,
19-
} from "@/components/ui/dropdownMenu";
13+
import { Button, Dropdown } from "antd";
2014
import { Input } from "@/components/ui/input";
21-
import { App } from "antd";
2215
import { Tooltip, TooltipProvider } from "@/components/ui/tooltip";
2316
import { StaticScrollArea } from "@/components/ui/scrollArea";
2417
import { USER_ROLES } from "@/const/modelConfig";
@@ -234,64 +227,77 @@ export function ChatSidebar({
234227
overlayStyle={{ maxWidth: "300px" }}
235228
>
236229
<Button
237-
variant="ghost"
238-
className="flex-1 justify-start text-left hover:bg-transparent min-w-0 max-w-[250px]"
239-
onClick={() => onDialogClick(dialog)}
240-
>
241-
<ConversationStatusIndicator
242-
isStreaming={streamingConversations.has(
243-
dialog.conversation_id
244-
)}
245-
isCompleted={completedConversations.has(
246-
dialog.conversation_id
247-
)}
248-
/>
249-
<span className="truncate block text-base font-normal text-gray-800 tracking-wide font-sans">
250-
{dialog.conversation_title}
251-
</span>
252-
</Button>
230+
type="text"
231+
size="middle"
232+
className="flex-1 justify-start text-left min-w-0 max-w-[250px] px-3 py-2 h-auto border-0 shadow-none bg-transparent hover:!bg-transparent active:!bg-transparent"
233+
onClick={() => onDialogClick(dialog)}
234+
>
235+
<ConversationStatusIndicator
236+
isStreaming={streamingConversations.has(
237+
dialog.conversation_id
238+
)}
239+
isCompleted={completedConversations.has(
240+
dialog.conversation_id
241+
)}
242+
/>
243+
<span className="truncate block text-base font-normal text-gray-800 tracking-wide font-sans">
244+
{dialog.conversation_title}
245+
</span>
246+
</Button>
253247
</Tooltip>
254248
</TooltipProvider>
255249

256-
<DropdownMenu
250+
<Dropdown
257251
open={openDropdownId === dialog.conversation_id.toString()}
258252
onOpenChange={(open) =>
259253
onDropdownOpenChange(
260254
open,
261255
dialog.conversation_id.toString()
262256
)
263257
}
264-
>
265-
<DropdownMenuTrigger asChild>
266-
<Button
267-
variant="ghost"
268-
size="icon"
269-
className="h-6 w-6 flex-shrink-0 opacity-0 group-hover:opacity-100 hover:bg-slate-100 hover:border hover:border-slate-200 mr-1 focus:outline-none focus:ring-0"
270-
>
271-
<MoreHorizontal className="h-4 w-4" />
272-
</Button>
273-
</DropdownMenuTrigger>
274-
<DropdownMenuContent align="end" side="bottom">
275-
<DropdownMenuItem
276-
onClick={() =>
258+
menu={{
259+
items: [
260+
{
261+
key: "rename",
262+
label: (
263+
<span className="flex items-center">
264+
<Pencil className="mr-2 h-5 w-5" />
265+
{t("chatLeftSidebar.rename")}
266+
</span>
267+
),
268+
},
269+
{
270+
key: "delete",
271+
label: (
272+
<span className="flex items-center text-red-500">
273+
<Trash2 className="mr-2 h-5 w-5" />
274+
{t("chatLeftSidebar.delete")}
275+
</span>
276+
),
277+
},
278+
],
279+
onClick: ({ key }) => {
280+
if (key === "rename") {
277281
handleStartEdit(
278282
dialog.conversation_id,
279283
dialog.conversation_title
280-
)
284+
);
285+
} else if (key === "delete") {
286+
handleDeleteClick(dialog.conversation_id);
281287
}
282-
>
283-
<Pencil className="mr-2 h-5 w-5" />
284-
{t("chatLeftSidebar.rename")}
285-
</DropdownMenuItem>
286-
<DropdownMenuItem
287-
className="text-red-500 hover:text-red-600 hover:bg-red-50"
288-
onClick={() => handleDeleteClick(dialog.conversation_id)}
289-
>
290-
<Trash2 className="mr-2 h-5 w-5" />
291-
{t("chatLeftSidebar.delete")}
292-
</DropdownMenuItem>
293-
</DropdownMenuContent>
294-
</DropdownMenu>
288+
},
289+
}}
290+
placement="bottomRight"
291+
trigger={["click"]}
292+
>
293+
<Button
294+
type="text"
295+
size="small"
296+
className="h-6 w-6 min-w-[24px] p-0 flex-shrink-0 opacity-0 group-hover:opacity-100 hover:bg-slate-100 hover:border hover:border-slate-200 mr-1 focus:outline-none focus:ring-0 rounded-full transition-opacity duration-200 flex items-center justify-center"
297+
>
298+
<MoreHorizontal className="h-4 w-4" />
299+
</Button>
300+
</Dropdown>
295301
</>
296302
)}
297303
</div>
@@ -309,12 +315,12 @@ export function ChatSidebar({
309315
<TooltipProvider>
310316
<Tooltip title={t("chatLeftSidebar.expandSidebar")} placement="right">
311317
<Button
312-
variant="ghost"
313-
size="icon"
314-
className="h-10 w-10 rounded-full hover:bg-slate-100"
318+
type="text"
319+
size="middle"
320+
className="h-10 w-10 min-w-[40px] p-0 flex-shrink-0 hover:bg-slate-100 active:bg-slate-200 flex items-center justify-center rounded-full transition-colors duration-200"
315321
onClick={onToggleSidebar}
316322
>
317-
<ChevronRight className="h-6 w-6" strokeWidth={2.5} />
323+
<ChevronRight className="h-5 w-5" />
318324
</Button>
319325
</Tooltip>
320326
</TooltipProvider>
@@ -325,12 +331,12 @@ export function ChatSidebar({
325331
<TooltipProvider>
326332
<Tooltip title={t("chatLeftSidebar.newConversation")} placement="right">
327333
<Button
328-
variant="ghost"
329-
size="icon"
330-
className="h-10 w-10 rounded-full hover:bg-slate-100"
334+
type="text"
335+
size="middle"
336+
className="h-10 w-10 min-w-[40px] p-0 flex-shrink-0 hover:bg-slate-100 active:bg-slate-200 flex items-center justify-center rounded-full transition-colors duration-200"
331337
onClick={onNewConversation}
332338
>
333-
<Plus className="h-6 w-6" strokeWidth={2.5} />
339+
<Plus className="h-5 w-5" />
334340
</Button>
335341
</Tooltip>
336342
</TooltipProvider>
@@ -353,8 +359,9 @@ export function ChatSidebar({
353359
<div className="m-4 mt-3">
354360
<div className="flex items-center gap-2">
355361
<Button
356-
variant="outline"
357-
className="flex-1 justify-start text-base overflow-hidden"
362+
type="default"
363+
size="middle"
364+
className="flex-1 justify-start text-base overflow-hidden h-10 border border-slate-300 hover:border-slate-400 hover:bg-white transition-colors duration-200"
358365
onClick={onNewConversation}
359366
>
360367
<Plus
@@ -369,9 +376,9 @@ export function ChatSidebar({
369376
<Tooltip>
370377
<Tooltip title={t("chatLeftSidebar.collapseSidebar")}>
371378
<Button
372-
variant="ghost"
373-
size="icon"
374-
className="h-10 w-10 flex-shrink-0 hover:bg-slate-100"
379+
type="text"
380+
size="middle"
381+
className="h-10 w-10 min-w-[40px] p-0 flex-shrink-0 hover:bg-slate-100 active:bg-slate-200 flex items-center justify-center rounded-full transition-colors duration-200"
375382
onClick={onToggleSidebar}
376383
>
377384
<ChevronLeft className="h-5 w-5" />
@@ -395,7 +402,11 @@ export function ChatSidebar({
395402
<p className="px-2 text-sm font-medium text-muted-foreground">
396403
{t("chatLeftSidebar.recentConversations")}
397404
</p>
398-
<Button variant="ghost" className="w-full justify-start">
405+
<Button
406+
type="text"
407+
size="middle"
408+
className="w-full justify-start flex items-center px-3 py-2 h-auto hover:bg-slate-50 transition-colors duration-200"
409+
>
399410
<Clock className="mr-2 h-5 w-5" />
400411
{t("chatLeftSidebar.noHistory")}
401412
</Button>

frontend/app/[locale]/chat/components/chatRightPanel.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import { useState, useEffect, useRef, useCallback } from "react";
22
import { useTranslation } from "react-i18next";
33
import { ExternalLink, Database, X, Server } from "lucide-react";
44

5-
import { Button } from "@/components/ui/button";
65
import { StaticScrollArea } from "@/components/ui/scrollArea";
76
import { ImageItem, ChatRightPanelProps, SearchResult } from "@/types/chat";
87
import { API_ENDPOINTS } from "@/services/api";
98
import { formatDate, formatUrl } from "@/lib/utils";
109
import { convertImageUrlToApiUrl, extractObjectNameFromUrl, storageService } from "@/services/storageService";
11-
import { message, Tabs } from "antd";
10+
import { message, Button, Tabs } from "antd";
1211
import log from "@/lib/logger";
1312

1413

@@ -95,23 +94,23 @@ export function ChatRightPanel({
9594
try {
9695
// Convert image URL to backend API URL
9796
const apiUrl = convertImageUrlToApiUrl(imageUrl);
98-
97+
9998
// Use backend API to get the image
10099
const response = await fetch(apiUrl);
101-
100+
102101
if (!response.ok) {
103102
throw new Error(`Failed to load image: ${response.statusText}`);
104103
}
105104

106105
// Get image as blob and convert to base64
107106
const blob = await response.blob();
108107
const reader = new FileReader();
109-
108+
110109
reader.onloadend = () => {
111110
const base64Data = reader.result as string;
112111
// Remove data URL prefix (e.g., "data:image/png;base64,")
113112
const base64 = base64Data.split(',')[1] || base64Data;
114-
113+
115114
setImageData((prev) => ({
116115
...prev,
117116
[imageUrl]: {
@@ -123,13 +122,13 @@ export function ChatRightPanel({
123122
}));
124123
loadingImages.current.delete(imageUrl);
125124
};
126-
125+
127126
reader.onerror = () => {
128127
log.error("Failed to read image blob");
129128
handleImageLoadFail(imageUrl);
130129
loadingImages.current.delete(imageUrl);
131130
};
132-
131+
133132
reader.readAsDataURL(blob);
134133
} catch (error) {
135134
log.error(t("chatRightPanel.imageProxyError"), error);
@@ -234,7 +233,7 @@ export function ChatRightPanel({
234233
const handleFileDownload = async (e: React.MouseEvent) => {
235234
e.preventDefault();
236235
e.stopPropagation();
237-
236+
238237
if (!filename && !url) {
239238
message.error(t("chatRightPanel.fileDownloadError", "File name or URL is missing"));
240239
return;
@@ -481,9 +480,9 @@ export function ChatRightPanel({
481480
>
482481
<div className="relative max-w-[90vw] max-h-[90vh]">
483482
<Button
484-
variant="ghost"
485-
size="icon"
486-
className="absolute top-2 right-2 z-50 rounded-full bg-black/50 text-white hover:bg-black/70"
483+
type="text"
484+
size="middle"
485+
className="absolute top-2 right-2 z-50 rounded-full bg-black/50 text-white hover:bg-black/70 h-8 w-8 p-0"
487486
onClick={(e: React.MouseEvent) => {
488487
e.stopPropagation();
489488
setViewingImage(null);
@@ -522,9 +521,9 @@ export function ChatRightPanel({
522521

523522
{toggleRightPanel && (
524523
<Button
525-
variant="ghost"
526-
size="sm"
527-
className="p-1 h-7 w-7 rounded hover:bg-gray-200"
524+
type="text"
525+
size="small"
526+
className="p-0 h-7 w-7 min-w-[28px] rounded hover:bg-gray-200 active:bg-gray-300 flex items-center justify-center transition-colors duration-200"
528527
onClick={toggleRightPanel}
529528
title={t("chatRightPanel.closeSidebarTitle")}
530529
>
@@ -627,10 +626,10 @@ export function ChatRightPanel({
627626
{processedImages.length > maxInitialImages && (
628627
<div className="mt-4 text-center">
629628
<Button
630-
variant="outline"
631-
size="sm"
629+
type="default"
630+
size="small"
632631
onClick={() => setExpandedImages(!expandedImages)}
633-
className="w-full"
632+
className="w-full border border-slate-300 hover:border-slate-400 hover:bg-white transition-colors duration-200"
634633
>
635634
{expandedImages
636635
? t("chatRightPanel.collapseImages")

0 commit comments

Comments
 (0)