From 2d2db92c3ccc5373164b93368502919919bed1e3 Mon Sep 17 00:00:00 2001 From: positnuec <93694981+positnuec@users.noreply.github.com> Date: Sat, 15 Aug 2026 22:48:24 +0800 Subject: [PATCH] Fix: init state_switch before show() in webui On session loss the page reloads, the sidebar becomes clickable while run() is still initializing, and a click in between raises AttributeError on missing state_switch. --- module/webui/app.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/module/webui/app.py b/module/webui/app.py index e983e5d3d..3789acbbb 100644 --- a/module/webui/app.py +++ b/module/webui/app.py @@ -1394,6 +1394,14 @@ class AlasGUI(Frame): """ ) + # Init state switch before rendering, `ui_alas()` and `ui_develop()` may be + # triggered as soon as the sidebar is visible, while `run()` is still initializing + self.state_switch = Switch( + status=self.set_status, + get_state=lambda: getattr(getattr(self, "alas", -1), "state", 0), + name="state", + ) + aside = get_localstorage("aside") self.show() @@ -1423,12 +1431,6 @@ class AlasGUI(Frame): name="visibility_state", ) - self.state_switch = Switch( - status=self.set_status, - get_state=lambda: getattr(getattr(self, "alas", -1), "state", 0), - name="state", - ) - def goto_update(): self.ui_develop() self.dev_update()