diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py index 5f7895a..7d72049 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py @@ -1798,6 +1798,10 @@ class Flomni( # Published so a future GUI never needs a hardcoded mirror of the # action registry -- see _describe_tomo_queue_actions(). self.client.set_global_var("tomo_queue_actions", self._describe_tomo_queue_actions()) + # Reset to empty on every Flomni() -- hooks are session-only (see + # self._at_each_angle_hooks above), so a stale list published by a + # since-ended session must not linger and look registered. + self._publish_at_each_angle_hooks() from csaxs_bec.bec_ipython_client.plugins.flomni.flomni_webpage_generator import ( FlomniWebpageGenerator, ) @@ -2955,6 +2959,7 @@ class Flomni( if not callable(func): raise TypeError(f"register_at_each_angle_hook: {func!r} is not callable.") self._at_each_angle_hooks[name] = func + self._publish_at_each_angle_hooks() print(f"Registered at_each_angle hook '{name}'.") def unregister_at_each_angle_hook(self, name: str) -> None: @@ -2962,8 +2967,21 @@ class Flomni( if self._at_each_angle_hooks.pop(name, None) is None: print(f"No at_each_angle hook named '{name}' is registered.") else: + self._publish_at_each_angle_hooks() print(f"Unregistered at_each_angle hook '{name}'.") + def _publish_at_each_angle_hooks(self) -> None: + """Publish the names of all currently registered at_each_angle + hooks as the ``tomo_at_each_angle_hooks`` global var (a plain list + of strings) -- so a GUI (or any other client) can build a dropdown + from it directly, no hardcoded mirror, same reasoning as + ``tomo_queue_actions`` for the command-job registry (see + _describe_tomo_queue_actions()). Unlike that registry this list + changes at runtime, whenever register_/unregister_at_each_angle_hook() + is called -- not just once at __init__. + """ + self.client.set_global_var("tomo_at_each_angle_hooks", sorted(self._at_each_angle_hooks)) + def list_at_each_angle_hooks(self) -> list: """Print and return the names of all at_each_angle hooks registered in this session. The active one (``self.at_each_angle_hook``, if