Skip to content

🎨 Palette: Use native max_selections in Team Lab multiselect - #67

Open
Gunnarguy wants to merge 1 commit into
mainfrom
palette-multiselect-max-selections-9454753673210713264
Open

Gunnarguy wants to merge 1 commit into
mainfrom
palette-multiselect-max-selections-9454753673210713264

Conversation

@Gunnarguy

@Gunnarguy Gunnarguy commented Jul 16, 2026

Copy link
Copy Markdown
Owner

🎨 Palette UX Improvement

💡 What:
Added the max_selections=4 parameter to the Streamlit st.multiselect component in the Team Lab section and removed the previous manual post-selection validation logic (which issued an st.warning and silently truncated the selection).

🎯 Why:
Relying on manual post-selection validation leads to poor UX. It allows the user to make an invalid action (selecting a 5th item) and then corrects them. Using the native max_selections parameter restricts the maximum number of items that can be selected, preventing the user from entering an invalid state in the first place, offering a smoother and more intuitive experience.

Accessibility:
Provides immediate, native feedback instead of a delayed warning toast.

📸 Before/After:
Before: User selects 5 items -> Gets warning -> Selection is truncated back to 4.
After: User selects 4 items -> Dropdown grays out remaining options with helper text "You can only select up to 4 options. Remove an option first."

(Also updated the .Jules/palette.md journal with this learning).


PR created automatically by Jules for task 9454753673210713264 started by @Gunnarguy

Summary by Sourcery

Use Streamlit's native max_selections limit for Team Lab multiselect and document the UX learning in the Palette journal.

New Features:

  • Enforce a maximum of four unit selections directly via the Team Lab multiselect component.

Enhancements:

  • Improve Team Lab help and empty-state messaging to better describe SP economy and defensive coverage analysis.

Documentation:

  • Add a Palette journal entry describing the UX benefits of using native max_selections in Streamlit multiselect components.

Replaces manual post-selection validation in the Team Lab view with Streamlit's native `max_selections=4` parameter for `st.multiselect`, improving UX by preventing invalid state entry.

Co-authored-by: Gunnarguy <110250624+Gunnarguy@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings July 16, 2026 08:19
@sourcery-ai

sourcery-ai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the Team Lab Streamlit multiselect to use the native max_selections constraint instead of manual validation, and records the UX learning in the Jules palette journal.

Sequence diagram for updated Team Lab multiselect max_selections behavior

sequenceDiagram
    actor User
    participant StreamlitApp
    participant StreamlitMultiselect
    participant TeamLabAnalysis

    StreamlitApp->>StreamlitMultiselect: st_multiselect(max_selections=4)
    User->>StreamlitMultiselect: select_units

    alt [user selects up to 4 units]
        StreamlitMultiselect-->>StreamlitApp: selected_variant_ids
        StreamlitApp->>TeamLabAnalysis: render_team_lab(selected_variant_ids)
    else [user attempts 5th selection]
        StreamlitMultiselect-->>User: [helper text and disabled options]
    end
Loading

File-Level Changes

Change Details Files
Replace manual post-selection validation for the Team Lab multiselect with Streamlit's native max_selections parameter.
  • Update the multiselect help text to describe analyzing up to 4 units and their combined SP economy and defensive coverage.
  • Add max_selections=4 to the Team Lab st.multiselect call to enforce the selection limit natively.
  • Remove the warning message and manual truncation logic that handled selections greater than 4.
  • Retain the empty-state st.info message that prompts users to select up to 4 units.
src/grandchase_meta_analyzer/explorer_app.py
Document the UX learning about using native selection limits in the internal Jules palette journal.
  • Add a dated journal entry describing the drawbacks of manual post-selection validation for multiselect components.
  • Recommend using the native max_selections parameter in Streamlit st.multiselect for better UX and to prevent invalid states.
.Jules/palette.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider extracting the repeated "Select up to 4 units…" messaging into a shared constant so the help text and empty-state info stay aligned if the wording or limit changes in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the repeated "Select up to 4 units…" messaging into a shared constant so the help text and empty-state info stay aligned if the wording or limit changes in the future.

## Individual Comments

### Comment 1
<location path=".Jules/palette.md" line_range="14" />
<code_context>
 **Action:** Utilize built-in visual aids via Streamlit's native Material Symbols shortcodes (e.g. `icon=":material/search:"` for search, `icon=":material/menu_book:"` for database views). This improves UX and ensures pixel-perfect, cross-browser compatibility across Safari and Chrome without needing custom CSS.
+
+## 2025-06-18 - Native Selection Limits in Streamlit Multiselect
+**Learning:** Relying on manual post-selection validation in Streamlit (e.g., showing a warning if a user selects too many items) leads to poor UX. It allows the user to make an invalid action and then corrects them.
+**Action:** Always use the native `max_selections` parameter in `st.multiselect` to restrict the maximum number of items that can be selected. This prevents the user from entering an invalid state in the first place, offering a smoother and more intuitive experience.
</code_context>
<issue_to_address>
**suggestion (typo):** Consider rephrasing the sentence about invalid actions for grammatical clarity.

The phrase "make an invalid action and then corrects them" is grammatically awkward because "them" refers to the user while "action" is the object. Consider rewording to something like "perform an invalid action and then be corrected" or "perform an invalid action and then correct it" so the subject–object relationship is clearer.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .Jules/palette.md
**Action:** Utilize built-in visual aids via Streamlit's native Material Symbols shortcodes (e.g. `icon=":material/search:"` for search, `icon=":material/menu_book:"` for database views). This improves UX and ensures pixel-perfect, cross-browser compatibility across Safari and Chrome without needing custom CSS.

## 2025-06-18 - Native Selection Limits in Streamlit Multiselect
**Learning:** Relying on manual post-selection validation in Streamlit (e.g., showing a warning if a user selects too many items) leads to poor UX. It allows the user to make an invalid action and then corrects them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (typo): Consider rephrasing the sentence about invalid actions for grammatical clarity.

The phrase "make an invalid action and then corrects them" is grammatically awkward because "them" refers to the user while "action" is the object. Consider rewording to something like "perform an invalid action and then be corrected" or "perform an invalid action and then correct it" so the subject–object relationship is clearer.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Team Lab UX in the Streamlit explorer app by enforcing the “up to 4 units” constraint directly in the st.multiselect widget, eliminating the previous post-selection warning + truncation behavior. It aligns the implementation with Streamlit’s native interaction model and documents the design learning in the Palette journal.

Changes:

  • Add max_selections=4 to the Team Lab “Units” multiselect and remove manual truncation/warning logic.
  • Refresh the Team Lab multiselect help text to better describe what the analysis covers (SP economy + defensive coverage).
  • Document the UX rationale for using native max_selections in .Jules/palette.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/grandchase_meta_analyzer/explorer_app.py Enforces the 4-unit selection cap via Streamlit’s native max_selections and removes manual validation/truncation.
.Jules/palette.md Adds a journal entry capturing the UX learning about native selection limits in Streamlit multiselects.

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