SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
refactor: improve asset preview handling and clean up Processing component
Salman-Ahamed4ea23b62de8d
diff --git a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsx b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsxindex e9c428bc..e3000cad 100644--- a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsx+++ b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/PreviewableAsset.tsx@@ -29,9 +29,13 @@ const PreviewableAsset = ({ asset }: { asset: string }) => {try {const mimeType = getMimeTypeFromUrl(asset.trim());if (!mimeType.mimetype) {+ setStateProps((prev) => ({+ ...prev,+ isContentLoaded: true,+ }));return;}- let fileType = getFileCategory(mimeType.mimetype) || '';+ const fileType = getFileCategory(mimeType.mimetype) || '';setStateProps((prev) => ({...prev,fileType,diff --git a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/Processing.tsx b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/Processing.tsxindex 26e6bb61..54c02c8b 100644--- a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/Processing.tsx+++ b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/Processing.tsx@@ -4,7 +4,6 @@ import ResponseView from '@src/react/features/builder/components/endpoint-form-pimport { useEndpointFormPreview } from '@src/react/features/builder/contexts/endpoint-form-preview-sidebar.context';import classNames from 'classnames';import { FC, useEffect, useRef, useState } from 'react';-import { FaCircleCheck, FaCircleXmark } from 'react-icons/fa6';import { PiSpinnerLight } from 'react-icons/pi';/**@@ -14,7 +13,6 @@ const Processing: FC<{ showBackButton?: boolean; onBackButtonClick?: () => voidshowBackButton = true,onBackButtonClick,}) => {- const [buttonRef, setButtonRef] = useState<HTMLButtonElement | null>(null);const [isFormVisible, setIsFormVisible] = useState<boolean>(true);const [contentHeight, setContentHeight] = useState<number | 'auto'>('auto');const formRef = useRef<HTMLDivElement>(null);@@ -48,7 +46,7 @@ const Processing: FC<{ showBackButton?: boolean; onBackButtonClick?: () => void<ArrowLeftIcon className="w-4 h-4 text-smythos-blue-500" /> Skills List</button>)}- <div className={classNames('', view === 'home' && callSkillMutation.isLoading && 'hidden')}>+ <div className={classNames('', callSkillMutation.isLoading && 'hidden')}><buttononClick={() => {if (view === 'view_response') {@@ -85,66 +83,32 @@ const Processing: FC<{ showBackButton?: boolean; onBackButtonClick?: () => void{selectedSkill?.inputsTypes && <FormFill setIsFormVisible={setIsFormVisible} />}</div></div>- {view === 'home' && (+ {callSkillMutation.isLoading && (<div>- {/* {requests.map((request) => ( */}- <button- ref={setButtonRef}- key={selectedSkill.skillId}- className={classNames(- 'bg-slate-100 px-4 py-3 rounded-lg flex items-center justify-between w-full',- (callSkillMutation.isSuccess || callSkillMutation.isError) && 'cursor-pointer',- )}- onClick={() => {- if (callSkillMutation.isSuccess || callSkillMutation.isError) {- setView('view_response');- }- }}- >+ <div className="bg-slate-100 px-4 py-3 rounded-lg flex items-center justify-between w-full"><div className="flex items-center"><span className="icon svg-icon APIEndpoint w-6 mr-2" />-<div className="flex flex-col"><h4 className="font-bold text-[#3E3E3E] text-sm">{selectedSkill.details.name}</h4><p className="text-gray-500 text-xs">{selectedSkill.details.description}</p></div></div>-- <div className="flex flex-col">- {callSkillMutation.isLoading && (- <div className=" p-2 rounded-md flex items-center gap-2">- <span>Processing...</span>- <PiSpinnerLight className="animate-spin" size={18} />- </div>- )}- {callSkillMutation.isSuccess && (- <div className="p-2 rounded-md flex items-center gap-2">- <FaCircleCheck className="text-green-500" size={20} />- </div>- )}- {callSkillMutation.isError && (- <div className="p-2 rounded-md flex items-center gap-2">- <FaCircleXmark className="text-red-500" size={20} />- </div>- )}+ <div className="flex items-center gap-2">+ <span>Processing...</span>+ <PiSpinnerLight className="animate-spin" size={18} /></div>+ </div>+ <button+ onClick={() => {+ abortController.current?.abort();+ callSkillMutation.reset();+ setView('form');+ setIsFormVisible(true);+ }}+ className="bg-transparent font-bold border border-gray-300 text-gray-500 px-4 py-3 rounded-md w-full mt-8"+ >+ Stop Testing</button>- {/* ))} */}-- {callSkillMutation.isLoading && (- // option to cancel the request- <button- onClick={() => {- abortController.current?.abort();- callSkillMutation.reset();- setView('form');- setIsFormVisible(true);- }}- className="bg-transparent font-bold border border-gray-300 text-gray-500 px-4 py-3 rounded-md w-full mt-8"- >- Stop Testing- </button>- )}</div>)}{view === 'view_response' && <ResponseView />}diff --git a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsxindex 1a552c61..9803c655 100644--- a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx+++ b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx@@ -15,15 +15,8 @@ const TEST_FORM_TRY_DEBUG_BUTTON_EXPERIMENT_VARIANTS = {} as const;const ResponseView = () => {- const {- callSkillMutation,- lastFormValues,- abortController,- lastResponse,- mode,- agentSkillErrors,- selectedSkill,- } = useEndpointFormPreview();+ const { callSkillMutation, lastFormValues, lastResponse, mode, agentSkillErrors, selectedSkill } =+ useEndpointFormPreview();const handleDebugClick = async () => {// Toggle debug bar@@ -39,7 +32,6 @@ const ResponseView = () => {const component = componentElement['_control'];if (component && typeof component.openDebugDialog === 'function') {// Fire telemetry event- const { PostHog } = await import('@src/shared/posthog');Observability.observeInteraction('debug_modal_opened', {source: 'test_as_form',});@@ -153,18 +145,6 @@ const ResponseView = () => {return (<div>- {callSkillMutation.isLoading && (- // option to cancel the request- <button- onClick={() => {- abortController.current?.abort();- }}- className="bg-transparent font-bold border border-gray-300 text-gray-500 px-4 py-3 rounded-md w-full mt-4"- >- Stop Testing- </button>- )}-{agentSkillErrors.length > 0 && (<div className="flex flex-col gap-2 mt-4">{agentSkillErrors.map((error) => (