Skip to content

Remember scan parameter settings when navigating between parameters#113

Open
beitler wants to merge 3 commits into
mainfrom
108-sticky-scan-settings
Open

Remember scan parameter settings when navigating between parameters#113
beitler wants to merge 3 commits into
mainfrom
108-sticky-scan-settings

Conversation

@beitler
Copy link
Copy Markdown
Collaborator

@beitler beitler commented Jun 3, 2026

Fixes #108

Background

In the Experiment Page, the user is expected to configure a range scan for one or more parameters.

image

The fields Namespace, Display Group and Parameter construct the hierarchical identifier to the parameter to be scanned. The fields start, stop, points and scan pattern (the value range generator) define how the parameter value range is calculated.

Problem Statement

When navigating between different parameters (i.e. choosing different Namespace/Display Group/Parameter tuples) the values of start, stop, points and scan pattern are left unchanged. This can lead the user being presented with infeasible value ranges for their parameters.

The background of this behavior is that the browser's local storage persist only the value range generators for the currently selected parameter(s).

before.mov

Solution Proposal

A possible solution is to extend the ScanInfoState in the local storage with a list of parameter value range generators for previously configured but not currently shown parameters. When a new parameter is selected in the drop down, the past value range generator is fetched from the browser's local storage if present, otherwise a global default is loaded.

diff --git a/frontend/src/hooks/useScanInfoState.tsx b/frontend/src/hooks/useScanInfoState.tsx
index 65159a4..94d8319 100644
--- a/frontend/src/hooks/useScanInfoState.tsx
+++ b/frontend/src/hooks/useScanInfoState.tsx
@@ -1,11 +1,13 @@
 import { useEffect, useReducer } from "react";
 import { ScanParameterInfo } from "../types/ScanParameterInfo";
+import { ScanParameterValueGenerator } from "../types/ScanParameterValueGenerator";

 export interface ScanInfoState {
   priority: number;
   shots: number;
   repetitions: number;
   parameters: ScanParameterInfo[];
+  valueGenerators: Record<string, ScanParameterValueGenerator>;
 }

 export type ScanInfoAction =
after.mov

Notes

  • This solution is local to the browser. It does not synchronize the state of these fields globally across browsers
  • In this PR I removed the values from the ScanParameterInfo to avoid the browser potentially having to materialize a large value lists in case the user accidentally enters a large number of points. Now, the values list gets generated when the job is submitted, i.e. after input validation.
  • Future considerations:
    • We could consider an import/export functionality for these settings
    • start, stop, points field should be pre-populated with parameter-specfic reasonable defaults
    • start, stop, points fields should be validated against parameter-specfic validators
    • start, stop, points fields currently don't allow to clear the value, only overwrite is possible. It should be made possible to completely clear the value.

@beitler beitler requested review from antti-ethz and mastadle June 3, 2026 19:57
@beitler beitler changed the title Remember scan parameter settings when navigating between parameters, Fixes #108 Remember scan parameter settings when navigating between parameters Jun 3, 2026
Comment thread frontend/src/hooks/useScanInfoState.tsx Outdated
@mastadle
Copy link
Copy Markdown
Contributor

mastadle commented Jun 4, 2026

Great. I think it's a good idea to move the value generation to submit job.

You will have to regenerate the static assets before you can merge.

@mastadle
Copy link
Copy Markdown
Contributor

mastadle commented Jun 4, 2026

Another idea just came up and maybe @FlorenceBerterottiere can comment on it:

You can change the namespace or display group and ICON currently does not remember the last parameter that was selected. To achieve this, we would need another dictionary from namespace to display group and one from display group to parameter. It's quite related to what's currently happening in this PR. But we can leave that for the next PR after this implementation has received some testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remembering scan settings

2 participants