From c3d3afc202a653f7c2163955ce3a25f6eca2a07c Mon Sep 17 00:00:00 2001 From: danqzq Date: Sat, 10 Jan 2026 22:45:52 -0500 Subject: [PATCH 1/2] Remove redundant Close Protection setting --- app/[lang]/page.tsx | 24 ------------------------ components/chat-panel.tsx | 3 --- components/settings-dialog.tsx | 29 ----------------------------- lib/storage.ts | 1 - 4 files changed, 57 deletions(-) diff --git a/app/[lang]/page.tsx b/app/[lang]/page.tsx index 2a6049f..9d1e95a 100644 --- a/app/[lang]/page.tsx +++ b/app/[lang]/page.tsx @@ -4,7 +4,6 @@ import { Suspense, useCallback, useEffect, useRef, useState } from "react" import { DrawIoEmbed } from "react-drawio" import type { ImperativePanelHandle } from "react-resizable-panels" import ChatPanel from "@/components/chat-panel" -import { STORAGE_CLOSE_PROTECTION_KEY } from "@/components/settings-dialog" import { ResizableHandle, ResizablePanel, @@ -29,7 +28,6 @@ export default function Home() { const [darkMode, setDarkMode] = useState(false) const [isLoaded, setIsLoaded] = useState(false) const [isDrawioReady, setIsDrawioReady] = useState(false) - const [closeProtection, setCloseProtection] = useState(false) const chatPanelRef = useRef(null) const isMobileRef = useRef(false) @@ -66,13 +64,6 @@ export default function Home() { document.documentElement.classList.toggle("dark", prefersDark) } - const savedCloseProtection = localStorage.getItem( - STORAGE_CLOSE_PROTECTION_KEY, - ) - if (savedCloseProtection === "true") { - setCloseProtection(true) - } - setIsLoaded(true) }, [pathname, router]) @@ -146,20 +137,6 @@ export default function Home() { return () => window.removeEventListener("keydown", handleKeyDown) }, []) - // Show confirmation dialog when user tries to leave the page - useEffect(() => { - if (!closeProtection) return - - const handleBeforeUnload = (event: BeforeUnloadEvent) => { - event.preventDefault() - return "" - } - - window.addEventListener("beforeunload", handleBeforeUnload) - return () => - window.removeEventListener("beforeunload", handleBeforeUnload) - }, [closeProtection]) - return (
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx index 0dda333..40f4edb 100644 --- a/components/chat-panel.tsx +++ b/components/chat-panel.tsx @@ -70,7 +70,6 @@ interface ChatPanelProps { darkMode: boolean onToggleDarkMode: () => void isMobile?: boolean - onCloseProtectionChange?: (enabled: boolean) => void } // Constants for tool states @@ -111,7 +110,6 @@ export default function ChatPanel({ darkMode, onToggleDarkMode, isMobile = false, - onCloseProtectionChange, }: ChatPanelProps) { const { loadDiagram: onDisplayChart, @@ -1296,7 +1294,6 @@ export default function ChatPanel({ = { interface SettingsDialogProps { open: boolean onOpenChange: (open: boolean) => void - onCloseProtectionChange?: (enabled: boolean) => void drawioUi: "min" | "sketch" onToggleDrawioUi: () => void darkMode: boolean @@ -71,7 +70,6 @@ interface SettingsDialogProps { } export const STORAGE_ACCESS_CODE_KEY = "next-ai-draw-io-access-code" -export const STORAGE_CLOSE_PROTECTION_KEY = "next-ai-draw-io-close-protection" const STORAGE_ACCESS_CODE_REQUIRED_KEY = "next-ai-draw-io-access-code-required" function getStoredAccessCodeRequired(): boolean | null { @@ -84,7 +82,6 @@ function getStoredAccessCodeRequired(): boolean | null { function SettingsContent({ open, onOpenChange, - onCloseProtectionChange, drawioUi, onToggleDrawioUi, darkMode, @@ -97,7 +94,6 @@ function SettingsContent({ const pathname = usePathname() || "/" const search = useSearchParams() const [accessCode, setAccessCode] = useState("") - const [closeProtection, setCloseProtection] = useState(true) const [isVerifying, setIsVerifying] = useState(false) const [error, setError] = useState("") const [accessCodeRequired, setAccessCodeRequired] = useState( @@ -151,12 +147,6 @@ function SettingsContent({ localStorage.getItem(STORAGE_ACCESS_CODE_KEY) || "" setAccessCode(storedCode) - const storedCloseProtection = localStorage.getItem( - STORAGE_CLOSE_PROTECTION_KEY, - ) - // Default to true if not set - setCloseProtection(storedCloseProtection !== "false") - const storedSendShortcut = localStorage.getItem( STORAGE_KEYS.sendShortcut, ) @@ -394,25 +384,6 @@ function SettingsContent({ - {/* Close Protection */} - - { - setCloseProtection(checked) - localStorage.setItem( - STORAGE_CLOSE_PROTECTION_KEY, - checked.toString(), - ) - onCloseProtectionChange?.(checked) - }} - /> - - {/* Diagram Style */} Date: Sat, 10 Jan 2026 22:47:03 -0500 Subject: [PATCH 2/2] Remove Close Protection settings from language dictionaries --- lib/i18n/dictionaries/en.json | 2 -- lib/i18n/dictionaries/ja.json | 2 -- lib/i18n/dictionaries/zh.json | 2 -- 3 files changed, 6 deletions(-) diff --git a/lib/i18n/dictionaries/en.json b/lib/i18n/dictionaries/en.json index 4e43a39..745c9bb 100644 --- a/lib/i18n/dictionaries/en.json +++ b/lib/i18n/dictionaries/en.json @@ -100,8 +100,6 @@ "switchTo": "Switch to", "minimal": "Minimal", "sketch": "Sketch", - "closeProtection": "Close Protection", - "closeProtectionDescription": "Show confirmation when leaving the page.", "diagramStyle": "Diagram Style", "diagramStyleDescription": "Toggle between minimal and styled diagram output.", "sendShortcut": "Send Shortcut", diff --git a/lib/i18n/dictionaries/ja.json b/lib/i18n/dictionaries/ja.json index bfafb62..9f6464d 100644 --- a/lib/i18n/dictionaries/ja.json +++ b/lib/i18n/dictionaries/ja.json @@ -100,8 +100,6 @@ "switchTo": "切り替え", "minimal": "ミニマル", "sketch": "スケッチ", - "closeProtection": "ページ離脱確認", - "closeProtectionDescription": "ページを離れる際に確認を表示します。", "diagramStyle": "ダイアグラムスタイル", "diagramStyleDescription": "ミニマルとスタイル付きの出力を切り替えます。", "sendShortcut": "送信ショートカット", diff --git a/lib/i18n/dictionaries/zh.json b/lib/i18n/dictionaries/zh.json index ce431c8..5fd6df0 100644 --- a/lib/i18n/dictionaries/zh.json +++ b/lib/i18n/dictionaries/zh.json @@ -100,8 +100,6 @@ "switchTo": "切换到", "minimal": "简约", "sketch": "草图", - "closeProtection": "关闭确认", - "closeProtectionDescription": "离开页面时显示确认。", "diagramStyle": "图表样式", "diagramStyleDescription": "切换简约与精致图表输出模式。", "sendShortcut": "发送快捷键",