Skip to content

Commit 3509ce8

Browse files
fix(autolayout): type issue if workflow deployed + remove dead state code (#1524)
* fix(autolayout): type issue if workflow deployed * remove dead code hasActiveWebhook field
1 parent 7aae108 commit 3509ce8

File tree

19 files changed

+14
-111
lines changed

19 files changed

+14
-111
lines changed

apps/sim/app/api/copilot/checkpoints/revert/route.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ describe('Copilot Checkpoints Revert API Route', () => {
237237
parallels: {},
238238
isDeployed: true,
239239
deploymentStatuses: { production: 'deployed' },
240-
hasActiveWebhook: false,
241240
},
242241
}
243242

@@ -287,7 +286,6 @@ describe('Copilot Checkpoints Revert API Route', () => {
287286
parallels: {},
288287
isDeployed: true,
289288
deploymentStatuses: { production: 'deployed' },
290-
hasActiveWebhook: false,
291289
lastSaved: 1640995200000,
292290
},
293291
},
@@ -309,7 +307,6 @@ describe('Copilot Checkpoints Revert API Route', () => {
309307
parallels: {},
310308
isDeployed: true,
311309
deploymentStatuses: { production: 'deployed' },
312-
hasActiveWebhook: false,
313310
lastSaved: 1640995200000,
314311
}),
315312
}
@@ -445,7 +442,6 @@ describe('Copilot Checkpoints Revert API Route', () => {
445442
parallels: {},
446443
isDeployed: false,
447444
deploymentStatuses: {},
448-
hasActiveWebhook: false,
449445
lastSaved: 1640995200000,
450446
})
451447
})
@@ -722,7 +718,6 @@ describe('Copilot Checkpoints Revert API Route', () => {
722718
production: 'deployed',
723719
staging: 'pending',
724720
},
725-
hasActiveWebhook: true,
726721
deployedAt: '2024-01-01T10:00:00.000Z',
727722
},
728723
}
@@ -769,7 +764,6 @@ describe('Copilot Checkpoints Revert API Route', () => {
769764
production: 'deployed',
770765
staging: 'pending',
771766
},
772-
hasActiveWebhook: true,
773767
deployedAt: '2024-01-01T10:00:00.000Z',
774768
lastSaved: 1640995200000,
775769
})

apps/sim/app/api/copilot/checkpoints/revert/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export async function POST(request: NextRequest) {
7373
parallels: checkpointState?.parallels || {},
7474
isDeployed: checkpointState?.isDeployed || false,
7575
deploymentStatuses: checkpointState?.deploymentStatuses || {},
76-
hasActiveWebhook: checkpointState?.hasActiveWebhook || false,
7776
lastSaved: Date.now(),
7877
// Only include deployedAt if it's a valid date string that can be converted
7978
...(checkpointState?.deployedAt &&

apps/sim/app/api/workflows/[id]/deployments/[version]/revert/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export async function POST(
7676
isDeployed: true,
7777
deployedAt: new Date(),
7878
deploymentStatuses: deployedState.deploymentStatuses || {},
79-
hasActiveWebhook: deployedState.hasActiveWebhook || false,
8079
})
8180

8281
if (!saveResult.success) {

apps/sim/app/api/workflows/[id]/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
133133
state: {
134134
// Default values for expected properties
135135
deploymentStatuses: {},
136-
hasActiveWebhook: false,
137136
// Data from normalized tables
138137
blocks: normalizedData.blocks,
139138
edges: normalizedData.edges,

apps/sim/app/api/workflows/[id]/state/route.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,14 @@ const ParallelSchema = z.object({
8989
parallelType: z.enum(['count', 'collection']).optional(),
9090
})
9191

92-
const DeploymentStatusSchema = z.object({
93-
id: z.string(),
94-
status: z.enum(['deploying', 'deployed', 'failed', 'stopping', 'stopped']),
95-
deployedAt: z.date().optional(),
96-
error: z.string().optional(),
97-
})
98-
9992
const WorkflowStateSchema = z.object({
10093
blocks: z.record(BlockStateSchema),
10194
edges: z.array(EdgeSchema),
10295
loops: z.record(LoopSchema).optional(),
10396
parallels: z.record(ParallelSchema).optional(),
10497
lastSaved: z.number().optional(),
10598
isDeployed: z.boolean().optional(),
106-
deployedAt: z.date().optional(),
107-
deploymentStatuses: z.record(DeploymentStatusSchema).optional(),
108-
hasActiveWebhook: z.boolean().optional(),
99+
deployedAt: z.coerce.date().optional(),
109100
})
110101

111102
/**
@@ -204,8 +195,6 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
204195
lastSaved: state.lastSaved || Date.now(),
205196
isDeployed: state.isDeployed || false,
206197
deployedAt: state.deployedAt,
207-
deploymentStatuses: state.deploymentStatuses || {},
208-
hasActiveWebhook: state.hasActiveWebhook || false,
209198
}
210199

211200
const saveResult = await saveWorkflowToNormalizedTables(workflowId, workflowState as any)

apps/sim/app/api/workflows/yaml/export/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export async function GET(request: NextRequest) {
8989
// Use normalized table data - construct state from normalized tables
9090
workflowState = {
9191
deploymentStatuses: {},
92-
hasActiveWebhook: false,
9392
blocks: normalizedData.blocks,
9493
edges: normalizedData.edges,
9594
loops: normalizedData.loops,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/diff-controls.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export function DiffControls() {
8686
lastSaved: rawState.lastSaved || Date.now(),
8787
isDeployed: rawState.isDeployed || false,
8888
deploymentStatuses: rawState.deploymentStatuses || {},
89-
hasActiveWebhook: rawState.hasActiveWebhook || false,
9089
// Only include deployedAt if it's a valid date, never include null/undefined
9190
...(rawState.deployedAt && rawState.deployedAt instanceof Date
9291
? { deployedAt: rawState.deployedAt }

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-current-workflow.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export interface CurrentWorkflow {
1919
deployedAt?: Date
2020
deploymentStatuses?: Record<string, DeploymentStatus>
2121
needsRedeployment?: boolean
22-
hasActiveWebhook?: boolean
2322

2423
// Mode information
2524
isDiffMode: boolean
@@ -66,7 +65,6 @@ export function useCurrentWorkflow(): CurrentWorkflow {
6665
deployedAt: activeWorkflow.deployedAt,
6766
deploymentStatuses: activeWorkflow.deploymentStatuses,
6867
needsRedeployment: activeWorkflow.needsRedeployment,
69-
hasActiveWebhook: activeWorkflow.hasActiveWebhook,
7068

7169
// Mode information - update to reflect ready state
7270
isDiffMode: shouldUseDiff,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/auto-layout.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,19 @@ export async function applyAutoLayoutAndUpdateStore(
204204
useWorkflowStore.getState().updateLastSaved()
205205

206206
// Clean up the workflow state for API validation
207+
// Destructure out UI-only fields that shouldn't be persisted
208+
const { deploymentStatuses, needsRedeployment, dragStartPosition, ...stateToSave } =
209+
newWorkflowState
210+
207211
const cleanedWorkflowState = {
208-
...newWorkflowState,
212+
...stateToSave,
209213
// Convert null dates to undefined (since they're optional)
210-
deployedAt: newWorkflowState.deployedAt ? new Date(newWorkflowState.deployedAt) : undefined,
214+
deployedAt: stateToSave.deployedAt ? new Date(stateToSave.deployedAt) : undefined,
211215
// Ensure other optional fields are properly handled
212-
loops: newWorkflowState.loops || {},
213-
parallels: newWorkflowState.parallels || {},
214-
deploymentStatuses: newWorkflowState.deploymentStatuses || {},
216+
loops: stateToSave.loops || {},
217+
parallels: stateToSave.parallels || {},
215218
// Sanitize edges: remove null/empty handle fields to satisfy schema (optional strings)
216-
edges: (newWorkflowState.edges || []).map((edge: any) => {
219+
edges: (stateToSave.edges || []).map((edge: any) => {
217220
const { sourceHandle, targetHandle, ...rest } = edge || {}
218221
const sanitized: any = { ...rest }
219222
if (typeof sourceHandle === 'string' && sourceHandle.length > 0) {

apps/sim/contexts/socket-context.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
382382
isDeployed: workflowState.isDeployed ?? false,
383383
deployedAt: workflowState.deployedAt,
384384
deploymentStatuses: workflowState.deploymentStatuses || {},
385-
hasActiveWebhook: workflowState.hasActiveWebhook ?? false,
386385
})
387386

388387
// Replace subblock store values for this workflow

0 commit comments

Comments
 (0)