Skip to content

CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.

fix(flow): wire up the chat panel's settings controls

codingFeng101ebad2d85032b
diff --git a/client/workspaces/flow/chat/ChatPanel.tsx b/client/workspaces/flow/chat/ChatPanel.tsx
index 39b4895..fd368f4 100644
--- a/client/workspaces/flow/chat/ChatPanel.tsx
+++ b/client/workspaces/flow/chat/ChatPanel.tsx
@@ -4,12 +4,14 @@ import { useChat } from "@ai-sdk/react"
import {
PanelRightClose,
PanelRightOpen,
+ Settings,
} from "lucide-react"
import type React from "react"
import { useCallback, useEffect, useRef, useState } from "react"
import { Toaster, toast } from "sonner"
import { ButtonWithTooltip } from "@/shared/chat"
import { ChatInput } from "@/workspaces/flow/chat/ChatInput"
+import { SettingsDialog } from "@/workspaces/flow/chat/settings-dialog"
import { STORAGE_KEYS } from "@/workspaces/flow/lib/storage";
import { useDiagram } from "@/workspaces/flow/state/diagram-context"
import { useFlowT } from "@/workspaces/flow/lib/translations"
@@ -153,6 +155,7 @@ export default function ChatPanel({
const { files, pdfData, handleFileChange, setFiles } = useFileProcessor("flow")
const [showHistory, setShowHistory] = useState(false)
+ const [showSettings, setShowSettings] = useState(false)
const [, setAccessCodeRequired] = useState(false)
const [input, setInput] = useState("")
const [dailyRequestLimit, setDailyRequestLimit] = useState(0)
@@ -1312,6 +1315,15 @@ Please fix the XML issues. Ensure cell_id values exist in the current XML and th
</span>
</div>
<div className="flex items-center gap-1">
+ <ButtonWithTooltip
+ tooltipContent={t("chat.settings")}
+ variant="ghost"
+ size="icon"
+ onClick={() => setShowSettings(true)}
+ className="hover:bg-accent"
+ >
+ <Settings className="h-5 w-5 text-muted-foreground" />
+ </ButtonWithTooltip>
{!isMobile && (
<ButtonWithTooltip
tooltipContent={t("chat.panel.hide")}
@@ -1327,6 +1339,16 @@ Please fix the XML issues. Ensure cell_id values exist in the current XML and th
</div>
</header>
+ <SettingsDialog
+ open={showSettings}
+ onOpenChange={setShowSettings}
+ drawioUi={drawioUi}
+ onToggleDrawioUi={onToggleDrawioUi}
+ darkMode={darkMode}
+ onToggleDarkMode={onToggleDarkMode}
+ onCloseProtectionChange={onCloseProtectionChange}
+ />
+
{/* Messages */}
<main className="flex-1 w-full overflow-hidden min-h-0">
<ChatMessageDisplay
diff --git a/client/workspaces/flow/chat/settings-dialog.tsx b/client/workspaces/flow/chat/settings-dialog.tsx
index 398cb9c..c7213a6 100644
--- a/client/workspaces/flow/chat/settings-dialog.tsx
+++ b/client/workspaces/flow/chat/settings-dialog.tsx
@@ -64,7 +64,7 @@ export function SettingsDialog({
}: SettingsDialogProps) {
const t = useFlowT()
const [accessCode, setAccessCode] = useState("")
- const [closeProtection, setCloseProtection] = useState(true)
+ const [closeProtection, setCloseProtection] = useState(false)
const [isVerifying, setIsVerifying] = useState(false)
const [error, setError] = useState("")
const [accessCodeRequired, setAccessCodeRequired] = useState(
@@ -108,7 +108,7 @@ export function SettingsDialog({
const storedCloseProtection = localStorage.getItem(
STORAGE_CLOSE_PROTECTION_KEY,
)
- setCloseProtection(storedCloseProtection !== "false")
+ setCloseProtection(storedCloseProtection === "true")
const { textApiKey, textBaseUrl, textModel, imageApiKey, imageBaseUrl, imageModel } =
getWorkspaceAIConfig()