Skip to content

Commit e163d02

Browse files
Merge branch 'staging' into feat/byok
2 parents 27bff32 + 40a6bf5 commit e163d02

File tree

34 files changed

+3640
-2358
lines changed

34 files changed

+3640
-2358
lines changed

apps/sim/app/api/copilot/chat/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,6 @@ export async function GET(req: NextRequest) {
10661066
model: chat.model,
10671067
messages: Array.isArray(chat.messages) ? chat.messages : [],
10681068
messageCount: Array.isArray(chat.messages) ? chat.messages.length : 0,
1069-
previewYaml: null, // Not needed for chat list
10701069
planArtifact: chat.planArtifact || null,
10711070
config: chat.config || null,
10721071
createdAt: chat.createdAt,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,20 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
6060
const { loadWorkflowFromNormalizedTables } = await import('@/lib/workflows/persistence/utils')
6161
const normalizedData = await loadWorkflowFromNormalizedTables(id)
6262
if (normalizedData) {
63+
const [workflowRecord] = await db
64+
.select({ variables: workflow.variables })
65+
.from(workflow)
66+
.where(eq(workflow.id, id))
67+
.limit(1)
68+
6369
const currentState = {
6470
blocks: normalizedData.blocks,
6571
edges: normalizedData.edges,
6672
loops: normalizedData.loops,
6773
parallels: normalizedData.parallels,
74+
variables: workflowRecord?.variables || {},
6875
}
69-
const { hasWorkflowChanged } = await import('@/lib/workflows/utils')
76+
const { hasWorkflowChanged } = await import('@/lib/workflows/comparison')
7077
needsRedeployment = hasWorkflowChanged(currentState as any, active.state as any)
7178
}
7279
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
318318
loops: Record<string, any>
319319
parallels: Record<string, any>
320320
deploymentVersionId?: string
321+
variables?: Record<string, any>
321322
} | null = null
322323

323324
let processedInput = input
@@ -327,6 +328,11 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
327328
: await loadDeployedWorkflowState(workflowId)
328329

329330
if (workflowData) {
331+
const deployedVariables =
332+
!shouldUseDraftState && 'variables' in workflowData
333+
? (workflowData as any).variables
334+
: undefined
335+
330336
cachedWorkflowData = {
331337
blocks: workflowData.blocks,
332338
edges: workflowData.edges,
@@ -336,6 +342,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
336342
!shouldUseDraftState && 'deploymentVersionId' in workflowData
337343
? (workflowData.deploymentVersionId as string)
338344
: undefined,
345+
variables: deployedVariables,
339346
}
340347

341348
const serializedWorkflow = new Serializer().serializeWorkflow(
@@ -405,11 +412,13 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
405412
workflowStateOverride: effectiveWorkflowStateOverride,
406413
}
407414

415+
const executionVariables = cachedWorkflowData?.variables ?? workflow.variables ?? {}
416+
408417
const snapshot = new ExecutionSnapshot(
409418
metadata,
410419
workflow,
411420
processedInput,
412-
workflow.variables || {},
421+
executionVariables,
413422
selectedOutputs
414423
)
415424

@@ -471,14 +480,16 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
471480
selectedOutputs,
472481
cachedWorkflowData?.blocks || {}
473482
)
483+
const streamVariables = cachedWorkflowData?.variables ?? (workflow as any).variables
484+
474485
const stream = await createStreamingResponse({
475486
requestId,
476487
workflow: {
477488
id: workflow.id,
478489
userId: actorUserId,
479490
workspaceId,
480491
isDeployed: workflow.isDeployed,
481-
variables: (workflow as any).variables,
492+
variables: streamVariables,
482493
},
483494
input: processedInput,
484495
executingUserId: actorUserId,
@@ -675,11 +686,13 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
675686
workflowStateOverride: effectiveWorkflowStateOverride,
676687
}
677688

689+
const sseExecutionVariables = cachedWorkflowData?.variables ?? workflow.variables ?? {}
690+
678691
const snapshot = new ExecutionSnapshot(
679692
metadata,
680693
workflow,
681694
processedInput,
682-
workflow.variables || {},
695+
sseExecutionVariables,
683696
selectedOutputs
684697
)
685698

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { db, workflowDeploymentVersion } from '@sim/db'
1+
import { db, workflow, workflowDeploymentVersion } from '@sim/db'
22
import { and, desc, eq } from 'drizzle-orm'
33
import type { NextRequest } from 'next/server'
44
import { generateRequestId } from '@/lib/core/utils/request'
55
import { createLogger } from '@/lib/logs/console/logger'
6+
import { hasWorkflowChanged } from '@/lib/workflows/comparison'
67
import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/persistence/utils'
7-
import { hasWorkflowChanged } from '@/lib/workflows/utils'
88
import { validateWorkflowAccess } from '@/app/api/workflows/middleware'
99
import { createErrorResponse, createSuccessResponse } from '@/app/api/workflows/utils'
1010

@@ -22,17 +22,12 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
2222
return createErrorResponse(validation.error.message, validation.error.status)
2323
}
2424

25-
// Check if the workflow has meaningful changes that would require redeployment
2625
let needsRedeployment = false
2726

2827
if (validation.workflow.isDeployed) {
29-
// Get current state from normalized tables (same logic as deployment API)
30-
// Load current state from normalized tables using centralized helper
3128
const normalizedData = await loadWorkflowFromNormalizedTables(id)
3229

3330
if (!normalizedData) {
34-
// Workflow exists but has no blocks in normalized tables (empty workflow or not migrated)
35-
// This is valid state - return success with no redeployment needed
3631
return createSuccessResponse({
3732
isDeployed: validation.workflow.isDeployed,
3833
deployedAt: validation.workflow.deployedAt,
@@ -41,11 +36,18 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
4136
})
4237
}
4338

39+
const [workflowRecord] = await db
40+
.select({ variables: workflow.variables })
41+
.from(workflow)
42+
.where(eq(workflow.id, id))
43+
.limit(1)
44+
4445
const currentState = {
4546
blocks: normalizedData.blocks,
4647
edges: normalizedData.edges,
4748
loops: normalizedData.loops,
4849
parallels: normalizedData.parallels,
50+
variables: workflowRecord?.variables || {},
4951
lastSaved: Date.now(),
5052
}
5153

@@ -69,6 +71,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
6971
return createSuccessResponse({
7072
isDeployed: validation.workflow.isDeployed,
7173
deployedAt: validation.workflow.deployedAt,
74+
isPublished: validation.workflow.isPublished,
7275
needsRedeployment,
7376
})
7477
} catch (error) {

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

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)