import { AppLayout, Divider, Dropdown, InputField, InputSection, SegmentedControl } from "@elvis/ui"; import ComputationGraph from "./ComputationGraph"; import EvaluationTable from "./EvaluationTable"; import MathText from "./MathText"; import RunResult from "./RunResult"; import TimelineControls from "./TimelineControls"; import type { Mode, RunSettings } from "./types"; import useAutodiff from "./useAutodiff"; import useRunResults from "./useRunResults"; const MODE_OPTIONS: { value: Mode; label: string }[] = [ { value: "forward", label: "Forward" }, { value: "reverse", label: "Reverse" }, ]; function runCaption(run: RunSettings): string { const values = Object.entries(run.inputs).map(([name, value]) => `${name} = ${value}`); return `${values.join(", ")}${run.mode === "forward" ? `, differentiating by ${run.seed}` : ""}`; } export default function App() { const app = useAutodiff(); const prefix = `f(${app.graph?.inputs.join(", ") ?? "x"}) =`; const { flow, state } = app.snapshot; const results = useRunResults(app.graph, app.snapshot); // Labels follow the run on screen, not a control just changed const shownMode = app.run?.mode ?? app.mode; const shownSeed = app.run?.mode === "forward" ? app.run.seed : app.seed; return ( {app.graph && ( <>
{app.inputs.map((input) => ( app.setInput(input.name, text)} error={input.value === null ? "Enter a number." : null} mono /> ))}
{app.runError &&

{app.runError}

}
{app.mode === "forward" && app.graph.inputs.length > 1 && ( )} )} } footer={ <> {app.status === "loading" && (

Loading Python… actions will run once it is ready.

)} {app.status === "failed" &&

Python failed to load.

} } > {app.graph && (
{app.run && (

{shownMode === "forward" ? "Forward" : "Reverse"} mode at

)}
)}
); }