diff --git a/ui/litellm-dashboard/src/app/(dashboard)/agents/components/new-session-dialog.tsx b/ui/litellm-dashboard/src/app/(dashboard)/agents/components/new-session-dialog.tsx new file mode 100644 index 00000000000..1721e05f682 --- /dev/null +++ b/ui/litellm-dashboard/src/app/(dashboard)/agents/components/new-session-dialog.tsx @@ -0,0 +1,73 @@ +"use client"; + +/** + * NewSessionDialog — collects a repo URL and provisions a new session under + * an Agent. On success the parent navigates to the three-pane view, status + * pill = `provisioning`. + */ +import { useState } from "react"; +import { Modal, Form, Input, message } from "antd"; +import { createCloudSession } from "@/lib/cloud-agents-client"; +import type { CloudAgentSession } from "@/types/cloud-agents"; + +interface NewSessionDialogProps { + open: boolean; + agentId: string; + accessToken: string | null; + onClose: () => void; + onCreated: (session: CloudAgentSession) => void; +} + +export default function NewSessionDialog({ open, agentId, accessToken, onClose, onCreated }: NewSessionDialogProps) { + const [form] = Form.useForm<{ repo_url: string }>(); + const [submitting, setSubmitting] = useState(false); + + const handleOk = async () => { + try { + const values = await form.validateFields(); + setSubmitting(true); + const session = await createCloudSession(accessToken, { + agent_id: agentId, + repo_url: values.repo_url, + }); + message.success("Session provisioning…"); + form.resetFields(); + onCreated(session); + } catch (e) { + if (e instanceof Error) { + message.error(e.message); + } + } finally { + setSubmitting(false); + } + }; + + return ( + { + form.resetFields(); + onClose(); + }} + okText="Create session" + confirmLoading={submitting} + destroyOnClose + data-testid="new-session-dialog" + > +
+ + + +
+
+ ); +}