diff --git a/src/aare/gui/main_window.py b/src/aare/gui/main_window.py index b6090f42..183934e1 100644 --- a/src/aare/gui/main_window.py +++ b/src/aare/gui/main_window.py @@ -199,7 +199,7 @@ class MainWindow(QMainWindow): self._base_url = base_url self._token = token - self._mounting = False + self._watching_motion = False self._samcam_feed_banner_active = False self._samcam_feed_banner_message = "Sample camera feed unavailable" @@ -2707,11 +2707,16 @@ class MainWindow(QMainWindow): if self._remote_close_deadline_ts is not None: self._clear_remote_close_request() - if not self._mounting and s.state == BeamlineStateEnum.RobotSampleExchange: - self._mounting = True + # Busy (or the robot station) means something is physically moving: + # show the Beamline combined view so the motion can be watched, and + # return to the sample camera once it is done. Edge-triggered so a + # manual tab choice survives between transitions. + moving = bool(s.busy) or s.state == BeamlineStateEnum.RobotSampleExchange + if moving and not self._watching_motion: + self._watching_motion = True self.video_tab.setCurrentWidget(self.beamline_combined_panel) - elif self._mounting and s.state != BeamlineStateEnum.RobotSampleExchange: - self._mounting = False + elif not moving and self._watching_motion: + self._watching_motion = False self.video_tab.setCurrentWidget(self.sample_camera) # ========== BATON DIALOG HANDLING ==========