From 25a839bf888b6c0452529ec7114d31238b521605 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Mon, 23 Feb 2026 17:48:26 +0000 Subject: [PATCH 1/3] Stringify 0 as axios treats it as "" Also add a check that we don't try to log(0) --- webapp/src/components/labThingsComponents/inputFromSchema.vue | 3 ++- webapp/src/mixins/labThingsMixins.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/labThingsComponents/inputFromSchema.vue b/webapp/src/components/labThingsComponents/inputFromSchema.vue index 5b251e2d..6caac19e 100644 --- a/webapp/src/components/labThingsComponents/inputFromSchema.vue +++ b/webapp/src/components/labThingsComponents/inputFromSchema.vue @@ -346,7 +346,8 @@ export default { } // Rounding to about 5 sig figs to stop weird javascript rounding. - const magnitude = Math.floor(Math.log10(Math.abs(newValue))); + const absVal = Math.abs(newValue); + const magnitude = absVal > 0 ? Math.floor(Math.log10(absVal)) : 0; const factor = 10 ** -(Math.floor(magnitude) - 4); this.internalValue = Math.round(newValue * factor) / factor; }, diff --git a/webapp/src/mixins/labThingsMixins.js b/webapp/src/mixins/labThingsMixins.js index 2b935492..4fcc4d1a 100644 --- a/webapp/src/mixins/labThingsMixins.js +++ b/webapp/src/mixins/labThingsMixins.js @@ -56,10 +56,10 @@ export default { "writeproperty", false, ); - // `false` fails because axios somehow eats it! + // `false` and 0 fail because axios turns it to "" // Other values should not be stringified or pydantic // can't parse them. - if (value === false || value === true) { + if (value === false || value === true || value === 0) { value = JSON.stringify(value); } await axios.put(url, value); From dbe86340415db62191205e6762f24f739b2b6a93 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Tue, 24 Feb 2026 12:36:30 +0000 Subject: [PATCH 2/3] Apply suggestions from code review of branch allow-zero Co-authored-by: Julian Stirling --- webapp/src/components/labThingsComponents/inputFromSchema.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/labThingsComponents/inputFromSchema.vue b/webapp/src/components/labThingsComponents/inputFromSchema.vue index 6caac19e..891075ea 100644 --- a/webapp/src/components/labThingsComponents/inputFromSchema.vue +++ b/webapp/src/components/labThingsComponents/inputFromSchema.vue @@ -347,7 +347,7 @@ export default { // Rounding to about 5 sig figs to stop weird javascript rounding. const absVal = Math.abs(newValue); - const magnitude = absVal > 0 ? Math.floor(Math.log10(absVal)) : 0; + const magnitude = absVal > Number.EPSILON ? Math.floor(Math.log10(absVal)) : 0; const factor = 10 ** -(Math.floor(magnitude) - 4); this.internalValue = Math.round(newValue * factor) / factor; }, From 2c532e11c8ad2bf5ed902954d3cef92f9a0a46e8 Mon Sep 17 00:00:00 2001 From: jaknapper Date: Tue, 24 Feb 2026 12:45:42 +0000 Subject: [PATCH 3/3] Max_range cant be negative --- src/openflexure_microscope_server/things/scan_workflows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openflexure_microscope_server/things/scan_workflows.py b/src/openflexure_microscope_server/things/scan_workflows.py index 7b10cbff..85198a9e 100644 --- a/src/openflexure_microscope_server/things/scan_workflows.py +++ b/src/openflexure_microscope_server/things/scan_workflows.py @@ -290,7 +290,7 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]): This uses the settings from the ``BackgroundDetectThing``. """ - max_range: int = lt.setting(default=45000) + max_range: int = lt.setting(default=45000, ge=0) """The maximum distance in steps from the centre of the scan.""" # Stacking settings