feat: add LANGFLOW_AUTO_SAVING_INTERVAL .env variable for flow auto-saving debounce (#3478)
* 📝 (langflow): Add support for configuring auto saving interval for Langflow 📝 (langflow): Update ConfigResponse and Settings to include auto_saving_interval 📝 (frontend): Update useGetConfigQuery and useSaveConfig to handle auto_saving_interval 📝 (frontend): Update useAutoSaveFlow and flowsManagerStore to handle auto saving interval * 📝 (util.py): add support for setting auto_saving_interval in update_settings function to allow customization of auto-saving interval
This commit is contained in:
parent
8dd85d98b6
commit
1db1e3af3d
9 changed files with 28 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import { UseRequestProcessor } from "../../services/request-processor";
|
|||
export interface ConfigResponse {
|
||||
frontend_timeout: number;
|
||||
auto_saving: boolean;
|
||||
auto_saving_interval: number;
|
||||
}
|
||||
|
||||
export const useGetConfigQuery: useQueryFunctionType<
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { SAVE_DEBOUNCE_TIME } from "@/constants/constants";
|
||||
import useFlowsManagerStore from "@/stores/flowsManagerStore";
|
||||
import { FlowType } from "@/types/flow";
|
||||
import { useDebounce } from "../use-debounce";
|
||||
|
|
@ -7,12 +6,15 @@ import useSaveFlow from "./use-save-flow";
|
|||
const useAutoSaveFlow = () => {
|
||||
const saveFlow = useSaveFlow();
|
||||
const autoSaving = useFlowsManagerStore((state) => state.autoSaving);
|
||||
const autoSavingInterval = useFlowsManagerStore(
|
||||
(state) => state.autoSavingInterval,
|
||||
);
|
||||
|
||||
const autoSaveFlow = useDebounce((flow?: FlowType) => {
|
||||
if (autoSaving) {
|
||||
saveFlow(flow);
|
||||
}
|
||||
}, SAVE_DEBOUNCE_TIME);
|
||||
}, autoSavingInterval);
|
||||
|
||||
return autoSaveFlow;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import { useGetConfigQuery } from "../controllers/API/queries/config/use-get-con
|
|||
function useSaveConfig() {
|
||||
const { data } = useGetConfigQuery();
|
||||
const setAutoSaving = useFlowsManagerStore((state) => state.setAutoSaving);
|
||||
const setAutoSavingInterval = useFlowsManagerStore(
|
||||
(state) => state.setAutoSavingInterval,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
|
|
@ -15,6 +18,7 @@ function useSaveConfig() {
|
|||
axios.defaults.baseURL = "";
|
||||
axios.defaults.timeout = timeoutInMilliseconds;
|
||||
setAutoSaving(data.auto_saving);
|
||||
setAutoSavingInterval(data.auto_saving_interval);
|
||||
}
|
||||
}, [data]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { SAVE_DEBOUNCE_TIME } from "@/constants/constants";
|
||||
import { cloneDeep } from "lodash";
|
||||
import { create } from "zustand";
|
||||
import { FlowType } from "../types/flow";
|
||||
|
|
@ -18,6 +19,9 @@ const future = {};
|
|||
const useFlowsManagerStore = create<FlowsManagerStoreType>((set, get) => ({
|
||||
autoSaving: true,
|
||||
setAutoSaving: (autoSaving: boolean) => set({ autoSaving }),
|
||||
autoSavingInterval: SAVE_DEBOUNCE_TIME,
|
||||
setAutoSavingInterval: (autoSavingInterval: number) =>
|
||||
set({ autoSavingInterval }),
|
||||
examples: [],
|
||||
setExamples: (examples: FlowType[]) => {
|
||||
set({ examples });
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ export type FlowsManagerStoreType = {
|
|||
searchFlowsComponents: string;
|
||||
selectedFlowsComponentsCards: string[];
|
||||
setSelectedFlowsComponentsCards: (selected: string[]) => void;
|
||||
autoSavingInterval: number;
|
||||
setAutoSavingInterval: (autoSavingInterval: number) => void;
|
||||
};
|
||||
|
||||
export type UseUndoRedoOptions = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue