Skip to content

Commit 7c2d896

Browse files
Use live workflow run
1 parent b25c43c commit 7c2d896

5 files changed

Lines changed: 12 additions & 115 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/column-sidebar/column-sidebar.tsx

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import type {
4343
WorkflowGroupDependencies,
4444
WorkflowGroupOutput,
4545
} from '@/lib/table'
46+
import { columnTypeForLeaf, deriveOutputColumnName } from '@/lib/table/column-naming'
4647
import {
4748
type FlattenOutputsBlockInput,
4849
type FlattenOutputsEdgeInput,
@@ -52,10 +53,8 @@ import {
5253
import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
5354
import { TriggerUtils } from '@/lib/workflows/triggers/triggers'
5455
import type { InputFormatField } from '@/lib/workflows/types'
55-
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
5656
import { PreviewWorkflow } from '@/app/workspace/[workspaceId]/w/components/preview'
5757
import { getBlock } from '@/blocks'
58-
import { useDeploymentInfo, useDeployWorkflow } from '@/hooks/queries/deployments'
5958
import {
6059
useAddTableColumn,
6160
useAddWorkflowGroup,
@@ -64,7 +63,6 @@ import {
6463
} from '@/hooks/queries/tables'
6564
import { useWorkflowState, workflowKeys } from '@/hooks/queries/workflows'
6665
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
67-
import { columnTypeForLeaf, deriveOutputColumnName } from '@/lib/table/column-naming'
6866
import { COLUMN_TYPE_OPTIONS, type SidebarColumnType } from './column-types'
6967

7068
export type ColumnConfigState =
@@ -582,26 +580,6 @@ export function ColumnSidebar({
582580
open && isWorkflow && selectedWorkflowId ? selectedWorkflowId : undefined
583581
)
584582

585-
/**
586-
* Deployment status of the picked workflow. The sidebar surfaces an inline
587-
* warning row offering one-click (re)deploy, mirroring the badge in the
588-
* group's column header so the user sees the same signal where they're
589-
* configuring the column.
590-
*/
591-
const deploymentInfo = useDeploymentInfo(
592-
open && isWorkflow && selectedWorkflowId ? selectedWorkflowId : null,
593-
{ refetchOnMount: 'always' }
594-
)
595-
const deployState: 'undeployed' | 'redeploy' | null = deploymentInfo.data
596-
? !deploymentInfo.data.isDeployed
597-
? 'undeployed'
598-
: deploymentInfo.data.needsRedeployment
599-
? 'redeploy'
600-
: null
601-
: null
602-
const { mutate: deployWorkflow, isPending: isDeploying } = useDeployWorkflow()
603-
const userPermissions = useUserPermissionsContext()
604-
605583
/**
606584
* Resolves the unified Start block id and its current `inputFormat` field
607585
* names. The "Add inputs" mutation only adds rows for table columns that
@@ -1216,42 +1194,6 @@ export function ColumnSidebar({
12161194
}
12171195
/>
12181196
)}
1219-
{selectedWorkflowId && deployState && (
1220-
<WarningRow
1221-
tone={deployState === 'undeployed' ? 'red' : 'amber'}
1222-
message={
1223-
deployState === 'undeployed'
1224-
? 'Workflow is not deployed'
1225-
: 'Workflow has changes since last deploy'
1226-
}
1227-
action={
1228-
<Tooltip.Root>
1229-
<Tooltip.Trigger asChild>
1230-
<Button
1231-
type='button'
1232-
variant='default'
1233-
size='sm'
1234-
onClick={() => deployWorkflow({ workflowId: selectedWorkflowId })}
1235-
disabled={isDeploying || !userPermissions.canAdmin}
1236-
>
1237-
{isDeploying
1238-
? 'Deploying…'
1239-
: deployState === 'undeployed'
1240-
? 'Deploy'
1241-
: 'Redeploy'}
1242-
</Button>
1243-
</Tooltip.Trigger>
1244-
<Tooltip.Content side='top'>
1245-
{!userPermissions.canAdmin
1246-
? 'Admin permission required to deploy'
1247-
: deployState === 'undeployed'
1248-
? 'Deploy this workflow'
1249-
: 'Redeploy with the latest changes'}
1250-
</Tooltip.Content>
1251-
</Tooltip.Root>
1252-
}
1253-
/>
1254-
)}
12551197
</div>
12561198

12571199
<FieldDivider />

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/table.tsx

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Circle, Square } from 'lucide-react'
55
import { useParams, useRouter } from 'next/navigation'
66
import { usePostHog } from 'posthog-js/react'
77
import {
8-
Badge,
98
Button,
109
Checkbox,
1110
DatePicker,
@@ -23,7 +22,6 @@ import {
2322
ModalFooter,
2423
ModalHeader,
2524
Skeleton,
26-
Tooltip,
2725
Upload,
2826
} from '@/components/emcn'
2927
import {
@@ -61,7 +59,6 @@ import { LogDetails } from '@/app/workspace/[workspaceId]/logs/components'
6159
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
6260
import { ImportCsvDialog } from '@/app/workspace/[workspaceId]/tables/components/import-csv-dialog'
6361
import { getBlock } from '@/blocks'
64-
import { useDeploymentInfo, useDeployWorkflow } from '@/hooks/queries/deployments'
6562
import { useLogByExecutionId } from '@/hooks/queries/logs'
6663
import {
6764
useAddTableColumn,
@@ -3976,8 +3973,8 @@ function ColumnOptionsMenu({
39763973

39773974
/**
39783975
* Spans a fanned-out workflow column group in the table's meta header row.
3979-
* Renders the workflow's color chip + name and a deploy badge so the grouping
3980-
* across N sibling columns reads as one unit.
3976+
* Renders the workflow's color chip + name so the grouping across N sibling
3977+
* columns reads as one unit.
39813978
*/
39823979
function WorkflowGroupMetaCell({
39833980
workflowId,
@@ -4017,16 +4014,6 @@ function WorkflowGroupMetaCell({
40174014
const wf = workflows?.find((w) => w.id === workflowId)
40184015
const color = wf?.color ?? 'var(--text-muted)'
40194016
const name = wf?.name ?? 'Workflow'
4020-
const deploymentInfo = useDeploymentInfo(workflowId, { refetchOnMount: 'always' })
4021-
const deployState: 'undeployed' | 'redeploy' | null = deploymentInfo.data
4022-
? !deploymentInfo.data.isDeployed
4023-
? 'undeployed'
4024-
: deploymentInfo.data.needsRedeployment
4025-
? 'redeploy'
4026-
: null
4027-
: null
4028-
const { mutate: deployWorkflow, isPending: isDeploying } = useDeployWorkflow()
4029-
const userPermissions = useUserPermissionsContext()
40304017

40314018
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false)
40324019
const [optionsMenuPosition, setOptionsMenuPosition] = useState({ x: 0, y: 0 })
@@ -4094,38 +4081,6 @@ function WorkflowGroupMetaCell({
40944081
<span className='min-w-0 truncate font-medium text-[11px] text-[var(--text-secondary)]'>
40954082
{name}
40964083
</span>
4097-
{deployState && (
4098-
<Tooltip.Root>
4099-
<Tooltip.Trigger asChild>
4100-
<Badge
4101-
variant={deployState === 'undeployed' ? 'red' : 'amber'}
4102-
size='sm'
4103-
className={cn(
4104-
'shrink-0 py-0 text-[10px] leading-[14px]',
4105-
userPermissions.canAdmin ? 'cursor-pointer' : 'cursor-not-allowed'
4106-
)}
4107-
dot
4108-
onClick={(e) => {
4109-
e.stopPropagation()
4110-
if (workflowId && !isDeploying && userPermissions.canAdmin) {
4111-
deployWorkflow({ workflowId })
4112-
}
4113-
}}
4114-
>
4115-
{isDeploying ? 'Deploying...' : deployState}
4116-
</Badge>
4117-
</Tooltip.Trigger>
4118-
<Tooltip.Content>
4119-
<span className='text-sm'>
4120-
{!userPermissions.canAdmin
4121-
? 'Admin permission required to deploy'
4122-
: deployState === 'undeployed'
4123-
? 'Click to deploy'
4124-
: 'Click to redeploy'}
4125-
</span>
4126-
</Tooltip.Content>
4127-
</Tooltip.Root>
4128-
)}
41294084
{onRunGroup && (
41304085
<DropdownMenu open={runMenuOpen} onOpenChange={setRunMenuOpen}>
41314086
<DropdownMenuTrigger asChild>

apps/sim/background/workflow-column-execution.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ export async function executeWorkflowGroupCellJob(
8080
.where(eq(workflowTable.id, workflowId))
8181
.limit(1)
8282

83-
if (!workflowRecord || !workflowRecord.isDeployed) {
83+
if (!workflowRecord) {
8484
await writeState({
8585
status: 'error',
8686
executionId,
8787
jobId: null,
8888
workflowId,
89-
error: !workflowRecord ? 'Workflow not found' : 'Workflow is not deployed',
89+
error: 'Workflow not found',
9090
})
9191
return
9292
}
@@ -247,6 +247,11 @@ export async function executeWorkflowGroupCellJob(
247247
executionMode: 'sync',
248248
workflowTriggerType: 'table',
249249
triggerBlockId: startBlock.id,
250+
// Always run the live workflow state — table cells track the
251+
// current editor state rather than the most recent deploy, so
252+
// every save lands in the next row run without forcing the user
253+
// to re-deploy.
254+
useDraftState: true,
250255
abortSignal: signal,
251256
onBlockStart,
252257
onBlockComplete,

apps/sim/lib/copilot/tools/server/table/user-table.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
sanitizeName,
2020
validateMapping,
2121
} from '@/lib/table'
22+
import { columnTypeForLeaf, deriveOutputColumnName } from '@/lib/table/column-naming'
2223
import {
2324
addTableColumn,
2425
addWorkflowGroup,
@@ -53,10 +54,6 @@ import type {
5354
WorkflowGroupDependencies,
5455
WorkflowGroupOutput,
5556
} from '@/lib/table/types'
56-
import {
57-
columnTypeForLeaf,
58-
deriveOutputColumnName,
59-
} from '@/lib/table/column-naming'
6057
import { cancelWorkflowGroupRuns, triggerWorkflowGroupRun } from '@/lib/table/workflow-columns'
6158
import {
6259
downloadWorkspaceFile,

apps/sim/lib/table/column-naming.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ export function deriveOutputColumnName(path: string, taken: Set<string>): string
4242
* a superset (`array`, `object`, etc.); anything outside the column-type
4343
* union falls back to `json`, the most permissive shape that still validates.
4444
*/
45-
export function columnTypeForLeaf(
46-
leafType: string | undefined
47-
): ColumnDefinition['type'] {
45+
export function columnTypeForLeaf(leafType: string | undefined): ColumnDefinition['type'] {
4846
switch (leafType) {
4947
case 'string':
5048
case 'number':

0 commit comments

Comments
 (0)