From 1e76b9e1b8a352c03d15dde801e00ca03d2d50a9 Mon Sep 17 00:00:00 2001 From: Li zhongyu <65432159+shifang0511@users.noreply.github.com> Date: Wed, 3 Jun 2026 12:32:41 +0800 Subject: [PATCH] refactor(web): migrate workflow-node-panel-width to useSetLocalStorage (#36983) Co-authored-by: Claude Opus 4.6 Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- eslint-suppressions.json | 3 --- .../nodes/_base/components/workflow-panel/index.tsx | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/eslint-suppressions.json b/eslint-suppressions.json index daab54558c..40255553fd 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -3748,9 +3748,6 @@ } }, "web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx": { - "no-restricted-globals": { - "count": 1 - }, "react/set-state-in-effect": { "count": 2 }, diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx index 80f8c9466d..b53af61683 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx @@ -67,6 +67,7 @@ import { } from '@/app/components/workflow/utils' import { useAppContext } from '@/context/app-context' import { useModalContext } from '@/context/modal-context' +import { useSetLocalStorage } from '@/hooks/use-local-storage' import { useAllBuiltInTools } from '@/service/use-tools' import { useAllTriggerPlugins } from '@/service/use-triggers' import { FlowType } from '@/types/common' @@ -157,6 +158,7 @@ const BasePanel: FC = ({ const setNodePanelWidth = useStore(s => s.setNodePanelWidth) const pendingSingleRun = useStore(s => s.pendingSingleRun) const setPendingSingleRun = useStore(s => s.setPendingSingleRun) + const setNodePanelWidthStorage = useSetLocalStorage('workflow-node-panel-width', { raw: true }) const reservedCanvasWidth = 400 // Reserve the minimum visible width for the canvas @@ -169,10 +171,10 @@ const BasePanel: FC = ({ const newValue = clampNodePanelWidth(width, maxNodePanelWidth) if (source === 'user') - localStorage.setItem('workflow-node-panel-width', `${newValue}`) + setNodePanelWidthStorage(`${newValue}`) setNodePanelWidth(newValue) - }, [maxNodePanelWidth, setNodePanelWidth]) + }, [maxNodePanelWidth, setNodePanelWidth, setNodePanelWidthStorage]) const handleResize = useCallback((width: number) => { updateNodePanelWidth(width, 'user')