feat(flomni): publish registered at_each_angle hook names via a global var

Adds tomo_at_each_angle_hooks (a plain list of names), republished on
every register_at_each_angle_hook()/unregister_at_each_angle_hook()
call and reset to empty in __init__ (hooks are session-only, so a
stale list from a prior session must not linger). Same reasoning as
tomo_queue_actions for the command-job registry: a GUI (or any other
client) can build a dropdown from this directly, no hardcoded mirror.
Sim-validated: register/unregister updates the published list
correctly and the webpage generator's current_params payload picks up
an active hook.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
x01dc
2026-07-13 21:24:33 +02:00
co-authored by Claude Sonnet 5
parent 0899ac9809
commit c90be4f336
@@ -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