duplicated subflow

This commit is contained in:
Adam Gough
2025-09-15 00:18:11 -07:00
parent 2950353952
commit 1e13f6ee75
4 changed files with 21 additions and 11 deletions

View File

@@ -10,8 +10,8 @@ import {
loadWorkflowFromNormalizedTables,
saveWorkflowToNormalizedTables,
} from '@/lib/workflows/db-helpers'
import { sanitizeAgentToolsInBlocks } from '@/lib/workflows/validation'
import { updateBlockReferences } from '@/lib/workflows/reference-utils'
import { sanitizeAgentToolsInBlocks } from '@/lib/workflows/validation'
import { getUserId } from '@/app/api/auth/oauth/utils'
import { getAllBlocks, getBlock } from '@/blocks'
import type { BlockConfig } from '@/blocks/types'
@@ -32,8 +32,6 @@ const YamlWorkflowRequestSchema = z.object({
createCheckpoint: z.boolean().optional().default(false),
})
// moved to shared util in '@/lib/workflows/reference-utils'
/**
* Helper function to create a checkpoint before workflow changes
*/

View File

@@ -5,12 +5,12 @@ import { Handle, type NodeProps, Position, useReactFlow } from 'reactflow'
import { StartIcon } from '@/components/icons'
import { Button } from '@/components/ui/button'
import { Card } from '@/components/ui/card'
import { createLogger } from '@/lib/logs/console/logger'
import { cn } from '@/lib/utils'
import { type DiffStatus, hasDiffStatus } from '@/lib/workflows/diff/types'
import { IterationBadges } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/subflows/components/iteration-badges/iteration-badges'
import { useCurrentWorkflow } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
import { createLogger } from '@/lib/logs/console/logger'
const logger = createLogger('SubflowNode')
@@ -174,7 +174,10 @@ export const SubflowNodeComponent = memo(({ data, id }: NodeProps<SubflowNodeDat
}}
>
{!isPreview && (
<div className='absolute top-2 right-2 z-20 flex gap-1 opacity-0 transition-opacity duration-200 group-hover:opacity-100' style={{ pointerEvents: 'auto' }}>
<div
className='absolute top-2 right-2 z-20 flex gap-1 opacity-0 transition-opacity duration-200 group-hover:opacity-100'
style={{ pointerEvents: 'auto' }}
>
<Button
variant='ghost'
size='sm'

View File

@@ -2,9 +2,9 @@ import { useCallback, useEffect, useRef } from 'react'
import type { Edge } from 'reactflow'
import { useSession } from '@/lib/auth-client'
import { createLogger } from '@/lib/logs/console/logger'
import { updateBlockReferences } from '@/lib/workflows/reference-utils'
import { getBlock } from '@/blocks'
import { resolveOutputType } from '@/blocks/utils'
import { updateBlockReferences } from '@/lib/workflows/reference-utils'
import { useSocket } from '@/contexts/socket-context'
import { registerEmitFunctions, useOperationQueue } from '@/stores/operation-queue/store'
import { useVariablesStore } from '@/stores/panel/variables/store'
@@ -1263,7 +1263,11 @@ export function useCollaborativeWorkflow() {
child.type,
newChildName,
child.position,
{ ...(child.data ? JSON.parse(JSON.stringify(child.data)) : {}), parentId: newParentId, extent: 'parent' },
{
...(child.data ? JSON.parse(JSON.stringify(child.data)) : {}),
parentId: newParentId,
extent: 'parent',
},
newParentId,
'parent',
{
@@ -1290,7 +1294,11 @@ export function useCollaborativeWorkflow() {
type: child.type,
name: newChildName,
position: child.position,
data: { ...(child.data ? JSON.parse(JSON.stringify(child.data)) : {}), parentId: newParentId, extent: 'parent' },
data: {
...(child.data ? JSON.parse(JSON.stringify(child.data)) : {}),
parentId: newParentId,
extent: 'parent',
},
subBlocks: clonedSubBlocks,
outputs: child.outputs ? JSON.parse(JSON.stringify(child.outputs)) : {},
parentId: newParentId,

View File

@@ -38,9 +38,10 @@ export function updateBlockReferences(
return value
} catch (err) {
logger.warn('Failed to update block references', { contextId, error: err instanceof Error ? err.message : String(err) })
logger.warn('Failed to update block references', {
contextId,
error: err instanceof Error ? err.message : String(err),
})
return value
}
}