Run Workflow UI: default 'run-with-code' and 'ai-fallback' to true (#3528)
This commit is contained in:
@@ -45,7 +45,6 @@ import { constructCacheKeyValueFromParameters } from "@/routes/workflows/editor/
|
|||||||
import { useWorkflowQuery } from "@/routes/workflows/hooks/useWorkflowQuery";
|
import { useWorkflowQuery } from "@/routes/workflows/hooks/useWorkflowQuery";
|
||||||
import { type ApiCommandOptions } from "@/util/apiCommands";
|
import { type ApiCommandOptions } from "@/util/apiCommands";
|
||||||
import { apiBaseUrl, lsKeys } from "@/util/env";
|
import { apiBaseUrl, lsKeys } from "@/util/env";
|
||||||
import { cn } from "@/util/utils";
|
|
||||||
|
|
||||||
import { MAX_SCREENSHOT_SCROLLS_DEFAULT } from "./editor/nodes/Taskv2Node/types";
|
import { MAX_SCREENSHOT_SCROLLS_DEFAULT } from "./editor/nodes/Taskv2Node/types";
|
||||||
import { getLabelForWorkflowParameterType } from "./editor/workflowEditorUtils";
|
import { getLabelForWorkflowParameterType } from "./editor/workflowEditorUtils";
|
||||||
@@ -276,10 +275,10 @@ function RunWorkflowForm({
|
|||||||
status: "published",
|
status: "published",
|
||||||
});
|
});
|
||||||
|
|
||||||
const [runWithCodeIsEnabled, setRunWithCodeIsEnabled] = useState(false);
|
const [hasCode, setHasCode] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRunWithCodeIsEnabled(Object.keys(blockScripts ?? {}).length > 0);
|
setHasCode(Object.keys(blockScripts ?? {}).length > 0);
|
||||||
}, [blockScripts]);
|
}, [blockScripts]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -309,12 +308,6 @@ function RunWorkflowForm({
|
|||||||
...parameters
|
...parameters
|
||||||
} = values;
|
} = values;
|
||||||
|
|
||||||
const actuallyRunWithCode = !runWithCodeIsEnabled ? false : runWithCode;
|
|
||||||
const actuallyFallbackToAi =
|
|
||||||
!form.getValues().runWithCode || !runWithCodeIsEnabled
|
|
||||||
? false
|
|
||||||
: aiFallback;
|
|
||||||
|
|
||||||
const parsedParameters = parseValuesForWorkflowRun(
|
const parsedParameters = parseValuesForWorkflowRun(
|
||||||
parameters,
|
parameters,
|
||||||
workflowParameters,
|
workflowParameters,
|
||||||
@@ -327,8 +320,8 @@ function RunWorkflowForm({
|
|||||||
maxScreenshotScrolls,
|
maxScreenshotScrolls,
|
||||||
extraHttpHeaders,
|
extraHttpHeaders,
|
||||||
cdpAddress,
|
cdpAddress,
|
||||||
runWithCode: actuallyRunWithCode,
|
runWithCode,
|
||||||
aiFallback: actuallyFallbackToAi,
|
aiFallback,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,35 +523,39 @@ function RunWorkflowForm({
|
|||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
return (
|
return (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<div
|
<div className="flex gap-16">
|
||||||
className={cn("flex gap-16", {
|
|
||||||
"opacity-50": !runWithCodeIsEnabled,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
<div className="w-72">
|
<div className="w-72">
|
||||||
<div className="flex items-center gap-2 text-lg">
|
<div className="flex items-center gap-2 text-lg">
|
||||||
Run With
|
Run With
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-sm text-slate-400">
|
<h2 className="text-sm text-slate-400">
|
||||||
In a past run, code was generated with the input
|
{field.value ? (
|
||||||
parameters you've specified above. Choose to run this
|
hasCode ? (
|
||||||
workflow with that generated code, or with the Skyvern
|
<span>
|
||||||
Agent.
|
Run this workflow with generated code.
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span>
|
||||||
|
Run this workflow with generated code (after it
|
||||||
|
is first generated).
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
) : hasCode ? (
|
||||||
|
<span>
|
||||||
|
Run this workflow with AI. (Even though it has
|
||||||
|
generated code.)
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span>Run this workflow with AI.</span>
|
||||||
|
)}
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<div className="w-full space-y-2">
|
<div className="w-full space-y-2">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Select
|
<Select
|
||||||
disabled={!runWithCodeIsEnabled}
|
value={field.value ? "code" : "ai"}
|
||||||
value={
|
|
||||||
!runWithCodeIsEnabled
|
|
||||||
? "ai"
|
|
||||||
: field.value
|
|
||||||
? "code"
|
|
||||||
: "ai"
|
|
||||||
}
|
|
||||||
onValueChange={(v) =>
|
onValueChange={(v) =>
|
||||||
field.onChange(v === "code" ? true : false)
|
field.onChange(v === "code" ? true : false)
|
||||||
}
|
}
|
||||||
@@ -587,34 +584,24 @@ function RunWorkflowForm({
|
|||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
return (
|
return (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<div
|
<div className="flex gap-16">
|
||||||
className={cn("flex gap-16", {
|
|
||||||
"opacity-50":
|
|
||||||
!form.getValues().runWithCode || !runWithCodeIsEnabled,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
<div className="w-72">
|
<div className="w-72">
|
||||||
<div className="flex items-center gap-2 text-lg">
|
<div className="flex items-center gap-2 text-lg">
|
||||||
AI Fallback (self-healing)
|
AI Fallback (self-healing)
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-sm text-slate-400">
|
<h2 className="text-sm text-slate-400">
|
||||||
If the run fails when using code, turn this on to have
|
If the run fails when running with code, keep this on
|
||||||
AI attempt to fix the issue and regenerate the code.
|
to have AI attempt to fix the issue and regenerate the
|
||||||
|
code.
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<div className="w-full space-y-2">
|
<div className="w-full space-y-2">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Switch
|
<Switch
|
||||||
checked={
|
checked={field.value ?? true}
|
||||||
!form.getValues().runWithCode ||
|
|
||||||
!runWithCodeIsEnabled
|
|
||||||
? false
|
|
||||||
: (field.value as boolean)
|
|
||||||
}
|
|
||||||
onCheckedChange={field.onChange}
|
onCheckedChange={field.onChange}
|
||||||
disabled={!form.getValues().runWithCode}
|
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
|||||||
Reference in New Issue
Block a user