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:
@@ -522,4 +522,4 @@ def render_sidebar(state: AppState, dual_pane: dict):
|
|||||||
if _shared_db is not None:
|
if _shared_db is not None:
|
||||||
register_api_routes(_shared_db)
|
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)
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ def render_comfy_monitor(state: AppState):
|
|||||||
_live_refreshables = state._live_refreshables
|
_live_refreshables = state._live_refreshables
|
||||||
|
|
||||||
def poll_all():
|
def poll_all():
|
||||||
|
try:
|
||||||
timeout_val = config.get('monitor_timeout', 0)
|
timeout_val = config.get('monitor_timeout', 0)
|
||||||
if timeout_val > 0:
|
if timeout_val > 0:
|
||||||
for key, start_time in list(state.live_toggles.items()):
|
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)
|
_live_checkboxes[key].set_value(False)
|
||||||
if key in _live_refreshables:
|
if key in _live_refreshables:
|
||||||
_live_refreshables[key].refresh()
|
_live_refreshables[key].refresh()
|
||||||
|
except RuntimeError:
|
||||||
|
pass # Parent slot deleted during refresh
|
||||||
|
|
||||||
ui.timer(300, poll_all)
|
ui.timer(300, poll_all)
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -437,6 +437,8 @@ def render_timeline_tab(state: AppState):
|
|||||||
render_timeline()
|
render_timeline()
|
||||||
|
|
||||||
# --- Poll for graph node clicks (JS → Python bridge) ---
|
# --- Poll for graph node clicks (JS → Python bridge) ---
|
||||||
|
graph_timer = None
|
||||||
|
|
||||||
async def _poll_graph_click():
|
async def _poll_graph_click():
|
||||||
if view_mode.value == 'Linear Log':
|
if view_mode.value == 'Linear Log':
|
||||||
return
|
return
|
||||||
@@ -446,6 +448,9 @@ def render_timeline_tab(state: AppState):
|
|||||||
'window.graphSelectedNode = null; v;'
|
'window.graphSelectedNode = null; v;'
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
# Deactivate timer if parent slot was deleted
|
||||||
|
if graph_timer is not None:
|
||||||
|
graph_timer.active = False
|
||||||
return
|
return
|
||||||
if not result:
|
if not result:
|
||||||
return
|
return
|
||||||
@@ -458,7 +463,7 @@ def render_timeline_tab(state: AppState):
|
|||||||
selected['node_id'] = node_id
|
selected['node_id'] = node_id
|
||||||
render_timeline.refresh()
|
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):
|
def _render_graphviz(dot_source: str, selected_node_id: str | None = None):
|
||||||
|
|||||||
Reference in New Issue
Block a user