mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -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 { BASE_EXECUTION_CHARGE } from '@/lib/billing/constants'
|
||||||
import type { ExecutionEnvironment, ExecutionTrigger, WorkflowState } from '@/lib/logs/types'
|
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(
|
export function createTriggerObject(
|
||||||
type: ExecutionTrigger['type'],
|
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[]): {
|
export function calculateCostSummary(traceSpans: any[]): {
|
||||||
totalCost: number
|
totalCost: number
|
||||||
totalInputCost: number
|
totalInputCost: number
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
calculateCostSummary,
|
calculateCostSummary,
|
||||||
createEnvironmentObject,
|
createEnvironmentObject,
|
||||||
createTriggerObject,
|
createTriggerObject,
|
||||||
|
loadDeployedWorkflowStateForLogging,
|
||||||
loadWorkflowStateForExecution,
|
loadWorkflowStateForExecution,
|
||||||
} from '@/lib/logs/execution/logging-factory'
|
} from '@/lib/logs/execution/logging-factory'
|
||||||
import type {
|
import type {
|
||||||
@@ -78,7 +79,11 @@ export class LoggingSession {
|
|||||||
workspaceId,
|
workspaceId,
|
||||||
variables
|
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
|
// Only create a new log entry if not resuming
|
||||||
if (!skipLogCreation) {
|
if (!skipLogCreation) {
|
||||||
@@ -295,7 +300,7 @@ export class LoggingSession {
|
|||||||
workspaceId,
|
workspaceId,
|
||||||
variables
|
variables
|
||||||
)
|
)
|
||||||
// Minimal workflow state when normalized data is unavailable
|
// Minimal workflow state when normalized/deployed data is unavailable
|
||||||
this.workflowState = {
|
this.workflowState = {
|
||||||
blocks: {},
|
blocks: {},
|
||||||
edges: [],
|
edges: [],
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ export async function executeWorkflowCore(
|
|||||||
userId,
|
userId,
|
||||||
workspaceId: providedWorkspaceId,
|
workspaceId: providedWorkspaceId,
|
||||||
variables,
|
variables,
|
||||||
skipLogCreation, // Skip if resuming an existing execution
|
skipLogCreation,
|
||||||
deploymentVersionId, // Only set for deployed executions
|
deploymentVersionId,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Process block states with env var substitution using pre-decrypted values
|
// Process block states with env var substitution using pre-decrypted values
|
||||||
|
|||||||
Reference in New Issue
Block a user