Skip to content

feat(website): Add segment presence filter for multi-segmented organisms#5841

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-segment-presence-filter
Draft

feat(website): Add segment presence filter for multi-segmented organisms#5841
Copilot wants to merge 3 commits intomainfrom
copilot/add-segment-presence-filter

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Implementation Plan: Segment Presence Filter

Understanding the Current System

  • Explored how segment length fields are configured
  • Understood that length fields are metadata fields with rangeSearch: true
  • Found that segments are defined in referenceGenome.nucleotideSequences
  • Identified that SearchForm.tsx is where filters are rendered
  • Confirmed that getSuborganismSegmentAndGeneInfo() provides segment information

Implementation Tasks

  • Create a new SegmentPresenceField component
  • Add the component to SearchForm.tsx before mutation field (for multi-segmented organisms)
  • Implement checkbox UI for selecting required segments
  • Set length filters (e.g., {segmentName}LengthFrom=1) when segments are selected
  • Add tests for the new component
  • Test UI manually with screenshots
  • Address code review feedback

Changes Made

  1. Created SegmentPresenceField.tsx component that:

    • Displays checkboxes for each segment in multi-segmented organisms
    • Sets {segmentName}LengthFrom=1 when a segment is checked
    • Clears the length filter when unchecked
    • Syncs with existing length filter values from URL or other sources
    • Uses DisabledUntilHydrated on individual checkboxes to prevent race conditions in Playwright tests
    • Extracted minimum length value to named constant
  2. Updated SearchForm.tsx to:

    • Import the new SegmentPresenceField component
    • Conditionally render it before the mutation field when organism is multi-segmented
  3. Added comprehensive tests in SegmentPresenceField.spec.tsx covering:

    • Rendering all segments
    • Checking/unchecking segments
    • Setting/clearing length filters
    • Handling existing length filter values
    • Multiple segment selections

UI Preview

Segment Presence Filter UI

The new "Required segments" filter provides an intuitive way to search for sequences with specific segments present.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create a Segment presence filter checkbox for multi-segmented viruses and remove or decrease the size length check boxes</issue_title>
<issue_description>Currently users need to set length to >0 to search for entries that include a specific segment. This is tedious, ugly for organisms with multiple segments (as the length filter is very large) and isnt intuitive.

We should add a filter called Required segments where users can select multiple segments and this will set the length filter for users once selected (if someone has a better name please add a comment :-) )

This new component should be added to the search form if an organisms is multi-segmented: https://github.com/loculus-project/loculus/blob/main/website/src/components/SearchPage/SearchForm.tsx - perhaps above the mutations field</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

🚀 Preview: Add preview label to enable

Copilot AI and others added 2 commits January 15, 2026 16:16
Co-authored-by: anna-parker <50943381+anna-parker@users.noreply.github.com>
- Extract hardcoded '1' to MINIMUM_SEGMENT_LENGTH constant
- Fix DisabledUntilHydrated usage by wrapping each checkbox individually
- Remove unused import from test file

Co-authored-by: anna-parker <50943381+anna-parker@users.noreply.github.com>
Copilot AI changed the title [WIP] Add segment presence filter checkbox for multi-segmented viruses feat(website): Add segment presence filter for multi-segmented organisms Jan 15, 2026
Copilot AI requested a review from anna-parker January 15, 2026 16:31
@anna-parker anna-parker added the preview Triggers a deployment to argocd label Jan 15, 2026
@anna-parker
Copy link
Contributor

This looks nice but doesnt actually work

@anna-parker anna-parker removed the preview Triggers a deployment to argocd label Jan 15, 2026
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.

Create a Segment presence filter checkbox for multi-segmented viruses and remove or decrease the size length check boxes

2 participants