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 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 14:22:40 +01:00
parent a0d58d8982
commit 3928f4d225
2 changed files with 17 additions and 10 deletions

View File

@@ -119,7 +119,7 @@ def render_batch_processor(state: AppState):
if new_path.exists(): if new_path.exists():
ui.notify(f'File {new_name} already exists!', type='warning') ui.notify(f'File {new_name} already exists!', type='warning')
return return
first_item = data.copy() first_item = copy.deepcopy(data)
first_item.pop(KEY_PROMPT_HISTORY, None) first_item.pop(KEY_PROMPT_HISTORY, None)
first_item.pop(KEY_HISTORY_TREE, None) first_item.pop(KEY_HISTORY_TREE, None)
first_item[KEY_SEQUENCE_NUMBER] = 1 first_item[KEY_SEQUENCE_NUMBER] = 1
@@ -164,10 +164,9 @@ def render_batch_processor(state: AppState):
if _src_cache['batch']: if _src_cache['batch']:
opts = {i: format_seq_label(s.get(KEY_SEQUENCE_NUMBER, i+1)) opts = {i: format_seq_label(s.get(KEY_SEQUENCE_NUMBER, i+1))
for i, s in enumerate(_src_cache['batch'])} for i, s in enumerate(_src_cache['batch'])}
src_seq_select.options = opts src_seq_select.set_options(opts, value=0)
src_seq_select.set_value(0)
else: else:
src_seq_select.options = {} src_seq_select.set_options({})
src_file_select.on_value_change(lambda _: _update_src()) src_file_select.on_value_change(lambda _: _update_src())
_update_src() _update_src()
@@ -366,9 +365,9 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
# Promote # Promote
def promote(idx=i, s=seq): def promote(idx=i, s=seq):
single_data = s.copy() single_data = copy.deepcopy(s)
single_data[KEY_PROMPT_HISTORY] = data.get(KEY_PROMPT_HISTORY, []) single_data[KEY_PROMPT_HISTORY] = copy.deepcopy(data.get(KEY_PROMPT_HISTORY, []))
single_data[KEY_HISTORY_TREE] = data.get(KEY_HISTORY_TREE, {}) single_data[KEY_HISTORY_TREE] = copy.deepcopy(data.get(KEY_HISTORY_TREE, {}))
single_data.pop(KEY_SEQUENCE_NUMBER, None) single_data.pop(KEY_SEQUENCE_NUMBER, None)
save_json(file_path, single_data) save_json(file_path, single_data)
state.data_cache = 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): if idx is not None and 0 <= idx < len(batch_list):
src = batch_list[idx] src = batch_list[idx]
keys = [k for k in src.keys() if k != 'sequence_number'] 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) source_select.on_value_change(update_fields)
update_fields() update_fields()

View File

@@ -144,7 +144,11 @@ def _render_single_instance(state: AppState, instance_config: dict, index: int,
None, lambda: _fetch_blocking(f'{comfy_url}/queue')) None, lambda: _fetch_blocking(f'{comfy_url}/queue'))
with status_container: with status_container:
if res is not None: 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', [])) running_cnt = len(queue_data.get('queue_running', []))
pending_cnt = len(queue_data.get('queue_pending', [])) 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: if err is not None:
ui.label(f'Error fetching image: {err}').classes('text-negative') ui.label(f'Error fetching image: {err}').classes('text-negative')
return return
history = res.json() try:
history = res.json()
except (ValueError, Exception):
ui.label('Invalid response from server').classes('text-negative')
return
if not history: if not history:
ui.label('No history found.').classes('text-caption') ui.label('No history found.').classes('text-caption')
return return