diff --git a/apps/rowboat/app/actions/scenario_actions.ts b/apps/rowboat/app/actions/scenario_actions.ts deleted file mode 100644 index ded679dc..00000000 --- a/apps/rowboat/app/actions/scenario_actions.ts +++ /dev/null @@ -1,53 +0,0 @@ -'use server'; -import { ObjectId } from "mongodb"; -import { scenariosCollection } from "../lib/mongodb"; -import { z } from 'zod'; -import { WithStringId } from "../lib/types/types"; -import { Scenario } from "../lib/types/testing_types"; -import { projectAuthCheck } from "./project_actions"; - -export async function getScenarios(projectId: string): Promise>[]> { - await projectAuthCheck(projectId); - - const scenarios = await scenariosCollection.find({ projectId }).toArray(); - return scenarios.map(s => ({ ...s, _id: s._id.toString() })); -} - -export async function createScenario(projectId: string, name: string, description: string): Promise { - await projectAuthCheck(projectId); - - const now = new Date().toISOString(); - const result = await scenariosCollection.insertOne({ - projectId, - name, - description, - context: '', // Always empty string - lastUpdatedAt: now, - createdAt: now, - }); - return result.insertedId.toString(); -} - -export async function updateScenario(projectId: string, scenarioId: string, name: string, description: string) { - await projectAuthCheck(projectId); - - await scenariosCollection.updateOne({ - "_id": new ObjectId(scenarioId), - "projectId": projectId, - }, { - $set: { - name, - description, - lastUpdatedAt: new Date().toISOString(), - } - }); -} - -export async function deleteScenario(projectId: string, scenarioId: string) { - await projectAuthCheck(projectId); - - await scenariosCollection.deleteOne({ - "_id": new ObjectId(scenarioId), - "projectId": projectId, - }); -} diff --git a/apps/rowboat/app/actions/simulation_actions.ts b/apps/rowboat/app/actions/simulation_actions.ts index 2b1e939d..afdd3153 100644 --- a/apps/rowboat/app/actions/simulation_actions.ts +++ b/apps/rowboat/app/actions/simulation_actions.ts @@ -46,6 +46,7 @@ export async function createScenario(projectId: string, name: string, descriptio name, description, context: '', + criteria: '', lastUpdatedAt: now, createdAt: now, }); @@ -56,7 +57,12 @@ export async function createScenario(projectId: string, name: string, descriptio export async function updateScenario( projectId: string, scenarioId: string, - updates: { name?: string; description?: string; context?: string } + updates: { + name?: string; + description?: string; + context?: string; + criteria?: string; + } ): Promise { await projectAuthCheck(projectId); diff --git a/apps/rowboat/app/projects/[projectId]/playground/app.tsx b/apps/rowboat/app/projects/[projectId]/playground/app.tsx index 12014b86..d7b9528a 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/app.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/app.tsx @@ -6,7 +6,6 @@ import { PlaygroundChat } from "../../../lib/types/types"; import { Workflow } from "../../../lib/types/workflow_types"; import { SimulationData } from "../../../lib/types/testing_types"; import { SimulationScenarioData } from "../../../lib/types/testing_types"; -import { SimulateScenarioOption, SimulateURLOption } from "./simulation-options"; import { Chat } from "./chat"; import { useSearchParams, useRouter } from "next/navigation"; import { ActionButton, Pane } from "../workflow/pane"; @@ -36,7 +35,6 @@ export function App({ const initialChatId = useMemo(() => searchParams.get('chatId'), [searchParams]); const [existingChatId, setExistingChatId] = useState(initialChatId); const [loadingChat, setLoadingChat] = useState(false); - const [viewSimulationMenu, setViewSimulationMenu] = useState(false); const [counter, setCounter] = useState(0); const [chat, setChat] = useState>({ projectId, @@ -48,7 +46,7 @@ export function App({ const beginSimulation = useCallback((data: z.infer) => { setExistingChatId(null); - setViewSimulationMenu(false); + setLoadingChat(true); setCounter(counter + 1); setChat({ projectId, @@ -88,7 +86,7 @@ export function App({ function handleNewChatButtonClick() { setExistingChatId(null); - setViewSimulationMenu(false); + setLoadingChat(true); setCounter(counter + 1); setChat({ projectId, @@ -100,7 +98,7 @@ export function App({ } return ( - : "Chat"} actions={[ + } @@ -117,10 +115,10 @@ export function App({ , ]}>
- {!viewSimulationMenu && loadingChat &&
+ {loadingChat &&
} - {!viewSimulationMenu && !loadingChat && } - {viewSimulationMenu && }
); diff --git a/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx b/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx deleted file mode 100644 index ccc2fcba..00000000 --- a/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx +++ /dev/null @@ -1,245 +0,0 @@ -'use client'; - -import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Input, Spinner, Textarea } from "@nextui-org/react"; -import { useState, useEffect } from "react"; -import { getScenarios, createScenario, updateScenario, deleteScenario } from "../../../actions/scenario_actions"; -import { WithStringId } from "../../../lib/types/types"; -import { Scenario } from "../../../lib/types/testing_types"; -import { z } from "zod"; -import { EditableField } from "../../../lib/components/editable-field"; -import { EllipsisVerticalIcon, PlayIcon, PlusIcon } from "lucide-react"; - -export function AddScenarioForm({ - onAdd, -}: { - onAdd: (name: string, description: string) => Promise; -}) { - const [name, setName] = useState(""); - const [description, setDescription] = useState(""); - const [error, setError] = useState(null); - const [saving, setSaving] = useState(false); - - const handleAdd = async () => { - if (!name.trim() || !description.trim()) { - setError("Name and description are required"); - return; - } - - try { - setSaving(true); - await onAdd(name.trim(), description.trim()); - setName(""); - setDescription(""); - setError(null); - } catch (e) { - setError(e instanceof Error ? e.message : "Invalid input"); - } finally { - setSaving(false); - } - }; - - return
-
Add scenario
- setName(e.target.value)} - isInvalid={!!error} - required - /> -