diff --git a/gui/src/app/App.tsx b/gui/src/app/App.tsx index 67a3efa9..a068ad44 100644 --- a/gui/src/app/App.tsx +++ b/gui/src/app/App.tsx @@ -4,6 +4,7 @@ import ProjectContextProvider from "@SpCore/ProjectContextProvider"; import HomePage from "@SpPages/HomePage"; import { Analytics } from "@vercel/analytics/react"; import { BrowserRouter } from "react-router-dom"; +import { CompileContextProvider } from "./CompileContext/CompileContextProvider"; const theme = createTheme(); @@ -13,7 +14,9 @@ function App() {
- + + +
diff --git a/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx b/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx index f1a2620d..3ff84156 100644 --- a/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx +++ b/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx @@ -3,15 +3,22 @@ import { Cancel, Check } from "@mui/icons-material"; import CloseableDialog, { useDialogControls, } from "@SpComponents/CloseableDialog"; -import { FunctionComponent, useCallback, useEffect, useState } from "react"; +import { + FunctionComponent, + useCallback, + useContext, + useEffect, + useState, +} from "react"; import ConfigureCompilationServerDialog from "./ConfigureCompilationServerDialog"; import IconButton from "@mui/material/IconButton"; import Typography from "@mui/material/Typography"; +import { CompileContext } from "@SpCompileContext/CompileContext"; export const publicUrl = "https://trom-stan-wasm-server.magland.org"; export const localUrl = "http://localhost:8083"; -export type ServerType = "public" | "local" | "custom"; +type ServerType = "public" | "local" | "custom"; type CompilationServerConnectionControlProps = { // none @@ -20,22 +27,8 @@ type CompilationServerConnectionControlProps = { const CompilationServerConnectionControl: FunctionComponent< CompilationServerConnectionControlProps > = () => { - const [stanWasmServerUrl, setStanWasmServerUrl] = useState( - localStorage.getItem("stanWasmServerUrl") || publicUrl, - ); - - const [serverType, setServerType] = useState( - stanWasmServerUrl === publicUrl - ? "public" - : stanWasmServerUrl === localUrl - ? "local" - : "custom", - ); - + const { stanWasmServerUrl } = useContext(CompileContext); const { isConnected, retryConnection } = useIsConnected(stanWasmServerUrl); - useEffect(() => { - localStorage.setItem("stanWasmServerUrl", stanWasmServerUrl); - }, [stanWasmServerUrl]); const { handleOpen: openDialog, @@ -47,6 +40,8 @@ const CompilationServerConnectionControl: FunctionComponent< retryConnection(); }, [retryConnection]); + const serverType = serverTypeForUrl(stanWasmServerUrl); + return ( <> @@ -68,18 +63,18 @@ const CompilationServerConnectionControl: FunctionComponent< handleClose={closeDialog} > ); }; +export const serverTypeForUrl = (url: string): ServerType => { + return url === publicUrl ? "public" : url === localUrl ? "local" : "custom"; +}; + const useIsConnected = (stanWasmServerUrl: string) => { const probeUrl = `${stanWasmServerUrl}/probe`; const [isConnected, setIsConnected] = useState(false); @@ -89,6 +84,11 @@ const useIsConnected = (stanWasmServerUrl: string) => { }, []); useEffect(() => { setIsConnected(false); + if (!probeUrl.startsWith("http://") && !probeUrl.startsWith("https://")) { + // important to do this check because otherwise fetch may succeed because + // the server of this web app may respond with success + return; + } (async () => { try { const response = await fetch(probeUrl); diff --git a/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx b/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx index a170bb13..095cbafa 100644 --- a/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx +++ b/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx @@ -1,38 +1,33 @@ -import { FunctionComponent, useCallback } from "react"; -import { - localUrl, - publicUrl, - ServerType, -} from "./CompilationServerConnectionControl"; -import FormControl from "@mui/material/FormControl"; +import { CompileContext } from "@SpCompileContext/CompileContext"; +import { Refresh } from "@mui/icons-material"; import Divider from "@mui/material/Divider"; -import FormLabel from "@mui/material/FormLabel"; -import RadioGroup from "@mui/material/RadioGroup"; +import FormControl from "@mui/material/FormControl"; import FormControlLabel from "@mui/material/FormControlLabel"; +import FormLabel from "@mui/material/FormLabel"; +import IconButton from "@mui/material/IconButton"; import Radio from "@mui/material/Radio"; +import RadioGroup from "@mui/material/RadioGroup"; import TextField from "@mui/material/TextField"; -import IconButton from "@mui/material/IconButton"; -import { Refresh } from "@mui/icons-material"; +import { FunctionComponent, useCallback, useContext } from "react"; +import { + localUrl, + publicUrl, + serverTypeForUrl, +} from "./CompilationServerConnectionControl"; type ConfigureCompilationServerDialogProps = { - stanWasmServerUrl: string; - setStanWasmServerUrl: (url: string) => void; isConnected: boolean; onRetry: () => void; - choice: ServerType; - setChoice: (choice: ServerType) => void; }; const ConfigureCompilationServerDialog: FunctionComponent< ConfigureCompilationServerDialogProps -> = ({ - stanWasmServerUrl, - setStanWasmServerUrl, - isConnected, - onRetry, - choice, - setChoice, -}) => { +> = ({ isConnected, onRetry }) => { + const { stanWasmServerUrl, setStanWasmServerUrl } = + useContext(CompileContext); + + const serverType = serverTypeForUrl(stanWasmServerUrl); + const makeChoice = useCallback( (_: unknown, choice: string) => { if (choice === "public") { @@ -44,9 +39,8 @@ const ConfigureCompilationServerDialog: FunctionComponent< } else { return; } - setChoice(choice); }, - [setChoice, setStanWasmServerUrl], + [setStanWasmServerUrl], ); return ( @@ -73,7 +67,7 @@ const ConfigureCompilationServerDialog: FunctionComponent< Compilation server - + } @@ -91,13 +85,13 @@ const ConfigureCompilationServerDialog: FunctionComponent< /> - {choice === "custom" && ( + {serverType === "custom" && (

setStanWasmServerUrl(e.target.value)} /> @@ -106,7 +100,7 @@ const ConfigureCompilationServerDialog: FunctionComponent< )} - {choice === "local" && ( + {serverType === "local" && (

To start a local compilation server{" "} @@ -119,7 +113,7 @@ const ConfigureCompilationServerDialog: FunctionComponent<

)} - {choice === "public" && ( + {serverType === "public" && (

The public server ({publicUrl}) is diff --git a/gui/src/app/CompileContext/CompileContext.ts b/gui/src/app/CompileContext/CompileContext.ts new file mode 100644 index 00000000..cfd9d01e --- /dev/null +++ b/gui/src/app/CompileContext/CompileContext.ts @@ -0,0 +1,29 @@ +import { createContext } from "react"; + +export type CompileStatus = + | "preparing" + | "compiling" + | "compiled" + | "failed" + | ""; + +type CompileContextType = { + compileStatus: CompileStatus; + compileMessage: string; + compiledMainJsUrl?: string; + validSyntax: boolean; + compile: () => void; + setValidSyntax: (valid: boolean) => void; + stanWasmServerUrl: string; + setStanWasmServerUrl: (url: string) => void; +}; + +export const CompileContext = createContext({ + compileStatus: "", + compileMessage: "", + validSyntax: false, + compile: () => {}, + setValidSyntax: () => {}, + stanWasmServerUrl: "", + setStanWasmServerUrl: () => {}, +}); diff --git a/gui/src/app/CompileContext/CompileContextProvider.tsx b/gui/src/app/CompileContext/CompileContextProvider.tsx new file mode 100644 index 00000000..5f2c5d04 --- /dev/null +++ b/gui/src/app/CompileContext/CompileContextProvider.tsx @@ -0,0 +1,102 @@ +import { ProjectContext } from "@SpCore/ProjectContextProvider"; +import compileStanProgram from "@SpCompileContext/compileStanProgram"; +import { + FunctionComponent, + PropsWithChildren, + useCallback, + useContext, + useEffect, + useState, +} from "react"; +import { CompileContext, CompileStatus } from "./CompileContext"; + +type CompileContextProviderProps = { + // none +}; + +const initialStanWasmServerUrl = + localStorage.getItem("stanWasmServerUrl") || + "https://trom-stan-wasm-server.magland.org"; + +export const CompileContextProvider: FunctionComponent< + PropsWithChildren +> = ({ children }) => { + const { data } = useContext(ProjectContext); + const [compileStatus, setCompileStatus] = useState(""); + const [ + theStanFileContentThasHasBeenCompiled, + setTheStanFileContentThasHasBeenCompiled, + ] = useState(""); + const [compileMessage, setCompileMessage] = useState(""); + const [compiledMainJsUrl, setCompiledMainJsUrl] = useState< + string | undefined + >(undefined); + const [validSyntax, setValidSyntax] = useState(false); + + useEffect(() => { + // if the compiled content is not the same as the current content, + // then the state should not be compiled or failed + if (data.stanFileContent !== theStanFileContentThasHasBeenCompiled) { + if (compileStatus === "compiled" || compileStatus === "failed") { + setCompileStatus(""); + setCompiledMainJsUrl(""); + } + } + }, [ + data.stanFileContent, + theStanFileContentThasHasBeenCompiled, + compileStatus, + setCompiledMainJsUrl, + ]); + + const [stanWasmServerUrl, setStanWasmServerUrl] = useState( + initialStanWasmServerUrl, + ); + useEffect(() => { + // persist to local storage + localStorage.setItem("stanWasmServerUrl", stanWasmServerUrl); + }, [stanWasmServerUrl]); + + const handleCompile = useCallback(async () => { + setCompileStatus("compiling"); + await new Promise((resolve) => setTimeout(resolve, 500)); // for effect + const onStatus = (msg: string) => { + setCompileMessage(msg); + }; + const { mainJsUrl } = await compileStanProgram( + stanWasmServerUrl, + data.stanFileContent, + onStatus, + ); + + if (!mainJsUrl) { + setCompileStatus("failed"); + return; + } + setCompiledMainJsUrl(mainJsUrl); + setCompileStatus("compiled"); + setTheStanFileContentThasHasBeenCompiled(data.stanFileContent); + }, [ + data.stanFileContent, + setCompiledMainJsUrl, + setCompileStatus, + stanWasmServerUrl, + ]); + + return ( + + {children} + + ); +}; diff --git a/gui/src/app/compileStanProgram/compileStanProgram.ts b/gui/src/app/CompileContext/compileStanProgram.ts similarity index 100% rename from gui/src/app/compileStanProgram/compileStanProgram.ts rename to gui/src/app/CompileContext/compileStanProgram.ts diff --git a/gui/src/app/compileStanProgram/mainJsUrlCache.ts b/gui/src/app/CompileContext/mainJsUrlCache.ts similarity index 100% rename from gui/src/app/compileStanProgram/mainJsUrlCache.ts rename to gui/src/app/CompileContext/mainJsUrlCache.ts diff --git a/gui/src/app/FileEditor/StanFileEditor.tsx b/gui/src/app/FileEditor/StanFileEditor.tsx index 670053be..d49a925c 100644 --- a/gui/src/app/FileEditor/StanFileEditor.tsx +++ b/gui/src/app/FileEditor/StanFileEditor.tsx @@ -3,12 +3,12 @@ import { AutoFixHigh, Cancel, Help, Settings } from "@mui/icons-material"; import StanCompileResultWindow from "@SpComponents/StanCompileResultWindow"; import TextEditor from "@SpComponents/TextEditor"; import { ToolbarItem } from "@SpComponents/ToolBar"; -import compileStanProgram from "@SpStanc/compileStanProgram"; import { stancErrorsToCodeMarkers } from "@SpStanc/Linting"; import useStanc from "@SpStanc/useStanc"; +import { CompileContext } from "@SpCompileContext/CompileContext"; import { FunctionComponent, - useCallback, + useContext, useEffect, useMemo, useState, @@ -22,11 +22,8 @@ type Props = { setEditedFileContent: (text: string) => void; onDeleteFile?: () => void; readOnly: boolean; - setCompiledUrl: (s: string) => void; }; -type CompileStatus = "preparing" | "compiling" | "compiled" | "failed" | ""; - const StanFileEditor: FunctionComponent = ({ fileName, fileContent, @@ -34,7 +31,6 @@ const StanFileEditor: FunctionComponent = ({ editedFileContent, setEditedFileContent, readOnly, - setCompiledUrl, }) => { const { stancErrors, requestFormat } = useStanc( "main.stan", @@ -42,61 +38,21 @@ const StanFileEditor: FunctionComponent = ({ setEditedFileContent, ); + const { compileStatus, compileMessage, compile, setValidSyntax } = + useContext(CompileContext); + const validSyntax = useMemo(() => { return stancErrors.errors === undefined; }, [stancErrors]); + useEffect(() => { + setValidSyntax(validSyntax); + }, [validSyntax, setValidSyntax]); + const hasWarnings = useMemo(() => { return stancErrors.warnings && stancErrors.warnings.length > 0; }, [stancErrors]); - const [compileStatus, setCompileStatus] = useState(""); - const [ - theStanFileContentThasHasBeenCompiled, - setTheStanFileContentThasHasBeenCompiled, - ] = useState(""); - const [compileMessage, setCompileMessage] = useState(""); - - const handleCompile = useCallback(async () => { - setCompileStatus("compiling"); - await new Promise((resolve) => setTimeout(resolve, 500)); // for effect - const onStatus = (msg: string) => { - setCompileMessage(msg); - }; - const stanWasmServerUrl = - localStorage.getItem("stanWasmServerUrl") || - "https://trom-stan-wasm-server.magland.org"; - const { mainJsUrl } = await compileStanProgram( - stanWasmServerUrl, - fileContent, - onStatus, - ); - - if (!mainJsUrl) { - setCompileStatus("failed"); - return; - } - setCompiledUrl(mainJsUrl); - setCompileStatus("compiled"); - setTheStanFileContentThasHasBeenCompiled(fileContent); - }, [fileContent, setCompiledUrl]); - - useEffect(() => { - // if the compiled content is not the same as the current content, - // then the state should not be compiled or failed - if (fileContent !== theStanFileContentThasHasBeenCompiled) { - if (compileStatus === "compiled" || compileStatus === "failed") { - setCompileStatus(""); - setCompiledUrl(""); - } - } - }, [ - fileContent, - theStanFileContentThasHasBeenCompiled, - compileStatus, - setCompiledUrl, - ]); - const [syntaxWindowVisible, setSyntaxWindowVisible] = useState(false); const toolbarItems: ToolbarItem[] = useMemo(() => { @@ -154,7 +110,7 @@ const StanFileEditor: FunctionComponent = ({ tooltip: "Compile Stan model", label: "Compile", icon: , - onClick: handleCompile, + onClick: compile, color: "darkblue", }); } @@ -178,7 +134,7 @@ const StanFileEditor: FunctionComponent = ({ }, [ editedFileContent, fileContent, - handleCompile, + compile, requestFormat, validSyntax, compileStatus, diff --git a/gui/src/app/RunPanel/CompiledRunPanel.tsx b/gui/src/app/RunPanel/CompiledRunPanel.tsx new file mode 100644 index 00000000..167ed641 --- /dev/null +++ b/gui/src/app/RunPanel/CompiledRunPanel.tsx @@ -0,0 +1,141 @@ +import Box from "@mui/material/Box"; +import LinearProgress, { + LinearProgressProps, +} from "@mui/material/LinearProgress"; +import Typography from "@mui/material/Typography"; +import { FunctionComponent } from "react"; + +import Button from "@mui/material/Button"; +import { SamplingOpts } from "@SpCore/ProjectDataModel"; +import { Progress } from "@SpStanSampler/StanModelWorker"; +import { StanSamplerStatus } from "@SpStanSampler/StanSampler"; + +type CompiledRunPanelProps = { + handleRun: () => Promise; + cancelRun: () => void; + runStatus: StanSamplerStatus; + progress: Progress | undefined; + samplingOpts: SamplingOpts; + errorMessage: string; +}; + +const loadingDiv =

Loading compiled Stan model...
; +const completedDiv =
done sampling
; + +const CompiledRunPanel: FunctionComponent = ({ + handleRun, + runStatus, + cancelRun, + progress, + samplingOpts, + errorMessage, +}) => { + const samplingDiv = ( + <> + +
+ Sampling + +
+ + ); + + const failedDiv = ( +
+ Sampling failed! +
{errorMessage}
+ (see browser console for more details) +
+ ); + + return ( +
+ +   +
+ {runStatus === "loading" ? ( + loadingDiv + ) : runStatus === "completed" ? ( + completedDiv + ) : runStatus === "failed" ? ( + failedDiv + ) : runStatus === "sampling" ? ( + samplingDiv + ) : ( + <> + )} +
+ ); +}; + +type SamplingProgressComponentProps = { + report: Progress | undefined; + numChains: number; +}; + +const SamplingProgressComponent: FunctionComponent< + SamplingProgressComponentProps +> = ({ report, numChains }) => { + if (!report) return ; + const progress = + ((report.iteration + (report.chain - 1) * report.totalIterations) / + (report.totalIterations * numChains)) * + 100; + return ( + <> +
+ +
+
+ Chain {report.chain} Iteration: {report.iteration} /{" "} + {report.totalIterations} ({report.warmup ? "Warmup" : "Sampling"}) +
+ + ); +}; + +// from https://mui.com/material-ui/react-progress/#linear-with-label +const LinearProgressWithLabel = ( + props: LinearProgressProps & { value: number }, +) => { + return ( + + + + + + {`${Math.round( + props.value, + )}%`} + + + ); +}; + +export default CompiledRunPanel; diff --git a/gui/src/app/RunPanel/RunPanel.tsx b/gui/src/app/RunPanel/RunPanel.tsx index 8b2f18a5..dc2c6c56 100644 --- a/gui/src/app/RunPanel/RunPanel.tsx +++ b/gui/src/app/RunPanel/RunPanel.tsx @@ -1,16 +1,17 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import Box from "@mui/material/Box"; -import LinearProgress, { - LinearProgressProps, -} from "@mui/material/LinearProgress"; -import Typography from "@mui/material/Typography"; -import { FunctionComponent, useCallback } from "react"; +import { FunctionComponent, useCallback, useContext } from "react"; -import { SamplingOpts } from "@SpCore/ProjectDataModel"; -import { Progress } from "@SpStanSampler/StanModelWorker"; +import Button from "@mui/material/Button"; +import { CompileContext } from "@SpCompileContext/CompileContext"; +import { ProjectContext } from "@SpCore/ProjectContextProvider"; +import { + ProjectDataModel, + SamplingOpts, + modelHasUnsavedChanges, +} from "@SpCore/ProjectDataModel"; import StanSampler from "@SpStanSampler/StanSampler"; import { StanRun } from "@SpStanSampler/useStanSampler"; -import Button from "@mui/material/Button"; +import CompiledRunPanel from "./CompiledRunPanel"; type RunPanelProps = { sampler?: StanSampler; @@ -39,113 +40,59 @@ const RunPanel: FunctionComponent = ({ sampler.cancel(); }, [sampler]); - if (!sampler) - return
Stan model not compiled
; + const { compile, compileMessage, compileStatus, validSyntax } = + useContext(CompileContext); + + const { data: projectData } = useContext(ProjectContext); if (!dataIsSaved) { return
Data not saved
; } - return ( -
-
-
- -   - {runStatus === "sampling" && ( - - )} -
- {runStatus === "loading" &&
Loading compiled Stan model...
} - {runStatus === "sampling" && ( -
- Sampling - -
- )} - {runStatus === "completed" &&
done sampling
} - {runStatus === "failed" && ( -
- Sampling failed! -
{errorMessage}
- - (see browser console for more details) - -
- )} -
-
+ + const compileDiv = ( +
+
); -}; -type SamplingProgressComponentProps = { - report: Progress | undefined; - numChains: number; -}; + const compilingDiv =
{compileMessage}
; -const SamplingProgressComponent: FunctionComponent< - SamplingProgressComponentProps -> = ({ report, numChains }) => { - if (!report) return ; - const progress = - ((report.iteration + (report.chain - 1) * report.totalIterations) / - (report.totalIterations * numChains)) * - 100; return ( - <> -
- -
-
- Chain {report.chain} Iteration: {report.iteration} /{" "} - {report.totalIterations} ({report.warmup ? "Warmup" : "Sampling"}) +
+
+ {compileStatus === "compiled" ? ( + + ) : ["preparing", "compiling"].includes(compileStatus) ? ( + compilingDiv + ) : ( + compileDiv + )}
- +
); }; -// from https://mui.com/material-ui/react-progress/#linear-with-label -const LinearProgressWithLabel = ( - props: LinearProgressProps & { value: number }, +const isCompileModelDisabled = ( + projectData: ProjectDataModel, + validSyntax: boolean, ) => { - return ( - - - - - - {`${Math.round( - props.value, - )}%`} - - - ); + if (!validSyntax) return true; + if (!projectData.stanFileContent.trim()) return true; + if (modelHasUnsavedChanges(projectData)) return true; + return false; }; export default RunPanel; diff --git a/gui/src/app/pages/HomePage/HomePage.tsx b/gui/src/app/pages/HomePage/HomePage.tsx index 75042619..6e1ffa52 100644 --- a/gui/src/app/pages/HomePage/HomePage.tsx +++ b/gui/src/app/pages/HomePage/HomePage.tsx @@ -1,7 +1,11 @@ +import { Split } from "@geoffcox/react-splitter"; import Box from "@mui/material/Box"; import styled from "@mui/material/styles/styled"; import useMediaQuery from "@mui/material/useMediaQuery"; import StanFileEditor from "@SpComponents/StanFileEditor"; +import TabWidget from "@SpComponents/TabWidget"; +import TextEditor from "@SpComponents/TextEditor"; +import { FileNames } from "@SpCore/FileMapping"; import { ProjectContext } from "@SpCore/ProjectContextProvider"; import { modelHasUnsavedChanges, @@ -9,6 +13,8 @@ import { } from "@SpCore/ProjectDataModel"; import Sidebar, { drawerWidth } from "@SpPages/Sidebar"; import TopBar from "@SpPages/TopBar"; +import DataPyWindow from "@SpScripting/DataGeneration/DataPyWindow"; +import DataRWindow from "@SpScripting/DataGeneration/DataRWindow"; import { FunctionComponent, useContext, @@ -16,13 +22,7 @@ import { useRef, useState, } from "react"; -import TabWidget from "@SpComponents/TabWidget"; import SamplingWindow from "./SamplingWindow/SamplingWindow"; -import { FileNames } from "@SpCore/FileMapping"; -import DataRWindow from "@SpScripting/DataGeneration/DataRWindow"; -import DataPyWindow from "@SpScripting/DataGeneration/DataPyWindow"; -import TextEditor from "@SpComponents/TextEditor"; -import { Split } from "@geoffcox/react-splitter"; type Props = { // @@ -31,8 +31,6 @@ type Props = { const HomePage: FunctionComponent = () => { const { data } = useContext(ProjectContext); - const [compiledMainJsUrl, setCompiledMainJsUrl] = useState(""); - const smallScreen = useMediaQuery("(max-width:600px)"); const [leftPanelCollapsed, setLeftPanelCollapsed] = useState(smallScreen); @@ -64,8 +62,8 @@ const HomePage: FunctionComponent = () => { - - + + @@ -73,15 +71,13 @@ const HomePage: FunctionComponent = () => { }; type RightViewProps = { - compiledMainJsUrl: string; + // none }; -const RightView: FunctionComponent = ({ - compiledMainJsUrl, -}) => { +const RightView: FunctionComponent = () => { return ( - + @@ -91,12 +87,10 @@ const RightView: FunctionComponent = ({ }; type LeftViewProps = { - setCompiledMainJsUrl: (url: string) => void; + // none }; -const LeftView: FunctionComponent = ({ - setCompiledMainJsUrl, -}) => { +const LeftView: FunctionComponent = () => { const { data, update } = useContext(ProjectContext); return ( @@ -119,7 +113,6 @@ const LeftView: FunctionComponent = ({ }) } readOnly={false} - setCompiledUrl={setCompiledMainJsUrl} /> = ({ - compiledMainJsUrl, -}) => { +const SamplingWindow: FunctionComponent = () => { const { data, update } = useContext(ProjectContext); const parsedData = useMemo(() => { try { @@ -39,6 +38,8 @@ const SamplingWindow: FunctionComponent = ({ [update], ); + const { compiledMainJsUrl } = useContext(CompileContext); + const { sampler, latestRun } = useStanSampler(compiledMainJsUrl); const isSampling = latestRun.status === "sampling"; return ( diff --git a/gui/tsconfig.json b/gui/tsconfig.json index 765fbda1..a5db7f43 100644 --- a/gui/tsconfig.json +++ b/gui/tsconfig.json @@ -37,15 +37,12 @@ "@SpCore/gists/*": ["app/gists/*"], /* We are playing a bit fast and loose with the distinction */ "@SpPages/*": ["app/pages/HomePage/*"], - "@SpStanc/*": [ - "app/Stanc/*", - "app/CompilationServerConnectionControl/*", - "app/compileStanProgram/*" - ], + "@SpStanc/*": ["app/Stanc/*", "app/CompilationServerConnectionControl/*"], "@SpStanSampler/*": ["app/StanSampler/*"], "@SpUtil/*": ["app/util/*"], "@SpStanStats/*": ["app/util/stan_stats/*"], - "@SpScripting/*": ["app/Scripting/*"] + "@SpScripting/*": ["app/Scripting/*"], + "@SpCompileContext/*": ["app/CompileContext/*"] } }, "include": ["src", "test"],