Skip to content

Commit

Permalink
Merge branch 'main' into suchintan.add-de-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
suchintan authored Jan 30, 2025
2 parents b1d93fc + 4c50f6f commit 69d53c4
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { EditableNodeTitle } from "../components/EditableNodeTitle";
import { NodeActionMenu } from "../NodeActionMenu";
import { WorkflowBlockIcon } from "../WorkflowBlockIcon";
import type { WaitNode } from "./types";
import { WorkflowBlockInput } from "@/components/WorkflowBlockInput";
import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow";
import { Input } from "@/components/ui/input";

function WaitNode({ id, data }: NodeProps<WaitNode>) {
const { updateNodeData } = useReactFlow();
Expand Down Expand Up @@ -89,18 +89,10 @@ function WaitNode({ id, data }: NodeProps<WaitNode>) {
</div>
) : null}
</div>

<WorkflowBlockInput
nodeId={id}
type="number"
min="1"
max="300"
<Input
value={inputs.waitInSeconds}
onChange={(value) => {
if (!editable) {
return;
}
handleChange("waitInSeconds", Number(value));
onChange={(event) => {
handleChange("waitInSeconds", event.target.value);
}}
className="nopan text-xs"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Node } from "@xyflow/react";
import { NodeBaseData } from "../types";

export type WaitNodeData = NodeBaseData & {
waitInSeconds: number;
waitInSeconds: string;
};

export type WaitNode = Node<WaitNodeData, "wait">;
Expand All @@ -11,7 +11,7 @@ export const waitNodeDefaultData: WaitNodeData = {
label: "",
continueOnFailure: false,
editable: true,
waitInSeconds: 1,
waitInSeconds: "1",
};

export function isWaitNode(node: Node): node is WaitNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import {
isExtractionNode,
} from "./nodes/ExtractionNode/types";
import { loginNodeDefaultData } from "./nodes/LoginNode/types";
import { waitNodeDefaultData } from "./nodes/WaitNode/types";
import { isWaitNode, waitNodeDefaultData } from "./nodes/WaitNode/types";
import { fileDownloadNodeDefaultData } from "./nodes/FileDownloadNode/types";
import { ProxyLocation } from "@/api/types";
import { pdfParserNodeDefaultData } from "./nodes/PDFParserNode/types";
Expand Down Expand Up @@ -301,7 +301,7 @@ function convertToNode(
type: "wait",
data: {
...commonData,
waitInSeconds: block.wait_sec ?? 1,
waitInSeconds: String(block.wait_sec ?? 1),
},
};
}
Expand Down Expand Up @@ -962,7 +962,7 @@ function getWorkflowBlock(node: WorkflowBlockNode): BlockYAML {
return {
...base,
block_type: "wait",
wait_sec: node.data.waitInSeconds,
wait_sec: Number(node.data.waitInSeconds),
};
}
case "fileDownload": {
Expand Down Expand Up @@ -1809,6 +1809,18 @@ function getWorkflowErrors(nodes: Array<AppNode>): Array<string> {
}
});

const waitNodes = nodes.filter(isWaitNode);
waitNodes.forEach((node) => {
const waitTimeString = node.data.waitInSeconds.trim();

const decimalRegex = new RegExp("^\\d+$");
const isNumber = decimalRegex.test(waitTimeString);

if (!isNumber) {
errors.push(`${node.data.label}: Invalid input for wait time.`);
}
});

return errors;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function ActionCard({ action, onClick, active, index }: Props) {
if (element && active) {
element.scrollIntoView({
behavior: "smooth",
block: "center",
block: "start",
});
}
// this should only run once at mount.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function ThoughtCard({ thought, onClick, active }: Props) {
if (element && active) {
element.scrollIntoView({
behavior: "smooth",
block: "center",
block: "start",
});
}
// this should only run once at mount.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { CubeIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
import {
CheckCircledIcon,
CrossCircledIcon,
CubeIcon,
ExternalLinkIcon,
} from "@radix-ui/react-icons";
import { workflowBlockTitle } from "../editor/nodes/types";
import { WorkflowBlockIcon } from "../editor/nodes/WorkflowBlockIcon";
import {
Expand All @@ -15,6 +20,7 @@ import { cn } from "@/util/utils";
import { isTaskVariantBlock } from "../types/workflowTypes";
import { Link } from "react-router-dom";
import { useCallback } from "react";
import { Status } from "@/api/types";

type Props = {
activeItem: WorkflowRunOverviewActiveElement;
Expand Down Expand Up @@ -55,13 +61,23 @@ function WorkflowRunTimelineBlockItem({
) {
element.scrollIntoView({
behavior: "smooth",
block: "center",
block: "start",
});
}
// this should only run once at mount.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const showStatusIndicator = block.status !== null;
const showSuccessIndicator =
showStatusIndicator && block.status === Status.Completed;
const showFailureIndicator =
showStatusIndicator &&
(block.status === Status.Failed ||
block.status === Status.Terminated ||
block.status === Status.TimedOut ||
block.status === Status.Canceled);

return (
<div
className={cn(
Expand All @@ -87,20 +103,32 @@ function WorkflowRunTimelineBlockItem({
/>
<span>{workflowBlockTitle[block.block_type]}</span>
</div>
<div className="flex items-center gap-1 rounded bg-slate-elevation5 px-2 py-1">
{showDiagnosticLink ? (
<Link to={`/tasks/${block.task_id}/diagnostics`}>
<div className="flex gap-1">
<ExternalLinkIcon className="size-4" />
<span className="text-xs">Diagnostics</span>
</div>
</Link>
) : (
<>
<CubeIcon className="size-4" />
<span className="text-xs">Block</span>
</>
<div className="flex gap-2">
{showFailureIndicator && (
<div className="bg-slate-elevation5 px-2 py-1">
<CrossCircledIcon className="size-4 text-destructive" />
</div>
)}
{showSuccessIndicator && (
<div className="bg-slate-elevation5 px-2 py-1">
<CheckCircledIcon className="size-4 text-success" />
</div>
)}
<div className="flex items-center gap-1 rounded bg-slate-elevation5 px-2 py-1">
{showDiagnosticLink ? (
<Link to={`/tasks/${block.task_id}/diagnostics`}>
<div className="flex gap-1">
<ExternalLinkIcon className="size-4" />
<span className="text-xs">Diagnostics</span>
</div>
</Link>
) : (
<>
<CubeIcon className="size-4" />
<span className="text-xs">Block</span>
</>
)}
</div>
</div>
</div>
{block.description ? (
Expand Down

0 comments on commit 69d53c4

Please sign in to comment.