Skip to content

Commit

Permalink
flow editor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Dec 17, 2024
1 parent 33bacb2 commit d8467c4
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 25 deletions.
5 changes: 4 additions & 1 deletion backend/windmill-worker/src/worker_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3146,8 +3146,11 @@ async fn compute_next_flow_transform(
}
/* forloop modules are expected set `iter: { value: Value, index: usize }` as job arguments */
FlowModuleValue::ForloopFlow { modules, modules_node, iterator, parallel, .. } => {
tracing::error!("{:?}", flow_job);
// if it's a simple single step flow, we will collapse it as an optimization and need to pass flow_input as an arg
let is_simple = !parallel && is_simple_modules(&modules, flow.failure_module.as_ref());
let is_simple = !matches!(flow_job.job_kind, JobKind::FlowPreview)
&& !parallel
&& is_simple_modules(&modules, flow.failure_module.as_ref());

// if is_simple {
// match value {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/components/Dev.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@
initialPath: '',
flowInputsStore: writable<FlowInput>({}),
customUi: {},
insertButtonOpen: writable(false)
insertButtonOpen: writable(false),
executionCount: writable(0),
})
setContext<PropPickerContext>('PropPickerContext', {
flowPropPickerConfig: writable<FlowPropPickerConfig | undefined>(undefined),
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/lib/components/FlowBuilder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
export let disabledFlowInputs = false
export let savedPrimarySchedule: ScheduleTrigger | undefined = undefined
export let version: number | undefined = undefined
export let setSavedraftCb: ((cb: () => void) => void) | undefined = undefined
export let setSavedraftCb: ((cb: () => void) => void) | undefined = undefined
// Used by multiplayer deploy collision warning
let deployedValue: Value | undefined = undefined // Value to diff against
Expand Down Expand Up @@ -528,7 +528,8 @@
initialPath,
flowInputsStore: writable<FlowInput>({}),
customUi,
insertButtonOpen
insertButtonOpen,
executionCount: writable(0)
})
setContext<TriggerContext>('TriggerContext', {
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/lib/components/FlowPreviewContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@
runPreview($previewArgs, undefined)
}
const { selectedId, previewArgs, flowStateStore, flowStore, pathStore, initialPath, customUi } =
getContext<FlowEditorContext>('FlowEditorContext')
const {
selectedId,
previewArgs,
flowStateStore,
flowStore,
pathStore,
initialPath,
customUi,
executionCount
} = getContext<FlowEditorContext>('FlowEditorContext')
const dispatch = createEventDispatcher()
function extractFlow(previewMode: 'upTo' | 'whole'): OpenFlow {
Expand Down Expand Up @@ -330,6 +338,10 @@
wideResults
{flowStateStore}
{jobId}
on:done={() => {
console.log('done')
$executionCount = $executionCount + 1
}}
on:jobsLoaded={({ detail }) => {
job = detail
}}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/lib/components/FlowStatusViewerInner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@
j != state?.selectedForloopIndex ||
setManually != state?.selectedForLoopSetManually
if (selectedNotEqual) {
console.log('not equal')
globalState?.update((topLevelModuleStates) => {
topLevelModuleStates[modId] = {
type: 'WaitingForPriorSteps',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
pathStore,
saveDraft,
flowInputsStore,
customUi
customUi,
executionCount
} = getContext<FlowEditorContext>('FlowEditorContext')
export let flowModule: FlowModule
Expand Down Expand Up @@ -107,17 +108,18 @@
$: editor !== undefined && setCopilotModuleEditor()
$: stepPropPicker = failureModule
? getFailureStepPropPicker($flowStateStore, $flowStore, $previewArgs)
: getStepPropPicker(
$flowStateStore,
parentModule,
previousModule,
flowModule.id,
$flowStore,
$previewArgs,
false
)
$: stepPropPicker =
$executionCount != undefined && failureModule
? getFailureStepPropPicker($flowStateStore, $flowStore, $previewArgs)
: getStepPropPicker(
$flowStateStore,
parentModule,
previousModule,
flowModule.id,
$flowStore,
$previewArgs,
false
)
function onKeyDown(event: KeyboardEvent) {
if ((event.ctrlKey || event.metaKey) && event.key == 'Enter') {
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/lib/components/flows/previousResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ function getFlowInput(
if (parentState && parentModule) {
if (
parentState.previewArgs &&
!(parentModule.value?.type === 'forloopflow' && parentModule.value?.modules?.length === 1) &&
parentState &&
typeof parentState.previewArgs == 'object' &&
`iter` in parentState.previewArgs
) {
return { ...topFlowInput, ...parentState.previewArgs }
return {
iter: {
value: "Iteration's value",
index: "Iteration's index"
},
...topFlowInput,
...parentState.previewArgs
}
} else {
let parentFlowInput = getFlowInput(parentModules, flowState, args, schema)
if (parentModule.value.type === 'forloopflow') {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/components/flows/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ export type FlowEditorContext = {
flowInputsStore: Writable<FlowInput>
customUi: FlowBuilderWhitelabelCustomUi
insertButtonOpen: Writable<boolean>
executionCount: Writable<number>
}
8 changes: 5 additions & 3 deletions frontend/src/lib/components/propertyPicker/PropPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@
let filteringFlowInputsOrResult = ''
async function filterPickableProperties() {
if (!$propPickerConfig || !filterActive) {
flowInputsFiltered = pickableProperties.flow_input
resultByIdFiltered = pickableProperties.priorIds
if (search === EMPTY_STRING) {
flowInputsFiltered = pickableProperties.flow_input
resultByIdFiltered = pickableProperties.priorIds
}
filteringFlowInputsOrResult = ''
return
}
Expand Down Expand Up @@ -189,7 +191,7 @@
await updateCollapsable()
}
$: search, $inputMatches, $propPickerConfig, updateState()
$: search, $inputMatches, $propPickerConfig, pickableProperties, updateState()
</script>

<div class="flex flex-col h-full rounded">
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/routes/flows/dev/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
initialPath: '',
flowInputsStore: writable<FlowInput>({}),
customUi: {},
insertButtonOpen: writable(false)
insertButtonOpen: writable(false),
executionCount: writable(0)
})
setContext<PropPickerContext>('PropPickerContext', {
flowPropPickerConfig: writable<FlowPropPickerConfig | undefined>(undefined),
Expand Down

0 comments on commit d8467c4

Please sign in to comment.