Skip to content

Fix multiselect parameter format for TOPP tool compatibility#323

Merged
t0mdavid-m merged 3 commits intomainfrom
claude/streamlit-multiselect-ui-d7bm5
Jan 27, 2026
Merged

Fix multiselect parameter format for TOPP tool compatibility#323
t0mdavid-m merged 3 commits intomainfrom
claude/streamlit-multiselect-ui-d7bm5

Conversation

@t0mdavid-m
Copy link
Member

@t0mdavid-m t0mdavid-m commented Jan 27, 2026

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

Summary by CodeRabbit

  • Bug Fixes
    • Multiselect list parameters now display and sync correctly with stored parameter values, ensuring selections shown in the UI match what's saved.
    • Display-only selections are not persisted to the parameter store, preventing temporary UI controls from being written to saved configurations.

✏️ Tip: You can customize this high-level summary in your review settings.

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
Use default= parameter directly instead of manual session state initialization,
more consistent with how selectbox uses index= parameter.

https://claude.ai/code/session_016FpXUEwfPanXWu4CLrFLSA
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

display_TOPP_params now presents list-type TOPP parameters with a separate multiselect display key and an on_change callback that syncs the selected list into the main session_state key as a newline-joined string; ParameterManager.save_parameters skips keys ending with _display when persisting.

Changes

Cohort / File(s) Summary
Multiselect UI & state sync
src/workflow/StreamlitUI.py
Introduces a display_key for multiselect widgets; adds on_multiselect_change callback to join the display list into the main session_state key as a newline-separated string; initializes main key from current_values; falls back to text_area when no valid strings.
Parameter persistence
src/workflow/ParameterManager.py
Updates save_parameters to skip keys that end with _display, preventing multiselect display keys from being written to the saved JSON parameters.

Possibly related PRs

  • Fix list display bug #314: Addresses similar list-vs-string handling for TOPP parameters; introduces an original_is_list flag and converts loaded strings back to lists, related to multiselect state persistence.

Poem

🐰 I hop through keys both main and bright,
I gather lists by soft moonlight,
The display picks, the main one learns,
Joined by newlines, the value turns,
A tiny sync — a coder's delight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix multiselect parameter format for TOPP tool compatibility' directly and specifically describes the main change: converting Streamlit multiselect list output to newline-separated strings for TOPP tool compatibility.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/workflow/StreamlitUI.py (1)

868-890: Sync main TOPP param key from display selection on every render, not just on initialization.

The main key is only initialized when missing (line 889), which leaves a sync gap: if the key already exists from a prior parameter load and the current valid options have changed, the main key can retain stale/filtered-out values until the user changes the widget. This causes the saved TOPP parameter to diverge from the UI selection until user interaction.

Sync from display_key after the widget is rendered to ensure the main key always reflects the actual current selection:

🛠️ Proposed fix
                         cols[i].multiselect(
                             name,
                             options=sorted(p['valid_strings']),
                             default=current_values,
                             help=p["description"],
                             key=display_key,
                             on_change=on_multiselect_change,
                         )

-                        # Ensure main key has string value for ParameterManager
-                        if key not in st.session_state:
-                            st.session_state[key] = "\n".join(current_values)
+                        # Keep main key in sync with actual selection
+                        selected = st.session_state.get(display_key, current_values)
+                        st.session_state[key] = "\n".join(selected)

Skip keys ending in _display in save_parameters() to prevent multiselect
display keys from being incorrectly saved to JSON or compared with INI values.

https://claude.ai/code/session_016FpXUEwfPanXWu4CLrFLSA
@t0mdavid-m t0mdavid-m merged commit 39d9fa5 into main Jan 27, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments