Skip to content

🎨 Palette: Refactor st.multiselect to use native max_selections constraint - #60

Open
Gunnarguy wants to merge 1 commit into
mainfrom
palette-ux-max-selections-14902790406424800946
Open

Gunnarguy wants to merge 1 commit into
mainfrom
palette-ux-max-selections-14902790406424800946

Conversation

@Gunnarguy

@Gunnarguy Gunnarguy commented Jul 8, 2026

Copy link
Copy Markdown
Owner

🎨 Palette: Refactor st.multiselect to use native max_selections constraint

💡 What: Replaced manual retroactive warnings for selection limits in the Team Lab unit picker with Streamlit's native max_selections=4 argument. Additionally, added a magnifying glass icon to the empty state message.
🎯 Why: Allowing users to select a 5th element only to immediately slice it and show a warning is a frustrating interaction. The native constraint prevents the invalid selection upfront, creating a smoother and more expected user experience. The empty state icon creates better visual hierarchy.
📸 Before/After: N/A
♿ Accessibility: Improves input constraint predictability for users.


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

Summary by Sourcery

Refactor the Team Lab unit multiselect to rely on Streamlit’s native selection limit and improve its empty-state messaging.

New Features:

  • Add a search icon to the Team Lab empty-state informational banner for better visual hierarchy.

Enhancements:

  • Use Streamlit’s native max_selections constraint for the Team Lab unit multiselect instead of manual post-selection truncation and warnings.
  • Clarify the Team Lab unit picker help and empty-state copy to emphasize SP economy and defensive coverage.
  • Document a new Palette learning about preferring native Streamlit input constraints over custom validation logic.

…raint

💡 What: Replaced manual retroactive warnings for selection limits in the Team Lab unit picker with Streamlit's native `max_selections=4` argument. Additionally, added a magnifying glass icon to the empty state message.
🎯 Why: Allowing users to select a 5th element only to immediately slice it and show a warning is a frustrating interaction. The native constraint prevents the invalid selection upfront, creating a smoother and more expected user experience. The empty state icon creates better visual hierarchy.
📸 Before/After: N/A
♿ Accessibility: Improves input constraint predictability for users.

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 8, 2026 07:54
@sourcery-ai

sourcery-ai Bot commented Jul 8, 2026

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

Reviewer's Guide

Refactors the Team Lab unit picker to rely on Streamlit's native max_selections constraint instead of manual truncation and warnings, and updates empty-state messaging and the Palette design log accordingly.

Sequence diagram for updated Team Lab multiselect constraint

sequenceDiagram
    actor User
    participant StreamlitApp
    participant StreamlitMultiselect

    User->>StreamlitApp: render_team_lab
    StreamlitApp->>StreamlitMultiselect: st.multiselect(max_selections=4)
    User->>StreamlitMultiselect: select_unit
    StreamlitMultiselect-->>User: [selection accepted up to 4 units]
    StreamlitMultiselect-->>StreamlitApp: selected_variant_ids
    alt [selected_variant_ids empty]
        StreamlitApp->>User: st.info(icon=:material/search:)
    else [selected_variant_ids not empty]
        StreamlitApp->>User: render Team Lab analysis
    end
Loading

Flow diagram for render_team_lab empty state and selection handling

flowchart TD
    A[User opens Team Lab] --> B[st.multiselect with max_selections 4]
    B --> C{selected_variant_ids empty?}
    C -- Yes --> D[st.info Select up to 4 units to inspect SP economy and defensive coverage. icon :material/search:]
    C -- No --> E[Filter roster_df by selected_variant_ids]
    E --> F[Render Team Lab analysis]
Loading

File-Level Changes

Change Details Files
Use Streamlit's native max_selections constraint for Team Lab unit multiselect instead of manual validation.
  • Pass max_selections=4 to the unit multiselect widget to enforce the selection limit natively.
  • Update the multiselect help text to describe the 4-unit analysis constraint more clearly.
  • Remove post-selection warning and slicing logic that previously truncated selections beyond four items.
src/grandchase_meta_analyzer/explorer_app.py
Improve empty-state messaging and document the design decision in the Palette guide.
  • Add a search Material icon to the Team Lab empty-state st.info banner to improve visual hierarchy.
  • Document the new guideline favoring native Streamlit input constraints over manual validation in the Palette markdown.
src/grandchase_meta_analyzer/explorer_app.py
.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:

  • Double-check that the Streamlit version used in all deployment environments supports the max_selections argument on st.multiselect, as this change now depends on that behavior for enforcing the limit.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Double-check that the Streamlit version used in all deployment environments supports the `max_selections` argument on `st.multiselect`, as this change now depends on that behavior for enforcing the limit.

## Individual Comments

### Comment 1
<location path=".Jules/palette.md" line_range="10" />
<code_context>
 ## 2025-06-17 - Empty State Visual Differentiation
 **Learning:** Default informational banners (like Streamlit's `st.info`) for empty states can create a sterile user experience when repeated frequently across many data tables or search results. However, introducing completely custom HTML/CSS violates design constraints. Additionally, standard unicode emojis can render inconsistently or fail completely on Safari.
 **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.
+
</code_context>
<issue_to_address>
**suggestion (typo):** Consider capitalizing "Unicode" as a proper noun.

Here it refers to the Unicode standard, so please capitalize it in this phrase for correctness.

```suggestion
**Learning:** Default informational banners (like Streamlit's `st.info`) for empty states can create a sterile user experience when repeated frequently across many data tables or search results. However, introducing completely custom HTML/CSS violates design constraints. Additionally, standard Unicode emojis can render inconsistently or fail completely on Safari.
```
</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
@@ -9,3 +9,7 @@
## 2025-06-17 - Empty State Visual Differentiation
**Learning:** Default informational banners (like Streamlit's `st.info`) for empty states can create a sterile user experience when repeated frequently across many data tables or search results. However, introducing completely custom HTML/CSS violates design constraints. Additionally, standard unicode emojis can render inconsistently or fail completely on Safari.

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 capitalizing "Unicode" as a proper noun.

Here it refers to the Unicode standard, so please capitalize it in this phrase for correctness.

Suggested change
**Learning:** Default informational banners (like Streamlit's `st.info`) for empty states can create a sterile user experience when repeated frequently across many data tables or search results. However, introducing completely custom HTML/CSS violates design constraints. Additionally, standard unicode emojis can render inconsistently or fail completely on Safari.
**Learning:** Default informational banners (like Streamlit's `st.info`) for empty states can create a sterile user experience when repeated frequently across many data tables or search results. However, introducing completely custom HTML/CSS violates design constraints. Additionally, standard Unicode emojis can render inconsistently or fail completely on Safari.

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

Refactors the Team Lab unit multiselect in the Streamlit explorer app to rely on Streamlit’s native selection limiting, improving the input experience and simplifying the surrounding UI logic.

Changes:

  • Replaced manual “select >4 then truncate + warn” behavior with st.multiselect(max_selections=4).
  • Improved the Team Lab empty-state banner by adding a Material icon and tightening copy.
  • Documented the UX guideline to prefer native Streamlit input constraints over retroactive validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/grandchase_meta_analyzer/explorer_app.py Uses Streamlit’s native max_selections for the Team Lab picker and updates the empty-state message/icon.
.Jules/palette.md Adds a Palette learning entry documenting the preference for native Streamlit input constraints.

Comment on lines 3302 to +3303
if not selected_variant_ids:
st.info("Select up to 4 units to inspect SP economy and defensive coverage.")
st.info("Select up to 4 units to inspect SP economy and defensive coverage.", icon=":material/search:")
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