From feca70d7ec371b92dd05db4d8145f22f5f1f5906 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Thu, 6 Jun 2024 12:15:35 -0300 Subject: [PATCH] merge dev --- src/frontend/src/controllers/API/index.ts | 12 ++---------- .../src/customNodes/genericNode/index.tsx | 17 ++--------------- .../components/chatView/chatInput/index.tsx | 7 +++---- .../IOModal/components/chatView/index.tsx | 8 -------- src/frontend/src/stores/flowStore.ts | 18 +++--------------- src/frontend/src/types/api/index.ts | 5 ++--- src/frontend/src/types/chat/index.ts | 6 +++--- src/frontend/src/types/components/index.ts | 5 +++-- src/frontend/src/types/zustand/flow/index.ts | 18 +++++++----------- .../src/types/zustand/flowIOStore/index.ts | 4 ++-- 10 files changed, 27 insertions(+), 73 deletions(-) diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index acebaa476..05e2f84e5 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -964,12 +964,8 @@ export async function getVerticesOrder( export async function postBuildVertex( flowId: string, vertexId: string, -<<<<<<< HEAD input_value: string, - files?: string[], -======= - input_value: string ->>>>>>> dev + files?: string[] ): Promise> { // input_value is optional and is a query parameter const data = { inputs: { input_value: input_value ?? "" } }; @@ -978,11 +974,7 @@ export async function postBuildVertex( } return await api.post( `${BASE_URL_API}build/${flowId}/vertices/${vertexId}`, -<<<<<<< HEAD - data, -======= - input_value ? { inputs: { input_value: input_value } } : undefined ->>>>>>> dev + data ); } diff --git a/src/frontend/src/customNodes/genericNode/index.tsx b/src/frontend/src/customNodes/genericNode/index.tsx index f76f49269..9d16b4e4a 100644 --- a/src/frontend/src/customNodes/genericNode/index.tsx +++ b/src/frontend/src/customNodes/genericNode/index.tsx @@ -22,7 +22,6 @@ import useFlowStore from "../../stores/flowStore"; import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { useTypesStore } from "../../stores/typesStore"; import { APIClassType, VertexBuildTypeAPI } from "../../types/api"; -import { validationStatusType } from "../../types/components"; import { NodeDataType } from "../../types/flow"; import { handleKeyDown, scapedJSONStringfy } from "../../utils/reactflowUtils"; import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; @@ -170,7 +169,7 @@ export default function GenericNode({ // should be empty string if no duration // else should be `Duration: ${duration}` - const getDurationString = (duration: number | undefined|string): string => { + const getDurationString = (duration: number | undefined | string): string => { if (duration === undefined) { return ""; } else { @@ -193,7 +192,7 @@ export default function GenericNode({ ? flowPool[data.id][flowPool[data.id].length - 1] : null; if (relevantData) { - console.log(relevantData) + console.log(relevantData); // Extract validation information from relevantData and update the validationStatus state setValidationStatus(relevantData); } else { @@ -261,11 +260,7 @@ export default function GenericNode({ const isDark = useDarkStore((state) => state.dark); const renderIconStatus = ( buildStatus: BuildStatus | undefined, -<<<<<<< HEAD validationStatus: VertexBuildTypeAPI | null -======= - validationStatus: validationStatusType | null ->>>>>>> dev ) => { if (buildStatus === BuildStatus.BUILDING) { return ; @@ -306,11 +301,7 @@ export default function GenericNode({ }; const getSpecificClassFromBuildStatus = ( buildStatus: BuildStatus | undefined, -<<<<<<< HEAD validationStatus: VertexBuildTypeAPI | null -======= - validationStatus: validationStatusType | null ->>>>>>> dev ) => { let isInvalid = validationStatus && !validationStatus.valid; @@ -334,11 +325,7 @@ export default function GenericNode({ selected: boolean, showNode: boolean, buildStatus: BuildStatus | undefined, -<<<<<<< HEAD validationStatus: VertexBuildTypeAPI | null -======= - validationStatus: validationStatusType | null ->>>>>>> dev ) => { const specificClassFromBuildStatus = getSpecificClassFromBuildStatus( buildStatus, diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx index 6ca07dcc7..4dff635ff 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx @@ -6,8 +6,8 @@ import { import { uploadFile } from "../../../../../controllers/API"; import useFlowsManagerStore from "../../../../../stores/flowsManagerStore"; import { + ChatInputType, FilePreviewType, - chatInputType, } from "../../../../../types/components"; import FilePreview from "../filePreviewChat"; import ButtonSendWrapper from "./components/buttonSendWrapper"; @@ -15,7 +15,6 @@ import TextAreaWrapper from "./components/textAreaWrapper"; import UploadFileButton from "./components/uploadFileButton"; import { getClassNamesFilePreview } from "./helpers/get-class-file-preview"; import useAutoResizeTextArea from "./hooks/use-auto-resize-text-area"; -import useDragAndDrop from "./hooks/use-drag-and-drop"; import useFocusOnUnlock from "./hooks/use-focus-unlock"; import useHandleFileChange from "./hooks/use-handle-file-change"; import useUpload from "./hooks/use-upload"; @@ -29,7 +28,7 @@ export default function ChatInput({ files, setFiles, isDragging, -}: chatInputType): JSX.Element { +}: ChatInputType): JSX.Element { const [repeat, setRepeat] = useState(1); const saveLoading = useFlowsManagerStore((state) => state.saveLoading); const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId); @@ -111,7 +110,7 @@ export default function ChatInput({ key={file.id} onDelete={() => { setFiles((prev: FilePreviewType[]) => - prev.filter((f) => f.id !== file.id), + prev.filter((f) => f.id !== file.id) ); // TODO: delete file on backend }} diff --git a/src/frontend/src/modals/IOModal/components/chatView/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/index.tsx index 8b631e3a7..6899b0c47 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/index.tsx @@ -1,9 +1,6 @@ import { useEffect, useRef, useState } from "react"; import IconComponent from "../../../../components/genericIconComponent"; -<<<<<<< HEAD -======= import { Button } from "../../../../components/ui/button"; ->>>>>>> dev import { CHAT_FIRST_INITIAL_TEXT, CHAT_SECOND_INITIAL_TEXT, @@ -185,15 +182,10 @@ export default function ChatView({ >>>>>> dev )} aria-hidden="true" /> diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 1f000cbc8..bc9e03e8f 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -16,7 +16,7 @@ import { import { BuildStatus } from "../constants/enums"; import { getFlowPool } from "../controllers/API"; import { VertexBuildTypeAPI } from "../types/api"; -import { ChatOutputType, chatInputType } from "../types/chat"; +import { ChatInputType, ChatOutputType } from "../types/chat"; import { NodeDataType, NodeType, @@ -73,11 +73,7 @@ const useFlowStore = create((set, get) => ({ }, updateFlowPool: ( nodeId: string, -<<<<<<< HEAD - data: VertexBuildTypeAPI | ChatOutputType | chatInputType, -======= - data: FlowPoolObjectType | ChatOutputType | chatInputType, ->>>>>>> dev + data: VertexBuildTypeAPI | ChatOutputType | ChatInputType, buildId?: string ) => { let newFlowPool = cloneDeep({ ...get().flowPool }); @@ -96,7 +92,7 @@ const useFlowStore = create((set, get) => ({ else { newFlowPool[nodeId][index].data.message = data as | ChatOutputType - | chatInputType; + | ChatInputType; } } get().setFlowPool(newFlowPool); @@ -492,11 +488,7 @@ const useFlowStore = create((set, get) => ({ (id) => !vertexBuildData.inactivated_vertices?.includes(id) ); const top_level_vertices = vertexBuildData.top_level_vertices.filter( -<<<<<<< HEAD (vertex) => !vertexBuildData.inactivated_vertices?.includes(vertex) -======= - (vertex) => !vertexBuildData.inactivated_vertices?.includes(vertex.id) ->>>>>>> dev ); const nextVertices: VertexLayerElementType[] = zip( next_vertices_ids, @@ -521,11 +513,7 @@ const useFlowStore = create((set, get) => ({ } get().addDataToFlowPool( -<<<<<<< HEAD { ...vertexBuildData, run_id: runId }, -======= - { ...vertexBuildData, buildId: runId }, ->>>>>>> dev vertexBuildData.id ); diff --git a/src/frontend/src/types/api/index.ts b/src/frontend/src/types/api/index.ts index a8a63f881..446c09c86 100644 --- a/src/frontend/src/types/api/index.ts +++ b/src/frontend/src/types/api/index.ts @@ -1,6 +1,5 @@ import { Edge, Node, Viewport } from "reactflow"; -import { ChatOutputType, chatInputType } from "../chat"; -import { Log } from "../components"; +import { ChatInputType, ChatOutputType } from "../chat"; import { FlowType } from "../flow"; //kind and class are just representative names to represent the actual structure of the object received by the API export type APIDataType = { [key: string]: APIKindType }; @@ -162,7 +161,7 @@ export type VertexDataTypeAPI = { results: { [key: string]: string }; artifacts?: { [key: string]: string }; logs: { message: any; type: string }[]; - message: ChatOutputType | chatInputType; + message: ChatOutputType | ChatInputType; inactive?: boolean; timedelta?: number; duration?: string; diff --git a/src/frontend/src/types/chat/index.ts b/src/frontend/src/types/chat/index.ts index c4b322882..72ebb5370 100644 --- a/src/frontend/src/types/chat/index.ts +++ b/src/frontend/src/types/chat/index.ts @@ -22,7 +22,7 @@ export type ChatOutputType = { files?: Array<{ path: string; type: string; name: string }>; }; -export type chatInputType = { +export type ChatInputType = { message: string; sender: string; sender_name: string; @@ -34,7 +34,7 @@ export type FlowPoolObjectType = { timestamp: string; valid: boolean; // list of chat outputs or list of chat inputs - messages: Array | []; - data: { artifacts: any; results: any | ChatOutputType | chatInputType }; + messages: Array | []; + data: { artifacts: any; results: any | ChatOutputType | ChatInputType }; id: string; }; diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index fb07d1f91..221c59697 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -76,6 +76,7 @@ export type InputListComponentType = { disabled: boolean; editNode?: boolean; componentName?: string; + playgroundDisabled?: boolean; }; export type InputGlobalComponentType = { @@ -490,11 +491,11 @@ export type headerFlowsType = { style?: FlowStyleType; }; -export type chatInputType = { +export type ChatInputType = { isDragging: boolean; files: FilePreviewType[]; setFiles: ( - files: FilePreviewType[] | ((prev: FilePreviewType[]) => FilePreviewType[]), + files: FilePreviewType[] | ((prev: FilePreviewType[]) => FilePreviewType[]) ) => void; chatValue: string; inputRef: { diff --git a/src/frontend/src/types/zustand/flow/index.ts b/src/frontend/src/types/zustand/flow/index.ts index d128e4ac2..e8b88e8d3 100644 --- a/src/frontend/src/types/zustand/flow/index.ts +++ b/src/frontend/src/types/zustand/flow/index.ts @@ -9,16 +9,16 @@ import { } from "reactflow"; import { BuildStatus } from "../../../constants/enums"; import { VertexBuildTypeAPI } from "../../api"; -import { ChatOutputType, chatInputType } from "../../chat"; +import { ChatInputType, ChatOutputType } from "../../chat"; import { FlowState } from "../../tabs"; export type FlowPoolObjectType = { timestamp: string; valid: boolean; - messages: Array | []; + messages: Array | []; data: { - artifacts: any | ChatOutputType | chatInputType; - results: any | ChatOutputType | chatInputType; + artifacts: any | ChatOutputType | ChatInputType; + results: any | ChatOutputType | ChatInputType; }; duration?: string; progress?: number; @@ -33,8 +33,8 @@ export type FlowPoolObjectTypeNew = { timestamp: string; valid: boolean; data: { - logs?: any | ChatOutputType | chatInputType; - results: any | ChatOutputType | chatInputType; + logs?: any | ChatOutputType | ChatInputType; + results: any | ChatOutputType | ChatInputType; }; duration?: string; progress?: number; @@ -155,11 +155,7 @@ export type FlowStoreType = { }; updateFlowPool: ( nodeId: string, -<<<<<<< HEAD - data: VertexBuildTypeAPI | ChatOutputType | chatInputType, -======= - data: FlowPoolObjectType | ChatOutputType | chatInputType, ->>>>>>> dev + data: VertexBuildTypeAPI | ChatOutputType | ChatInputType, buildId?: string ) => void; getNodePosition: (nodeId: string) => { x: number; y: number }; diff --git a/src/frontend/src/types/zustand/flowIOStore/index.ts b/src/frontend/src/types/zustand/flowIOStore/index.ts index 65833ced9..54430f88e 100644 --- a/src/frontend/src/types/zustand/flowIOStore/index.ts +++ b/src/frontend/src/types/zustand/flowIOStore/index.ts @@ -1,4 +1,4 @@ -export type chatInputType = { +export type ChatInputType = { result: string; }; @@ -12,7 +12,7 @@ export type FlowPoolObjectType = { timestamp: string; valid: boolean; params: any; - data: { artifacts: any; results: any | ChatOutputType | chatInputType }; + data: { artifacts: any; results: any | ChatOutputType | ChatInputType }; id: string; };