Fix page reset on save: disable reload, handle orphaned timers

- Set reload=False to prevent watchfiles from triggering full page
  reloads when JSON/DB files are written during save
- Timeline graph poll timer (200ms) now deactivates itself when its
  parent slot is deleted during UI refresh
- Comfy monitor poll timer catches RuntimeError from deleted parent
  slots instead of crashing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 22:50:11 +01:00
parent efd0a31426
commit f3ad3e01bc
3 changed files with 19 additions and 11 deletions
+1 -1
View File
@@ -522,4 +522,4 @@ def render_sidebar(state: AppState, dual_pane: dict):
if _shared_db is not None:
register_api_routes(_shared_db)
ui.run(title='AI Settings Manager', port=8080, reload=True, reload_includes=['*.py'])
ui.run(title='AI Settings Manager', port=8080, reload=False)
+3
View File
@@ -82,6 +82,7 @@ def render_comfy_monitor(state: AppState):
_live_refreshables = state._live_refreshables
def poll_all():
try:
timeout_val = config.get('monitor_timeout', 0)
if timeout_val > 0:
for key, start_time in list(state.live_toggles.items()):
@@ -91,6 +92,8 @@ def render_comfy_monitor(state: AppState):
_live_checkboxes[key].set_value(False)
if key in _live_refreshables:
_live_refreshables[key].refresh()
except RuntimeError:
pass # Parent slot deleted during refresh
ui.timer(300, poll_all)
+6 -1
View File
@@ -437,6 +437,8 @@ def render_timeline_tab(state: AppState):
render_timeline()
# --- Poll for graph node clicks (JS → Python bridge) ---
graph_timer = None
async def _poll_graph_click():
if view_mode.value == 'Linear Log':
return
@@ -446,6 +448,9 @@ def render_timeline_tab(state: AppState):
'window.graphSelectedNode = null; v;'
)
except Exception:
# Deactivate timer if parent slot was deleted
if graph_timer is not None:
graph_timer.active = False
return
if not result:
return
@@ -458,7 +463,7 @@ def render_timeline_tab(state: AppState):
selected['node_id'] = node_id
render_timeline.refresh()
ui.timer(0.2, _poll_graph_click)
graph_timer = ui.timer(0.2, _poll_graph_click)
def _render_graphviz(dot_source: str, selected_node_id: str | None = None):