diff --git a/v2/src/pages/MissionWorkspace.tsx b/v2/src/pages/MissionWorkspace.tsx index 6ed3622..34c6bce 100644 --- a/v2/src/pages/MissionWorkspace.tsx +++ b/v2/src/pages/MissionWorkspace.tsx @@ -49,7 +49,7 @@ import { loadDraft, saveDraft, } from "@/services/draft-store"; -import { runMissionCode } from "@/services/runner"; +import { runManualCode, runMissionCode } from "@/services/runner"; import { runMissionAdmin, type MissionSolution, @@ -62,6 +62,7 @@ import { type Attempt, type AttemptKind, type Language, + type ManualRunResult, type RunResult, } from "@/types"; @@ -70,6 +71,7 @@ const MonacoEditor = lazy(() => import("@monaco-editor/react")); type MobilePane = "brief" | "code" | "results"; type BriefTab = "problem" | "hints" | "history" | "solution"; type SaveState = "loading" | "saving" | "synced" | "local" | "error"; +type ManualRunState = "idle" | "running"; const RESULTS_WIDTH_KEY = "tomatin.v3.workspace-results-width"; const MIN_RESULTS_WIDTH = 290; @@ -432,6 +434,10 @@ export function Component() { const [saveState, setSaveState] = useState("loading"); const [saveMessage, setSaveMessage] = useState(""); const [result, setResult] = useState(null); + const [manualOpen, setManualOpen] = useState(false); + const [manualExpression, setManualExpression] = useState(""); + const [manualResult, setManualResult] = useState(null); + const [manualRunning, setManualRunning] = useState("idle"); const [running, setRunning] = useState(null); const [briefTab, setBriefTab] = useState( linkedAttemptId || linkedReviewId ? "history" : "problem", @@ -817,6 +823,19 @@ export function Component() { setRunning(null); } + async function executeManualTest() { + if (language === "cpp" || manualRunning === "running") return; + setManualRunning("running"); + setManualResult(null); + const manual = await runManualCode({ + language, + code: currentCode, + expression: manualExpression, + }); + setManualResult(manual); + setManualRunning("idle"); + } + function clampResultsWidth(nextWidth: number) { const workbenchWidth = workbenchRef.current?.clientWidth ?? 0; const maxWidth = Math.max( @@ -1428,6 +1447,23 @@ export function Component() { ? "Pyodide Worker" : "Web Worker"} + + + + {manualSignatureHints.length > 0 ? ( +

+ Funciones evaluadas en este ejercicio:{" "} + {manualSignatureHints.map((signature, index) => ( + + {index > 0 ? ", " : ""} + {signature} + + ))} +

+ ) : null} +
+ + +
+ {manualResult ? ( +
+ + {manualResult.status === "passed" + ? "Resultado" + : "No se pudo ejecutar"} + +
+
+
Expresión
+
+ {manualResult.expression} +
+
+ {manualResult.value !== undefined ? ( +
+
Valor
+
+ {manualResult.value} +
+
+ ) : null} +
+ {manualResult.stdout || manualResult.stderr ? ( +
+                        {manualResult.stdout ? `$ ${manualResult.stdout}\n` : ""}
+                        {manualResult.stderr
+                          ? `[stderr]\n${manualResult.stderr}`
+                          : ""}
+                      
+ ) : null} +
+ ) : null} + + + ) : null} +