feat: default beamline state on login by role
Staff land in BeamLocation, users in SampleAlignment. One-shot on the first status tick where the GUI owns the session and the beamline is idle, so a running operation or a watch-only GUI is never disturbed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -173,6 +173,7 @@ class MainWindow(QMainWindow):
|
||||
_default_dock_split_done: bool = False
|
||||
_pre_watch_dock_state: QByteArray | None = None
|
||||
_pre_watch_visibility: list[tuple[QWidget, bool]] | None = None
|
||||
_login_default_state_sent: bool = False
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -2609,6 +2610,18 @@ class MainWindow(QMainWindow):
|
||||
self._apply_session_gate(getattr(getattr(s, "session", None), "session", None))
|
||||
self._apply_pgroup_gate(getattr(getattr(s, "session", None), "current_pgroup", None))
|
||||
|
||||
# Login default: staff start in BeamLocation, users in SampleAlignment.
|
||||
# One-shot on the first status tick where this GUI owns the session and
|
||||
# the beamline is idle — a busy beamline or watch-only GUI must never
|
||||
# have its state yanked by someone merely logging in.
|
||||
if not self._login_default_state_sent and self._session_operations_enabled and not s.busy:
|
||||
self._login_default_state_sent = True
|
||||
if self._decoded_token.staff:
|
||||
if s.state != BeamlineStateEnum.BeamLocation:
|
||||
self.daq.beam_location()
|
||||
elif s.state != BeamlineStateEnum.SampleAlignment:
|
||||
self.daq.sample_alignment()
|
||||
|
||||
# Default tab only on state TRANSITIONS — a manual tab choice
|
||||
# survives while the state stays put.
|
||||
new_beamline_state = getattr(s, "state", None)
|
||||
|
||||
Reference in New Issue
Block a user