Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): migrate debug-and-preview-panel-width to useSetLocalStorage (#36977)

Li zhongyu7507e9ba6757
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index 8d469849282..d14a78b05a7 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -4679,11 +4679,6 @@
"count": 12
}
},
- "web/app/components/workflow/panel/debug-and-preview/index.tsx": {
- "no-restricted-globals": {
- "count": 1
- }
- },
"web/app/components/workflow/panel/env-panel/variable-modal.tsx": {
"no-restricted-imports": {
"count": 1
diff --git a/web/app/components/workflow/panel/debug-and-preview/index.tsx b/web/app/components/workflow/panel/debug-and-preview/index.tsx
index 4aefec71d5b..6e246df9e11 100644
--- a/web/app/components/workflow/panel/debug-and-preview/index.tsx
+++ b/web/app/components/workflow/panel/debug-and-preview/index.tsx
@@ -19,6 +19,7 @@ import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows
import { useEdgesInteractionsWithoutSync } from '@/app/components/workflow/hooks/use-edges-interactions-without-sync'
import { useNodesInteractionsWithoutSync } from '@/app/components/workflow/hooks/use-nodes-interactions-without-sync'
import { useStore } from '@/app/components/workflow/store'
+import { useSetLocalStorage } from '@/hooks/use-local-storage'
import {
useWorkflowInteractions,
} from '../../hooks'
@@ -54,11 +55,12 @@ const DebugAndPreview = () => {
const nodePanelWidth = useStore(s => s.nodePanelWidth)
const panelWidth = useStore(s => s.previewPanelWidth)
const setPanelWidth = useStore(s => s.setPreviewPanelWidth)
+ const setPanelWidthStorage = useSetLocalStorage<string>('debug-and-preview-panel-width', { raw: true })
const handleResize = useCallback((width: number, source: 'user' | 'system' = 'user') => {
if (source === 'user')
- localStorage.setItem('debug-and-preview-panel-width', `${width}`)
+ setPanelWidthStorage(`${width}`)
setPanelWidth(width)
- }, [setPanelWidth])
+ }, [setPanelWidth, setPanelWidthStorage])
const maxPanelWidth = useMemo(() => {
if (!workflowCanvasWidth)
return 720