mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-07 22:24:06 -05:00
fix(frozen-canvas): need to fetch the deployment version correctly (#2552)
This commit is contained in:
committed by
GitHub
parent
6c1e4ff7d6
commit
641ac58017
@@ -1,6 +1,9 @@
|
||||
import { BASE_EXECUTION_CHARGE } from '@/lib/billing/constants'
|
||||
import type { ExecutionEnvironment, ExecutionTrigger, WorkflowState } from '@/lib/logs/types'
|
||||
import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/persistence/utils'
|
||||
import {
|
||||
loadDeployedWorkflowState,
|
||||
loadWorkflowFromNormalizedTables,
|
||||
} from '@/lib/workflows/persistence/utils'
|
||||
|
||||
export function createTriggerObject(
|
||||
type: ExecutionTrigger['type'],
|
||||
@@ -47,6 +50,24 @@ export async function loadWorkflowStateForExecution(workflowId: string): Promise
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load deployed workflow state for logging purposes.
|
||||
* This fetches the active deployment state, ensuring logs capture
|
||||
* the exact state that was executed (not the live editor state).
|
||||
*/
|
||||
export async function loadDeployedWorkflowStateForLogging(
|
||||
workflowId: string
|
||||
): Promise<WorkflowState> {
|
||||
const deployedData = await loadDeployedWorkflowState(workflowId)
|
||||
|
||||
return {
|
||||
blocks: deployedData.blocks || {},
|
||||
edges: deployedData.edges || [],
|
||||
loops: deployedData.loops || {},
|
||||
parallels: deployedData.parallels || {},
|
||||
}
|
||||
}
|
||||
|
||||
export function calculateCostSummary(traceSpans: any[]): {
|
||||
totalCost: number
|
||||
totalInputCost: number
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
calculateCostSummary,
|
||||
createEnvironmentObject,
|
||||
createTriggerObject,
|
||||
loadDeployedWorkflowStateForLogging,
|
||||
loadWorkflowStateForExecution,
|
||||
} from '@/lib/logs/execution/logging-factory'
|
||||
import type {
|
||||
@@ -78,7 +79,11 @@ export class LoggingSession {
|
||||
workspaceId,
|
||||
variables
|
||||
)
|
||||
this.workflowState = await loadWorkflowStateForExecution(this.workflowId)
|
||||
// Use deployed state if deploymentVersionId is provided (non-manual execution)
|
||||
// Otherwise fall back to loading from normalized tables (manual/draft execution)
|
||||
this.workflowState = deploymentVersionId
|
||||
? await loadDeployedWorkflowStateForLogging(this.workflowId)
|
||||
: await loadWorkflowStateForExecution(this.workflowId)
|
||||
|
||||
// Only create a new log entry if not resuming
|
||||
if (!skipLogCreation) {
|
||||
@@ -295,7 +300,7 @@ export class LoggingSession {
|
||||
workspaceId,
|
||||
variables
|
||||
)
|
||||
// Minimal workflow state when normalized data is unavailable
|
||||
// Minimal workflow state when normalized/deployed data is unavailable
|
||||
this.workflowState = {
|
||||
blocks: {},
|
||||
edges: [],
|
||||
|
||||
@@ -179,8 +179,8 @@ export async function executeWorkflowCore(
|
||||
userId,
|
||||
workspaceId: providedWorkspaceId,
|
||||
variables,
|
||||
skipLogCreation, // Skip if resuming an existing execution
|
||||
deploymentVersionId, // Only set for deployed executions
|
||||
skipLogCreation,
|
||||
deploymentVersionId,
|
||||
})
|
||||
|
||||
// Process block states with env var substitution using pre-decrypted values
|
||||
|
||||
Reference in New Issue
Block a user