Skip to content

Commit 05e689b

Browse files
authored
fix(agent): export waits for complete workflow state (#889)
* Fix yaml export race condition * Fix env.ts dev
1 parent a3a5bf1 commit 05e689b

File tree

2 files changed

+5
-5
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/export-controls
    • stores/workflows/yaml

2 files changed

+5
-5
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/export-controls/export-controls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ export function ExportControls({ disabled = false }: ExportControlsProps) {
3737
}
3838
}
3939

40-
const handleExportYaml = () => {
40+
const handleExportYaml = async () => {
4141
if (!currentWorkflow || !activeWorkflowId) {
4242
logger.warn('No active workflow to export')
4343
return
4444
}
4545

4646
setIsExporting(true)
4747
try {
48-
const yamlContent = getYaml()
48+
const yamlContent = await getYaml()
4949
const filename = `${currentWorkflow.name.replace(/[^a-z0-9]/gi, '-')}.yaml`
5050

5151
downloadFile(yamlContent, filename, 'text/yaml')

apps/sim/stores/workflows/yaml/store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface WorkflowYamlState {
1313

1414
interface WorkflowYamlActions {
1515
generateYaml: () => Promise<void>
16-
getYaml: () => string
16+
getYaml: () => Promise<string>
1717
refreshYaml: () => void
1818
}
1919

@@ -151,7 +151,7 @@ export const useWorkflowYamlStore = create<WorkflowYamlStore>()(
151151
}
152152
},
153153

154-
getYaml: () => {
154+
getYaml: async () => {
155155
// Initialize subscriptions on first use
156156
initializeSubscriptions()
157157

@@ -160,7 +160,7 @@ export const useWorkflowYamlStore = create<WorkflowYamlStore>()(
160160

161161
// Auto-refresh if data is stale (older than 1 second) or never generated
162162
if (!lastGenerated || currentTime - lastGenerated > 1000) {
163-
get().generateYaml()
163+
await get().generateYaml()
164164
return get().yaml
165165
}
166166

0 commit comments

Comments
 (0)