diff --git a/apps/rowboat/app/actions/scenario_actions.ts b/apps/rowboat/app/actions/scenario_actions.ts index 321dea8b..0f75fc85 100644 --- a/apps/rowboat/app/actions/scenario_actions.ts +++ b/apps/rowboat/app/actions/scenario_actions.ts @@ -20,6 +20,7 @@ export async function createScenario(projectId: string, name: string, descriptio projectId, name, description, + context: '', // Always empty string lastUpdatedAt: now, createdAt: now, }); diff --git a/apps/rowboat/app/actions/simulation_actions.ts b/apps/rowboat/app/actions/simulation_actions.ts index 91cd5db4..58cbb898 100644 --- a/apps/rowboat/app/actions/simulation_actions.ts +++ b/apps/rowboat/app/actions/simulation_actions.ts @@ -44,6 +44,7 @@ export async function createScenario(projectId: string, name: string, descriptio projectId, name, description, + context: '', lastUpdatedAt: now, createdAt: now, }); @@ -54,7 +55,7 @@ export async function createScenario(projectId: string, name: string, descriptio export async function updateScenario( projectId: string, scenarioId: string, - updates: { name?: string; description?: string } + updates: { name?: string; description?: string; context?: string } ): Promise { await projectAuthCheck(projectId); diff --git a/apps/rowboat/app/lib/types.ts b/apps/rowboat/app/lib/types.ts index 82accba1..12d491cf 100644 --- a/apps/rowboat/app/lib/types.ts +++ b/apps/rowboat/app/lib/types.ts @@ -12,12 +12,14 @@ export const Scenario = z.object({ projectId: z.string(), name: z.string().min(1, "Name cannot be empty"), description: z.string().min(1, "Description cannot be empty"), + context: z.string().default(''), createdAt: z.string().datetime(), lastUpdatedAt: z.string().datetime(), }); export const SimulationScenarioData = z.object({ scenario: z.string(), + context: z.string().default(''), }); export const SimulationChatMessagesData = z.object({ diff --git a/apps/rowboat/app/projects/[projectId]/playground/app.tsx b/apps/rowboat/app/projects/[projectId]/playground/app.tsx index a61cc86a..f1ea5e5f 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/app.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/app.tsx @@ -53,6 +53,7 @@ export function App({ messages: [], simulated: true, simulationData: data, + systemMessage: 'context' in data ? data.context : '', }); }, [counter, projectId]); @@ -62,7 +63,10 @@ export function App({ console.log('Scenario Effect triggered:', { scenarioId, projectId }); getScenario(projectId, scenarioId).then((scenario) => { console.log('Scenario data received:', scenario); - beginSimulation(scenario as z.infer); + beginSimulation({ + ...scenario, + systemMessage: scenario.context || '', + } as z.infer); localStorage.removeItem('pendingScenarioId'); }).catch(error => { console.error('Error fetching scenario:', error); diff --git a/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx b/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx index 634fb200..d826cd04 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/scenario-list.tsx @@ -110,6 +110,7 @@ export function ScenarioList({ _id: tmpId, name, description, + context: '', projectId, createdAt: new Date().toISOString(), lastUpdatedAt: new Date().toISOString(), @@ -120,6 +121,7 @@ export function ScenarioList({ _id: id, name, description, + context: '', projectId, createdAt: new Date().toISOString(), lastUpdatedAt: new Date().toISOString(), @@ -135,7 +137,11 @@ export function ScenarioList({ async function handleEditScenario(scenarioId: string, name: string, description: string) { setSaving(true); - setScenarios(scenarios.map(scenario => scenario._id === scenarioId ? { ...scenario, name, description } : scenario)); + setScenarios(scenarios.map(scenario => + scenario._id === scenarioId + ? { ...scenario, name, description, context: scenario.context } + : scenario + )); await updateScenario(projectId, scenarioId, name, description); setSaving(false); } diff --git a/apps/rowboat/app/projects/[projectId]/playground/simulation-options.tsx b/apps/rowboat/app/projects/[projectId]/playground/simulation-options.tsx index 845ee8fb..d7a04e51 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/simulation-options.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/simulation-options.tsx @@ -57,6 +57,7 @@ export function SimulateScenarioOption({ projectId={projectId} onPlay={(scenario) => beginSimulation({ scenario: scenario.description, + context: scenario.context, })} /> ); diff --git a/apps/rowboat/app/projects/[projectId]/simulation/app.tsx b/apps/rowboat/app/projects/[projectId]/simulation/app.tsx index 6c7ad62b..5efe8df5 100644 --- a/apps/rowboat/app/projects/[projectId]/simulation/app.tsx +++ b/apps/rowboat/app/projects/[projectId]/simulation/app.tsx @@ -95,6 +95,7 @@ export default function SimulationApp() { { name: updatedScenario.name, description: updatedScenario.description, + context: updatedScenario.context, } ); // Refresh scenarios list @@ -435,6 +436,13 @@ function ScenarioViewer({
+
+
CONTEXT
+
{scenario.context}
+
+ +
+
DESCRIPTION
{scenario.description}
@@ -454,6 +462,7 @@ function ScenarioEditor({ onCancel: () => void; }) { const [name, setName] = useState(scenario.name); + const [context, setContext] = useState(scenario.context || ''); const [description, setDescription] = useState(scenario.description); const handleSubmit = (e: React.FormEvent) => { @@ -461,6 +470,7 @@ function ScenarioEditor({ onSave({ ...scenario, name, + context, description, }); }; @@ -499,6 +509,18 @@ function ScenarioEditor({
+
+
CONTEXT
+