From c429649643c09992724914fe86dbe1ec898ace4a Mon Sep 17 00:00:00 2001 From: akshaydeo Date: Tue, 16 Dec 2025 14:50:33 +0530 Subject: [PATCH] increase timeout limit to 48 hours for providers --- .../fragments/networkFormFragment.tsx | 48 ++++++++++++++++++- ui/lib/types/schemas.ts | 2 +- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/ui/app/workspace/providers/fragments/networkFormFragment.tsx b/ui/app/workspace/providers/fragments/networkFormFragment.tsx index 22f33c984..e8515a7ba 100644 --- a/ui/app/workspace/providers/fragments/networkFormFragment.tsx +++ b/ui/app/workspace/providers/fragments/networkFormFragment.tsx @@ -1,7 +1,7 @@ "use client"; import { Button } from "@/components/ui/button"; -import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; +import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; import { HeadersTable } from "@/components/ui/headersTable"; import { Input } from "@/components/ui/input"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; @@ -20,6 +20,37 @@ interface NetworkFormFragmentProps { provider: ModelProvider; } +// seconds to human readable time +const secondsToHumanReadable = (seconds: number) => { + // Handle edge cases + if (!seconds || seconds < 0 || isNaN(seconds)) { + return "0 seconds"; + } + seconds = Math.floor(seconds); + if (seconds < 60) { + return `${seconds} ${seconds === 1 ? "second" : "seconds"}`; + } + if (seconds < 3600) { + const minutes = Math.floor(seconds / 60); + return `${minutes} ${minutes === 1 ? "minute" : "minutes"}`; + } + if (seconds < 86400) { + const hours = Math.floor(seconds / 3600); + return `${hours} ${hours === 1 ? "hour" : "hours"}`; + } + // For >= 1 day, only show non-zero components + const days = Math.floor(seconds / 86400); + const hours = Math.floor((seconds % 86400) / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + const remainingSeconds = seconds % 60; + const parts: string[] = []; + parts.push(`${days} ${days === 1 ? "day" : "days"}`); + if (hours > 0) parts.push(`${hours} ${hours === 1 ? "hour" : "hours"}`); + if (minutes > 0) parts.push(`${minutes} ${minutes === 1 ? "minute" : "minutes"}`); + if (remainingSeconds > 0) parts.push(`${remainingSeconds} ${remainingSeconds === 1 ? "second" : "seconds"}`); + return parts.join(" "); +}; + export function NetworkFormFragment({ provider }: NetworkFormFragmentProps) { const dispatch = useAppDispatch(); const hasUpdateProviderAccess = useRbac(RbacResource.ModelProvider, RbacOperation.Update); @@ -130,8 +161,21 @@ export function NetworkFormFragment({ provider }: NetworkFormFragmentProps) { Timeout (seconds) - field.onChange(Number(e.target.value))} /> + { + if (isNaN(Number(e.target.value))) { + if (e.target.value.trim() === "") { + field.onChange(0); + } + return; + } + field.onChange(Number(e.target.value)); + }} + /> + {secondsToHumanReadable(field.value)} )} diff --git a/ui/lib/types/schemas.ts b/ui/lib/types/schemas.ts index f9070b122..556510551 100644 --- a/ui/lib/types/schemas.ts +++ b/ui/lib/types/schemas.ts @@ -207,7 +207,7 @@ export const networkFormConfigSchema = z default_request_timeout_in_seconds: z.coerce .number("Timeout must be a number") .min(1, "Timeout must be greater than 0 seconds") - .max(3600, "Timeout must be less than 3600 seconds"), + .max(172800, "Timeout must be less than 172800 seconds i.e. 48 hours"), max_retries: z.coerce .number("Max retries must be a number") .min(0, "Max retries must be greater than 0")