Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(deployed-state): use deployed state for API sync and async execs, deployed state modal visual for enabled/disabled#885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5 ...m/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| import { eq } from 'drizzle-orm' | ||
| import { createLogger } from '@/lib/logs/console/logger' | ||
| import { db } from '@/db' | ||
| import { workflowBlocks, workflowEdges, workflowSubflows } from '@/db/schema' | ||
| import type { LoopConfig, WorkflowState } from '@/stores/workflows/workflow/types' | ||
| import { workflow, workflowBlocks, workflowEdges, workflowSubflows } from '@/db/schema' | ||
| import type { WorkflowState } from '@/stores/workflows/workflow/types' | ||
| import { SUBFLOW_TYPES } from '@/stores/workflows/workflow/types' | ||
| const logger = createLogger('WorkflowDBHelpers') | ||
| @@ -12,7 +12,49 @@ export interface NormalizedWorkflowData { | ||
| edges: any[] | ||
| loops: Record<string, any> | ||
| parallels: Record<string, any> | ||
| isFromNormalizedTables: true // Flag to indicate this came from new tables | ||
| isFromNormalizedTables: boolean // Flag to indicate source (true = normalized tables, false = deployed state) | ||
| } | ||
| /** | ||
| * Load deployed workflow state for execution | ||
| * Returns deployed state if available, otherwise throws error | ||
| */ | ||
| export async function loadDeployedWorkflowState( | ||
| workflowId: string | ||
| ): Promise<NormalizedWorkflowData> { | ||
| try { | ||
| // First check if workflow is deployed and get deployed state | ||
| const [workflowResult] = await db | ||
| .select({ | ||
| isDeployed: workflow.isDeployed, | ||
| deployedState: workflow.deployedState, | ||
| }) | ||
| .from(workflow) | ||
| .where(eq(workflow.id, workflowId)) | ||
| .limit(1) | ||
| if (!workflowResult) { | ||
| throw new Error(`Workflow ${workflowId} not found`) | ||
| } | ||
| if (!workflowResult.isDeployed || !workflowResult.deployedState) { | ||
| throw new Error(`Workflow ${workflowId} is not deployed or has no deployed state`) | ||
| } | ||
| const deployedState = workflowResult.deployedState as any | ||
icecrasher321 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // Convert deployed state to normalized format | ||
| return { | ||
| blocks: deployedState.blocks || {}, | ||
| edges: deployedState.edges || [], | ||
| loops: deployedState.loops || {}, | ||
| parallels: deployedState.parallels || {}, | ||
| isFromNormalizedTables: false, // Flag to indicate this came from deployed state | ||
| } | ||
| } catch (error) { | ||
| logger.error(`Error loading deployed workflow state ${workflowId}:`, error) | ||
| throw error | ||
| } | ||
| } | ||
| /** | ||
| @@ -88,7 +130,6 @@ export async function loadWorkflowFromNormalizedTables( | ||
| const config = subflow.config || {} | ||
| if (subflow.type === SUBFLOW_TYPES.LOOP) { | ||
| const loopConfig = config as LoopConfig | ||
| loops[subflow.id] = { | ||
| id: subflow.id, | ||
| ...config, | ||
| @@ -126,7 +167,7 @@ export async function saveWorkflowToNormalizedTables( | ||
| ): Promise<{ success: boolean; jsonBlob?: any; error?: string }> { | ||
| try { | ||
| // Start a transaction | ||
| const result = await db.transaction(async (tx) => { | ||
| await db.transaction(async (tx) => { | ||
| // Clear existing data for this workflow | ||
| await Promise.all([ | ||
| tx.delete(workflowBlocks).where(eq(workflowBlocks.workflowId, workflowId)), | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.