fix: AI SUGGEST auto-updates after saving preset in manager

Add aiPresetVersion counter. Increment on modal close. AI panel
compares version and calls loadPresets() to sync from localStorage.
This commit is contained in:
2026-07-29 11:45:31 +07:00
parent fa7917cf54
commit 41b5a70a60
3 changed files with 17 additions and 4 deletions
+7 -1
View File
@@ -7466,6 +7466,7 @@ const App = () => {
const [systemManagerModalOpen, setSystemManagerModalOpen] = useState(false); const [systemManagerModalOpen, setSystemManagerModalOpen] = useState(false);
const [aiConfigModalOpen, setAiConfigModalOpen] = useState(false); const [aiConfigModalOpen, setAiConfigModalOpen] = useState(false);
const [aiPresetModalOpen, setAiPresetModalOpen] = useState(false); const [aiPresetModalOpen, setAiPresetModalOpen] = useState(false);
const [aiPresetVersion, setAiPresetVersion] = useState(0);
const [pluginManagerModalOpen, setPluginManagerModalOpen] = useState(false); const [pluginManagerModalOpen, setPluginManagerModalOpen] = useState(false);
const [pluginsData, setPluginsData] = useState(null); const [pluginsData, setPluginsData] = useState(null);
useEffect(() => { useEffect(() => {
@@ -16195,6 +16196,11 @@ const App = () => {
if (window.PromptTemplateManager && !aiPromptMgrRef.current) { if (window.PromptTemplateManager && !aiPromptMgrRef.current) {
aiPromptMgrRef.current = new window.PromptTemplateManager(); aiPromptMgrRef.current = new window.PromptTemplateManager();
} }
// Re-read from localStorage when presets change (e.g., AIPresetModal saved)
if (aiPromptMgrRef.current && window.__aiPresetVersion !== aiPresetVersion) {
window.__aiPresetVersion = aiPresetVersion;
aiPromptMgrRef.current.loadPresets();
}
const promptMgr = aiPromptMgrRef.current; const promptMgr = aiPromptMgrRef.current;
const suggestions = promptMgr ? promptMgr.presets : []; const suggestions = promptMgr ? promptMgr.presets : [];
const handleApplySuggestion = (preset) => { const handleApplySuggestion = (preset) => {
@@ -18322,7 +18328,7 @@ const App = () => {
pluginsData: pluginsData pluginsData: pluginsData
}), /*#__PURE__*/React.createElement(AIPresetModal, { }), /*#__PURE__*/React.createElement(AIPresetModal, {
isOpen: aiPresetModalOpen, isOpen: aiPresetModalOpen,
onClose: () => setAiPresetModalOpen(false) onClose: () => { setAiPresetModalOpen(false); setAiPresetVersion(v => v + 1); }
}), instrumentSelectorTrackId && /*#__PURE__*/React.createElement("div", { }), instrumentSelectorTrackId && /*#__PURE__*/React.createElement("div", {
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm", className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",
onClick: closeInstrumentSelector onClick: closeInstrumentSelector
File diff suppressed because one or more lines are too long
+6
View File
@@ -801,3 +801,9 @@
- **Các file ảnh hưởng:** `app/static/js/app.jsx` - **Các file ảnh hưởng:** `app/static/js/app.jsx`
- **Ghi chú/Test (nếu có):** `npm run build` — build passes. - **Ghi chú/Test (nếu có):** `npm run build` — build passes.
--- ---
### [2026-07-29 11:45] Task: AI SUGGEST auto-update after saving preset in AI Preset Manager
- **Tóm tắt thay đổi:** Thêm `aiPresetVersion` counter, increment khi AIPresetModal đóng. Trong AI panel, so sánh version với `window.__aiPresetVersion`, nếu khác thì gọi `aiPromptMgrRef.current.loadPresets()` để reload từ localStorage.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`
- **Ghi chú/Test (nếu có):** `npm run build` — build passes.
---