diff --git a/webui/src/App.jsx b/webui/src/App.jsx index beba622..be5dffe 100644 --- a/webui/src/App.jsx +++ b/webui/src/App.jsx @@ -188,7 +188,7 @@ function AppCore() { const [applyStatus, setApplyStatus] = useState(null); // null | 'saving' | 'restarting' | 'done' | 'timeout' | 'error' const [applyError, setApplyError] = useState(''); - const { flushAll, hasDirty } = useDraftConfig(); + const { flushAll, hasDirty, clearAllDirty } = useDraftConfig(); const handleApply = useCallback(async () => { setApplyError(''); @@ -231,10 +231,11 @@ function AppCore() { }, [flushAll, hasDirty]); const handleCancel = useCallback(async () => { + clearAllDirty(); await cellAPI.cancelPending(); setPending({ needs_restart: false, changes: [] }); window.dispatchEvent(new CustomEvent('pic-config-discarded')); - }, []); + }, [clearAllDirty]); const [activeServiceChildren, setActiveServiceChildren] = useState([]); @@ -327,7 +328,7 @@ function AppCore() { )} - {isOnline && pending.needs_restart && !applyStatus && ( + {isOnline && (pending.needs_restart || hasDirty()) && !applyStatus && ( )} diff --git a/webui/src/contexts/DraftConfigContext.jsx b/webui/src/contexts/DraftConfigContext.jsx index 10955c0..e2f1e10 100644 --- a/webui/src/contexts/DraftConfigContext.jsx +++ b/webui/src/contexts/DraftConfigContext.jsx @@ -25,8 +25,12 @@ export function DraftConfigProvider({ children }) { await Promise.all(flushers.map(fn => fn())); }, []); + const clearAllDirty = useCallback(() => { + hasDirtyRef.current = {}; + }, []); + return ( - + {children} );