Skip to content

Commit 5711f10

Browse files
committed
Fix multiselect parameter format for TOPP tool compatibility
The multiselect widget returns a list, but TOPP tools expect newline-separated strings. Use a separate key for the multiselect widget and sync to the original key as a newline-separated string via on_change callback. https://claude.ai/code/session_016FpXUEwfPanXWu4CLrFLSA
1 parent e5d9480 commit 5711f10

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/workflow/StreamlitUI.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,13 +869,30 @@ def display_TOPP_params(params: dict, num_cols):
869869
if len(p['valid_strings']) > 0:
870870
# Filter current values to only include valid options
871871
current_values = [v for v in p["value"] if v in p['valid_strings']]
872+
873+
# Create a temporary key for multiselect, then convert to newline string
874+
multiselect_key = f"{key}_multiselect"
875+
876+
# Initialize multiselect key from the main key if needed
877+
if multiselect_key not in st.session_state:
878+
st.session_state[multiselect_key] = current_values
879+
880+
# Define callback to sync multiselect list to newline-separated string
881+
def sync_multiselect_to_string(ms_key=multiselect_key, target_key=key):
882+
st.session_state[target_key] = "\n".join(st.session_state[ms_key])
883+
872884
cols[i].multiselect(
873885
name,
874886
options=sorted(p['valid_strings']),
875-
default=current_values,
887+
default=None, # Use session state
876888
help=p["description"],
877-
key=key,
889+
key=multiselect_key,
890+
on_change=sync_multiselect_to_string,
878891
)
892+
893+
# Initialize the string key if not present
894+
if key not in st.session_state:
895+
st.session_state[key] = "\n".join(current_values)
879896
else:
880897
# Fall back to text_area for freeform list input
881898
cols[i].text_area(

0 commit comments

Comments
 (0)