From 3928f4d225326fdf84e1a836f24f8a2bed3e4049 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Wed, 25 Feb 2026 14:22:40 +0100 Subject: [PATCH] Fix select options not pushing to browser and remaining shallow copies - Use set_options() instead of direct .options assignment (3 locations) so dropdown changes actually reach the browser - Wrap res.json() in try/except for non-JSON server responses - Deep copy in create_batch and promote to match rest of codebase Co-Authored-By: Claude Opus 4.6 --- tab_batch_ng.py | 15 +++++++-------- tab_comfy_ng.py | 12 ++++++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/tab_batch_ng.py b/tab_batch_ng.py index 727c4b6..4d94d4f 100644 --- a/tab_batch_ng.py +++ b/tab_batch_ng.py @@ -119,7 +119,7 @@ def render_batch_processor(state: AppState): if new_path.exists(): ui.notify(f'File {new_name} already exists!', type='warning') return - first_item = data.copy() + first_item = copy.deepcopy(data) first_item.pop(KEY_PROMPT_HISTORY, None) first_item.pop(KEY_HISTORY_TREE, None) first_item[KEY_SEQUENCE_NUMBER] = 1 @@ -164,10 +164,9 @@ def render_batch_processor(state: AppState): if _src_cache['batch']: opts = {i: format_seq_label(s.get(KEY_SEQUENCE_NUMBER, i+1)) for i, s in enumerate(_src_cache['batch'])} - src_seq_select.options = opts - src_seq_select.set_value(0) + src_seq_select.set_options(opts, value=0) else: - src_seq_select.options = {} + src_seq_select.set_options({}) src_file_select.on_value_change(lambda _: _update_src()) _update_src() @@ -366,9 +365,9 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state, # Promote def promote(idx=i, s=seq): - single_data = s.copy() - single_data[KEY_PROMPT_HISTORY] = data.get(KEY_PROMPT_HISTORY, []) - single_data[KEY_HISTORY_TREE] = data.get(KEY_HISTORY_TREE, {}) + single_data = copy.deepcopy(s) + single_data[KEY_PROMPT_HISTORY] = copy.deepcopy(data.get(KEY_PROMPT_HISTORY, [])) + single_data[KEY_HISTORY_TREE] = copy.deepcopy(data.get(KEY_HISTORY_TREE, {})) single_data.pop(KEY_SEQUENCE_NUMBER, None) save_json(file_path, single_data) state.data_cache = single_data @@ -646,7 +645,7 @@ def _render_mass_update(batch_list, data, file_path, state: AppState): if idx is not None and 0 <= idx < len(batch_list): src = batch_list[idx] keys = [k for k in src.keys() if k != 'sequence_number'] - field_select.options = keys + field_select.set_options(keys) source_select.on_value_change(update_fields) update_fields() diff --git a/tab_comfy_ng.py b/tab_comfy_ng.py index 2c23c61..d431ac8 100644 --- a/tab_comfy_ng.py +++ b/tab_comfy_ng.py @@ -144,7 +144,11 @@ def _render_single_instance(state: AppState, instance_config: dict, index: int, None, lambda: _fetch_blocking(f'{comfy_url}/queue')) with status_container: if res is not None: - queue_data = res.json() + try: + queue_data = res.json() + except (ValueError, Exception): + ui.label('Invalid response from server').classes('text-negative') + return running_cnt = len(queue_data.get('queue_running', [])) pending_cnt = len(queue_data.get('queue_pending', [])) @@ -238,7 +242,11 @@ def _render_single_instance(state: AppState, instance_config: dict, index: int, if err is not None: ui.label(f'Error fetching image: {err}').classes('text-negative') return - history = res.json() + try: + history = res.json() + except (ValueError, Exception): + ui.label('Invalid response from server').classes('text-negative') + return if not history: ui.label('No history found.').classes('text-caption') return