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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-13 10:08:47 +01:00
1 parent ab4cf83cfe
commit 0b19acdb1c
3 files changed
+64 -11

No files matched your search

+28 -4
View File
@@ -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 (
<>
<Button size="small" variant="outlined" color="inherit" startIcon={<ClearAllIcon/>}
disabled={clear.pending} onClick={() => clear.submit(undefined)}
sx={{ml: "auto", flexShrink: 0, alignSelf: "center", color: "text.secondary"}}>
Clear
</Button>
<UploadSnackbarView snackbar={clear.snackbar}/>
</>
);
}
// 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
</Typography>
{s.state === "Failed" && s.message &&
<Typography noWrap sx={{color: "text.secondary", minWidth: 0}}>{s.message}</Typography>}
{!running && !measuring && <ClearButton/>}
</Stack>
<RugnuxProgress s={s} deadline_s={deadline_s}/>
</Box>
@@ -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 (
<Box sx={{display: "grid", gridTemplateRows: "auto minmax(0, 1fr)", gap: 2.5, height: "100%", minHeight: 0}}>
<Header s={s} deadline_s={deadline_s} pal={pal}/>
<Header s={s} deadline_s={deadline_s} measuring={measuring} pal={pal}/>
<Box sx={{display: "grid", gap: 2.5, minHeight: 0,
gridTemplateColumns: {xs: "1fr", md: `${RAIL} minmax(0, 1fr)`, xl: `${RAIL} ${IMAGE} minmax(0, 1fr) minmax(360px, 27%)`},
gridTemplateRows: {xs: "auto", xl: `minmax(0, 1fr) ${STRIP}`}}}>
+3
View File
@@ -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)
+33 -7
View File
@@ -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 (
<FormControlLabel sx={{alignItems: "flex-start", mr: 0, "& .MuiSwitch-root": {mt: -0.75}}}
control={<Switch checked={checked} disabled={disabled} onChange={e => onChange(e.target.checked)}/>}
label={<>
<Typography>{label}</Typography>
<Typography variant="body2" color="text.secondary">{help}</Typography>
</>}/>
);
}
// 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 (
<Stack direction={{xs: "column", md: "row"}} spacing={2} alignItems="stretch">
<SettingsPanel title="Live processing" dirty={dirty} spacing={2}
onUpload={() => 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}>
<FormControlLabel label="Process collections with rugnux live"
control={<Switch checked={enable} disabled={measuring}
onChange={e => setEnable(e.target.checked)}/>}/>
<Stack spacing={1.5} alignItems="flex-start" sx={{textAlign: "left"}}>
<FormControlLabel label="Process collections with rugnux live"
control={<Switch checked={enable} disabled={measuring}
onChange={e => setEnable(e.target.checked)}/>}/>
<OptionSwitch label="Refine solvent" checked={refineSolvent} disabled={measuring} onChange={setRefineSolvent}
help="With a model: waters added and removed, waters and ions relabelled in refinement"/>
<OptionSwitch label="Process rotation as stills" checked={forceStill} disabled={measuring}
onChange={setForceStill}
help="Rotation collections go the serial way: pre-pass, per-image analysis, stills merge"/>
</Stack>
<NumberTextField label="Reserved CPU threads" start_val={cpus} min={0} max={512}
counter={counter} disabled={measuring}
callback={(v, err) => { setCpus(v); setCpusError(err); }}/>