From 0b19acdb1c0c75d26d25c8bda17efc168bb92218 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Fri, 13 Nov 2026 10:08:47 +0100 Subject: [PATCH] frontend: rugnux live switches for refine solvent and rotation as stills, Clear button The "Live processing" panel gets two switches with a line of help each, beside the rugnux live switch. The rugnux live page gets a Clear button next to the phase once a run is over and nothing is measured: POST /rugnux/clear, after which the page is the empty state. The model scores show the waters built where the solvent was refined. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK --- frontend/src/components/RugnuxPage.tsx | 32 ++++++++++++++--- frontend/src/components/RugnuxParts.tsx | 3 ++ frontend/src/components/RugnuxSettings.tsx | 40 ++++++++++++++++++---- 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/RugnuxPage.tsx b/frontend/src/components/RugnuxPage.tsx index 38f9d1cef..76d44f9f3 100644 --- a/frontend/src/components/RugnuxPage.tsx +++ b/frontend/src/components/RugnuxPage.tsx @@ -1,11 +1,15 @@ import {Alert, Box, Button, Collapse, Paper, Stack, Typography, useMediaQuery, useTheme} from "@mui/material"; import {keyframes} from "@mui/system"; -import {useQuery} from "@tanstack/react-query"; -import {getConfigRugnuxOptions, getRugnuxStatusOptions} from "../client/@tanstack/react-query.gen"; +import {useQuery, useQueryClient} from "@tanstack/react-query"; +import { + getConfigRugnuxOptions, getRugnuxStatusOptions, getRugnuxStatusQueryKey, postRugnuxClearMutation +} from "../client/@tanstack/react-query.gen"; import {rugnux_live_status} from "../client"; import {useTokenRequired} from "../auth"; import {LivePalette, livePalette} from "../livePalette"; import EmptyState from "./EmptyState"; +import {UploadSnackbarView} from "./SettingsPanel"; +import {useUpload} from "./useUpload"; import RugnuxTriage from "./RugnuxTriage"; import RugnuxTimeline from "./RugnuxTimeline"; import RugnuxSettings from "./RugnuxSettings"; @@ -18,6 +22,7 @@ import RugnuxCollectionPlots from "./RugnuxCollectionPlots"; import {lastImageTime, ModelScores, StepTable, VerdictAlert} from "./RugnuxParts"; import BoltIcon from "@mui/icons-material/Bolt"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; +import ClearAllIcon from "@mui/icons-material/ClearAll"; import {lazy, Suspense, useEffect, useRef, useState} from "react"; // The live page as one control-room screen, in the app's own light or dark: a stage the height of the window, @@ -55,9 +60,27 @@ function phase(s: rugnux_live_status, pal: LivePalette): { label: string, colour return {label: s.state, colour: "text.disabled"}; } +// Back to the empty page, as if nothing was measured: the broker forgets the run's result (POST /rugnux/clear). +// Offered once the run is over; the images and the collection's plots elsewhere are kept. +function ClearButton() { + const queryClient = useQueryClient(); + const clear = useUpload({...postRugnuxClearMutation(), + onSuccess: () => queryClient.invalidateQueries({queryKey: getRugnuxStatusQueryKey()})}); + return ( + <> + + + + ); +} + // Phase, the progress block and the clock: the number the run is judged by - seconds since the first image // while it runs, from the last image to all results written once it is over. -function Header({s, deadline_s, pal}: { s: rugnux_live_status, deadline_s: number, pal: LivePalette }) { +function Header({s, deadline_s, measuring, pal}: { s: rugnux_live_status, deadline_s: number, measuring: boolean, pal: LivePalette }) { const p = phase(s, pal); const running = s.state === "Running"; const lastImage = lastImageTime(s); @@ -80,6 +103,7 @@ function Header({s, deadline_s, pal}: { s: rugnux_live_status, deadline_s: numbe {s.state === "Failed" && s.message && {s.message}} + {!running && !measuring && } @@ -182,7 +206,7 @@ function Dashboard({s, deadline_s, modelLoaded, measuring, pal}: const hairline = {borderLeft: {xl: "1px solid"}, borderColor: {xl: "divider"}, pl: {xl: 2.5}}; return ( -
+
diff --git a/frontend/src/components/RugnuxParts.tsx b/frontend/src/components/RugnuxParts.tsx index e84c33716..24ba0c64e 100644 --- a/frontend/src/components/RugnuxParts.tsx +++ b/frontend/src/components/RugnuxParts.tsx @@ -173,6 +173,9 @@ export function ModelScores({m, mrSeconds, anomalousSignal}: .filter(Boolean).join(" · ")}); else if (rf) tiles.push({label: "Refinement", value: "failed", sub: rf.reason}); + if (rf && rf.waters_added != null) + tiles.push({label: "Waters built", value: `+${rf.waters_added}`, + sub: `${rf.waters_removed ?? 0} of the model's taken out · solvent refined`}); if (rf && rf.performed) { const count = (kind: string) => rf.blobs.filter(b => b.kind === kind).length; const kinds = ([["LIGAND", "ligand"], ["WATER", "water"], ["ION", "ion"], ["MODEL_ERROR", "model error"]] as const) diff --git a/frontend/src/components/RugnuxSettings.tsx b/frontend/src/components/RugnuxSettings.tsx index 8c5de7ea0..7a2ff11ad 100644 --- a/frontend/src/components/RugnuxSettings.tsx +++ b/frontend/src/components/RugnuxSettings.tsx @@ -15,7 +15,20 @@ import {useUpload} from "./useUpload"; const sizeText = (bytes?: number) => bytes === undefined ? "" : bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MiB` : `${(bytes / 1024).toFixed(0)} KiB`; -// Rugnux live mode (enable, reserved CPUs) and the model used for MR, as two panels side by side. +// A switch with a line of help under its label +function OptionSwitch({label, help, checked, disabled, onChange}: + { label: string, help: string, checked: boolean, disabled: boolean, onChange: (v: boolean) => void }) { + return ( + onChange(e.target.checked)}/>} + label={<> + {label} + {help} + }/> + ); +} + +// Rugnux live mode (enable, options, reserved CPUs) and the model used for MR, as two panels side by side. function RugnuxSettings({measuring}: { measuring: boolean }) { const queryClient = useQueryClient(); const {data: s} = useQuery({...getConfigRugnuxOptions(), refetchInterval: 2000}); @@ -26,6 +39,8 @@ function RugnuxSettings({measuring}: { measuring: boolean }) { const remove = useUpload({...deleteConfigRugnuxModelMutation(), ...refresh}); const [enable, setEnable] = useState(false); + const [refineSolvent, setRefineSolvent] = useState(false); + const [forceStill, setForceStill] = useState(false); const [cpus, setCpus] = useState(4); const [cpusError, setCpusError] = useState(false); const [deadline, setDeadline] = useState(0); @@ -36,23 +51,34 @@ function RugnuxSettings({measuring}: { measuring: boolean }) { useEffect(() => { if (s !== undefined) { setEnable(s.enable); + setRefineSolvent(s.refine_solvent); + setForceStill(s.force_still); setCpus(s.reserved_cpus); setDeadline(s.deadline_s ?? 0); setCounter(c => c + 1); } - }, [s?.enable, s?.reserved_cpus, s?.deadline_s]); + }, [s?.enable, s?.refine_solvent, s?.force_still, s?.reserved_cpus, s?.deadline_s]); - const dirty = s !== undefined && (enable !== s.enable || cpus !== s.reserved_cpus || deadline !== (s.deadline_s ?? 0)); + const dirty = s !== undefined && (enable !== s.enable || refineSolvent !== s.refine_solvent + || forceStill !== s.force_still || cpus !== s.reserved_cpus || deadline !== (s.deadline_s ?? 0)); return ( settings.submit({enable, reserved_cpus: cpus, deadline_s: deadline})} + onUpload={() => settings.submit({enable, refine_solvent: refineSolvent, force_still: forceStill, + reserved_cpus: cpus, deadline_s: deadline})} uploadDisabled={measuring || cpusError || deadlineError || settings.pending} snackbar={settings.snackbar}> - setEnable(e.target.checked)}/>}/> + + setEnable(e.target.checked)}/>}/> + + + { setCpus(v); setCpusError(err); }}/>