From c9d9dd257c178512772aee2721c09a6c1d5086c0 Mon Sep 17 00:00:00 2001 From: Biki Kalita <86558912+Biki-dev@users.noreply.github.com> Date: Sat, 27 Dec 2025 20:27:48 +0530 Subject: [PATCH] fix: move History and Download buttons to Settings dialog for cleaner chat interface --- components/chat-input.tsx | 114 +++-------- components/chat-panel.tsx | 4 +- components/settings-dialog.tsx | 360 ++++++++++++++++++++------------- lib/i18n/dictionaries/en.json | 6 +- lib/i18n/dictionaries/ja.json | 6 +- lib/i18n/dictionaries/zh.json | 6 +- 6 files changed, 259 insertions(+), 237 deletions(-) diff --git a/components/chat-input.tsx b/components/chat-input.tsx index 774b6f2..1094cde 100644 --- a/components/chat-input.tsx +++ b/components/chat-input.tsx @@ -1,22 +1,15 @@ "use client" -import { - Download, - History, - Image as ImageIcon, - Loader2, - Send, - Trash2, -} from "lucide-react" +import { Image as ImageIcon, Loader2, Send, Trash2 } from "lucide-react" import type React from "react" import { useCallback, useEffect, useRef, useState } from "react" import { toast } from "sonner" import { ButtonWithTooltip } from "@/components/button-with-tooltip" import { ErrorToast } from "@/components/error-toast" -import { HistoryDialog } from "@/components/history-dialog" + import { ModelSelector } from "@/components/model-selector" import { ResetWarningModal } from "@/components/reset-warning-modal" -import { SaveDialog } from "@/components/save-dialog" + import { Button } from "@/components/ui/button" import { Switch } from "@/components/ui/switch" import { Textarea } from "@/components/ui/textarea" @@ -25,7 +18,7 @@ import { TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip" -import { useDiagram } from "@/contexts/diagram-context" + import { useDictionary } from "@/hooks/use-dictionary" import { formatMessage } from "@/lib/i18n/utils" import { isPdfFile, isTextFile } from "@/lib/pdf-utils" @@ -152,8 +145,7 @@ interface ChatInputProps { File, { text: string; charCount: number; isExtracting: boolean } > - showHistory?: boolean - onToggleHistory?: (show: boolean) => void + sessionId?: string error?: Error | null minimalStyle?: boolean @@ -175,9 +167,7 @@ export function ChatInput({ files = [], onFileChange = () => {}, pdfData = new Map(), - showHistory = false, - onToggleHistory = () => {}, - sessionId, + error = null, minimalStyle = false, onMinimalStyleChange = () => {}, @@ -188,12 +178,7 @@ export function ChatInput({ onConfigureModels = () => {}, }: ChatInputProps) { const dict = useDictionary() - const { - diagramHistory, - saveDiagramToFile, - showSaveDialog, - setShowSaveDialog, - } = useDiagram() + const textareaRef = useRef(null) const fileInputRef = useRef(null) const [isDragging, setIsDragging] = useState(false) @@ -386,11 +371,6 @@ export function ChatInput({ onClear={handleClear} /> - -
@@ -421,63 +401,29 @@ export function ChatInput({
- onToggleHistory(true)} - disabled={isDisabled || diagramHistory.length === 0} - tooltipContent={dict.chat.diagramHistory} - className="h-8 w-8 p-0 text-muted-foreground hover:text-foreground" - > - - - - setShowSaveDialog(true)} - disabled={isDisabled} - tooltipContent={dict.chat.saveDiagram} - className="h-8 w-8 p-0 text-muted-foreground hover:text-foreground" - > - - - - - saveDiagramToFile(filename, format, sessionId) - } - defaultFilename={`diagram-${new Date() - .toISOString() - .slice(0, 10)}`} - /> - - - - - - +
+ + + + +
-
- +
+ {error && ( +

+ {error} +

+ )}
-
- - setAccessCode(e.target.value) - } - onKeyDown={handleKeyDown} - placeholder={ - dict.settings.accessCodePlaceholder - } - autoComplete="off" - className="h-9" - /> - + + + {/* Draw.io Style */} + + + + + {/* Close Protection */} + + { + setCloseProtection(checked) + localStorage.setItem( + STORAGE_CLOSE_PROTECTION_KEY, + checked.toString(), + ) + onCloseProtectionChange?.(checked) + }} + /> + + + {/* Diagram Actions */} + +
+ +
- {error && ( -

- {error} -

- )} -
- )} - - {/* Language */} - - - - - {/* Theme */} - - - - - {/* Draw.io Style */} - - - - - {/* Close Protection */} - - { - setCloseProtection(checked) - localStorage.setItem( - STORAGE_CLOSE_PROTECTION_KEY, - checked.toString(), - ) - onCloseProtectionChange?.(checked) - }} - /> - + + - - {/* Footer */} -
-

- Version {process.env.APP_VERSION} -

-
- + {/* Footer */} +
+

+ Version {process.env.APP_VERSION} +

+
+ + ;( + + ) + + ) } diff --git a/lib/i18n/dictionaries/en.json b/lib/i18n/dictionaries/en.json index 26557fe..342b887 100644 --- a/lib/i18n/dictionaries/en.json +++ b/lib/i18n/dictionaries/en.json @@ -98,7 +98,11 @@ "minimal": "Minimal", "sketch": "Sketch", "closeProtection": "Close Protection", - "closeProtectionDescription": "Show confirmation when leaving the page." + "closeProtectionDescription": "Show confirmation when leaving the page.", + "diagramActions": "Diagram Actions", + "diagramActionsDescription": "Manage diagram history and exports", + "history": "History", + "download": "Download" }, "save": { "title": "Save Diagram", diff --git a/lib/i18n/dictionaries/ja.json b/lib/i18n/dictionaries/ja.json index 39bdac0..123722c 100644 --- a/lib/i18n/dictionaries/ja.json +++ b/lib/i18n/dictionaries/ja.json @@ -98,7 +98,11 @@ "minimal": "ミニマル", "sketch": "スケッチ", "closeProtection": "ページ離脱確認", - "closeProtectionDescription": "ページを離れる際に確認を表示します。" + "closeProtectionDescription": "ページを離れる際に確認を表示します。", + "diagramActions": "ダイアグラム操作", + "diagramActionsDescription": "ダイアグラムの履歴とエクスポートを管理", + "history": "履歴", + "download": "ダウンロード" }, "save": { "title": "ダイアグラムを保存", diff --git a/lib/i18n/dictionaries/zh.json b/lib/i18n/dictionaries/zh.json index b7868c4..b306ee1 100644 --- a/lib/i18n/dictionaries/zh.json +++ b/lib/i18n/dictionaries/zh.json @@ -98,7 +98,11 @@ "minimal": "简约", "sketch": "草图", "closeProtection": "关闭确认", - "closeProtectionDescription": "离开页面时显示确认。" + "closeProtectionDescription": "离开页面时显示确认。", + "diagramActions": "图表操作", + "diagramActionsDescription": "管理图表历史记录和导出", + "history": "历史记录", + "download": "下载" }, "save": { "title": "保存图表",