LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
UN-1722 [FIX] Persist export reminder state across page reloads (#1733)
Athul0bde7ba08c9c
diff --git a/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx b/frontend/src/components/custom-tools/tool-ide/ToolIde.jsxindex 7de5d7078..f24fda5d9 100644--- a/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx+++ b/frontend/src/components/custom-tools/tool-ide/ToolIde.jsx@@ -157,6 +157,19 @@ function ToolIde() {}}, [hasUnsavedChanges, checkDeploymentUsage]);+ // Restore unsaved changes from sessionStorage on page reload+ useEffect(() => {+ if (details?.tool_id) {+ const { restoreUnsavedChangesFromSession } =+ useCustomToolStore.getState();+ const restored = restoreUnsavedChangesFromSession(details.tool_id);+ // Reset the check flag so deployment usage check runs after restore+ if (restored) {+ hasCheckedForCurrentSessionRef.current = false;+ }+ }+ }, [details?.tool_id]);+// Cleanup abort controller on unmountuseEffect(() => {return () => {diff --git a/frontend/src/store/custom-tool-store.js b/frontend/src/store/custom-tool-store.jsindex 04d8b2360..af3d2812a 100644--- a/frontend/src/store/custom-tool-store.js+++ b/frontend/src/store/custom-tool-store.js@@ -2,6 +2,11 @@ import { create } from "zustand";import { promptType } from "../helpers/GetStaticData";+// SessionStorage key prefix for persisting unsaved changes across page reloads+const UNSAVED_CHANGES_KEY_PREFIX = "unstract-unsaved-changes-";+const getSessionStorageKey = (toolId) =>+ `${UNSAVED_CHANGES_KEY_PREFIX}${toolId}`;+const defaultState = {dropdownItems: {},selectedDoc: null,@@ -114,6 +119,14 @@ const useCustomToolStore = create((setState, getState) => ({setState(existingState);},setHasUnsavedChanges: (hasChanges) => {+ const toolId = getState().details?.tool_id;+ if (toolId) {+ if (hasChanges) {+ sessionStorage.setItem(getSessionStorageKey(toolId), "true");+ } else {+ sessionStorage.removeItem(getSessionStorageKey(toolId));+ }+ }setState({ hasUnsavedChanges: hasChanges });},setLastExportedAt: (timestamp) => {@@ -123,11 +136,25 @@ const useCustomToolStore = create((setState, getState) => ({setState({ deploymentUsageInfo: info });},markChangesAsExported: () => {+ const toolId = getState().details?.tool_id;+ if (toolId) {+ sessionStorage.removeItem(getSessionStorageKey(toolId));+ }setState({hasUnsavedChanges: false,lastExportedAt: new Date().toISOString(),});},+ restoreUnsavedChangesFromSession: (toolId) => {+ if (toolId) {+ const savedState = sessionStorage.getItem(getSessionStorageKey(toolId));+ if (savedState === "true") {+ setState({ hasUnsavedChanges: true });+ return true;+ }+ }+ return false;+ },}));export { useCustomToolStore };