mirror of
https://github.com/stablyai/orca.git
synced 2026-10-25 08:04:05 +00:00
fix(persistence): schedule automation state writes
This commit is contained in:
@@ -2617,6 +2617,7 @@ export class Store {
|
||||
return {
|
||||
state: this.state,
|
||||
flush: () => this.flush(),
|
||||
scheduleSave: () => this.scheduleSave(),
|
||||
recordCreated: () => this.recordFeatureInteraction('automation-created')
|
||||
}
|
||||
}
|
||||
@@ -2625,6 +2626,7 @@ export class Store {
|
||||
return {
|
||||
state: this.state,
|
||||
flush: () => this.flush(),
|
||||
scheduleSave: () => this.scheduleSave(),
|
||||
recordManualRun: () => this.recordFeatureInteraction('automation-run'),
|
||||
getWorkspaceDisplayName: (workspaceId) =>
|
||||
this.getAutomationRunWorkspaceDisplayName(workspaceId)
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
export type AutomationDefinitionOperations = {
|
||||
state: StoreOwnedPersistedState
|
||||
flush: () => void
|
||||
scheduleSave: () => void
|
||||
recordCreated: () => void
|
||||
}
|
||||
|
||||
@@ -67,6 +68,7 @@ export function createAutomation(
|
||||
updatedAt: now
|
||||
}
|
||||
operations.state.automations = [...(operations.state.automations ?? []), automation]
|
||||
operations.scheduleSave()
|
||||
operations.recordCreated()
|
||||
operations.flush()
|
||||
return automation
|
||||
@@ -151,6 +153,7 @@ export function updateAutomation(
|
||||
updatedAt: Date.now()
|
||||
}
|
||||
operations.state.automations[index] = updated
|
||||
operations.scheduleSave()
|
||||
operations.flush()
|
||||
return updated
|
||||
}
|
||||
@@ -162,5 +165,6 @@ export function deleteAutomation(operations: AutomationDefinitionOperations, id:
|
||||
operations.state.automationRuns = (operations.state.automationRuns ?? []).filter(
|
||||
(entry) => entry.automationId !== id
|
||||
)
|
||||
operations.scheduleSave()
|
||||
operations.flush()
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
export type AutomationRunOperations = {
|
||||
state: StoreOwnedPersistedState
|
||||
flush: () => void
|
||||
scheduleSave: () => void
|
||||
recordManualRun: () => void
|
||||
getWorkspaceDisplayName: (workspaceId: string | null | undefined) => string | null
|
||||
}
|
||||
@@ -85,6 +86,7 @@ export function createAutomationRun(
|
||||
if (trigger === 'manual') {
|
||||
operations.recordManualRun()
|
||||
}
|
||||
operations.scheduleSave()
|
||||
operations.flush()
|
||||
return run
|
||||
}
|
||||
@@ -139,6 +141,7 @@ export function updateAutomationRun(
|
||||
automation.lastRunAt = now
|
||||
automation.updatedAt = now
|
||||
}
|
||||
operations.scheduleSave()
|
||||
operations.flush()
|
||||
return updated
|
||||
}
|
||||
@@ -161,6 +164,7 @@ export function snapshotAutomationRunWorkspaceDisplayName(
|
||||
return { ...run, workspaceDisplayName: normalizedDisplayName }
|
||||
})
|
||||
if (updatedCount > 0) {
|
||||
operations.scheduleSave()
|
||||
operations.flush()
|
||||
}
|
||||
return updatedCount
|
||||
|
||||
Reference in New Issue
Block a user