fix(gui): fire mount auto-centering on the first idle status tick #244

Merged
duan_j merged 2 commits from fix/gui-auto-center-after-mount-idle-tick into main 2026-09-29 17:04:16 +02:00
Owner

Problem

"apply after mounting" (Auto Centering checkbox) never fired. The GUI clicked
Auto Centering on the first status tick that showed the new sample id, but
/sample/mount still holds the hw lock at that point. /alc/center_loop takes
the same lock non-blocking, so the request failed with BeamlineBusyException,
which the GUI treats as a quiet error (no popup, no retry). A manual click a
few seconds later worked because the lock was free by then.

Fix

  • Arm on the sample-id change, click on the first status tick with busy=False
    (busy is the hw lock state). Same thing the user did by hand.
  • Skip arming while queue automation runs: it mounts and centers itself and
    frees the lock between /scan/auto calls; a GUI centering in that gap would
    steal the lock from the next scan.
  • One connect line in main_window from the existing automation_running_changed
    signal.

Known and accepted: Pause pressed during a scan's mount phase can still arm
that sample. Pause ends in an unmount, so the remaining window is the ms-wide
lock gap between scan end and unmount, sampled at 2 Hz. Noted in the code.

Supersedes PR 243 (fix/auto-center-after-mount-wait-idle, three commits with
an in-flight /scan/auto counter). That PR can be closed.

Verification

  • ruff check (+ isort variant), ruff format --check: pass
  • diff-quality basedpyright vs origin/main: 100%
  • tests/unit: 539 passed, 9 skipped (two runs)
  • diff-cover vs origin/main: 100% (15 lines)
  • Pre-push hook skipped: its --cov run hits a known macOS Bus error in
    test_tell_sample_panel.py::test_queue_drop_chip_accepts_sample_payloads
    (QDropEvent under coverage tracing), unrelated to this change; the same
    gates were run by hand.
  • Still to do on hardware: tick the box, mount from the Dewar list, expect the
    AUTO CENTERING overlay right after the robot finishes; run a short queue and
    confirm no centering between samples.

Generated with Claude Code

## Problem "apply after mounting" (Auto Centering checkbox) never fired. The GUI clicked Auto Centering on the first status tick that showed the new sample id, but /sample/mount still holds the hw lock at that point. /alc/center_loop takes the same lock non-blocking, so the request failed with BeamlineBusyException, which the GUI treats as a quiet error (no popup, no retry). A manual click a few seconds later worked because the lock was free by then. ## Fix - Arm on the sample-id change, click on the first status tick with busy=False (busy is the hw lock state). Same thing the user did by hand. - Skip arming while queue automation runs: it mounts and centers itself and frees the lock between /scan/auto calls; a GUI centering in that gap would steal the lock from the next scan. - One connect line in main_window from the existing automation_running_changed signal. Known and accepted: Pause pressed during a scan's mount phase can still arm that sample. Pause ends in an unmount, so the remaining window is the ms-wide lock gap between scan end and unmount, sampled at 2 Hz. Noted in the code. Supersedes PR 243 (fix/auto-center-after-mount-wait-idle, three commits with an in-flight /scan/auto counter). That PR can be closed. ## Verification - ruff check (+ isort variant), ruff format --check: pass - diff-quality basedpyright vs origin/main: 100% - tests/unit: 539 passed, 9 skipped (two runs) - diff-cover vs origin/main: 100% (15 lines) - Pre-push hook skipped: its --cov run hits a known macOS Bus error in test_tell_sample_panel.py::test_queue_drop_chip_accepts_sample_payloads (QDropEvent under coverage tracing), unrelated to this change; the same gates were run by hand. - Still to do on hardware: tick the box, mount from the Dewar list, expect the AUTO CENTERING overlay right after the robot finishes; run a short queue and confirm no centering between samples. Generated with [Claude Code](https://claude.com/claude-code)

Coverage report (automated)

Total line + branch coverage: 51%
Diff coverage vs main: 100% (minimum 80%)

Full report: coverage artifact on this run.

Coverage report (automated) Total line + branch coverage: 51% Diff coverage vs main: 100% (minimum 80%) Full report: coverage artifact on this run.
duan_j added 2 commits 2026-09-29 16:51:09 +02:00
The "apply after mounting" checkbox clicked Auto Centering as soon as the
status poll showed a new sample id. /sample/mount still holds the hw lock
at that point, /alc/center_loop takes the same lock non-blocking, and the
resulting BeamlineBusyException is a quiet error the GUI swallows. So the
automatic click never did anything; only a later manual click worked.

Arm on the sample-id change and click on the first status tick with
busy=False, which is exactly what the user did by hand. Skip arming while
queue automation runs: it mounts and centers on its own and frees the lock
between /scan/auto calls, so a GUI centering in that gap would steal the
lock from the next scan. Pause during a scan's mount phase can still arm
that one sample, but Pause ends in an unmount, so the window is a ms-wide
lock gap sampled at 2 Hz; accepted, noted in the code.

Supersedes the three-commit approach on
fix/auto-center-after-mount-wait-idle (PR 243).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
fix(gui): remove not longer needed return to main window at close and cleanup
CI / lint (pull_request) Successful in 1m27s
CI / test (3.12) (pull_request) Successful in 1m52s
CI / test (3.13) (pull_request) Successful in 1m35s
CI / test (3.14) (pull_request) Successful in 1m39s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 1m41s
CI / test-with-coverage (pull_request) Successful in 1m47s
CI / coverage-analysis (pull_request) Successful in 2s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 1m14s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 1m20s
Docs build and publish / docker (push) Successful in 2s
Build and Publish / release (push) Failing after 14s
CI / test-with-beamline-plugins (pxii_bec) (push) Failing after 50s
CI / test-with-beamline-plugins (pxiii_bec) (push) Failing after 50s
CI / test-with-beamline-plugins (pxi_bec) (push) Failing after 1m0s
CI / lint (push) Failing after 1m27s
CI / test (3.12) (push) Successful in 1m35s
CI / test (3.13) (push) Successful in 1m36s
CI / test (3.14) (push) Successful in 1m37s
CI / test-with-coverage (push) Successful in 1m39s
CI / coverage-analysis (push) Skipped
2c388ff7ad
duan_j force-pushed fix/gui-auto-center-after-mount-idle-tick from 168c8afb5f to 2c388ff7ad 2026-09-29 16:51:09 +02:00 Compare
duan_j merged commit 2c388ff7ad into main 2026-09-29 17:04:16 +02:00
Sign in to join this conversation.