Skip to content

Add Case filtering to Browse Simulations with lightweight case names endpoint#130

Merged
tomvothecoder merged 8 commits intomainfrom
copilot/add-case-group-filtering
Mar 10, 2026
Merged

Add Case filtering to Browse Simulations with lightweight case names endpoint#130
tomvothecoder merged 8 commits intomainfrom
copilot/add-case-group-filtering

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

Description

Adds a URL-persistent Case filter to the Browse Simulations page with server-side filtering, a lightweight case names endpoint, and consistent URL state management.

  • Case filter on Browse page

    • Searchable dropdown populated from a new lightweight GET /cases/names endpoint (returns list[str] only, no nested simulation summaries).
    • Selection persists in URL via caseName query param using useSearchParams.
    • Server-side filtering via GET /simulations?case_name=<value>.
  • Backend additions

    • GET /cases/names — returns sorted case names without loading simulation relationships.
    • case_name and case_group query params on GET /simulations, using Simulation.case.has(...) to avoid double-joining alongside joinedload.
  • Browse filter correctness

    • Clear All clears caseName along with all other applied filters.
    • "Clear All" visibility accounts for active caseName in addition to appliedFilters.
  • URL state consistency

    • URL → state hydration covers the full FilterState surface (derived from createEmptyFilters()), preventing dropped filters on refresh/back-forward.
    • Query param sync uses a single setSearchParams path to avoid dual-writer drift.
  • Scope

    • Changes apply to the Browse Simulations page only; the All Simulations page is unchanged.
    • No schema or database migration changes.

Checklist

  • Code follows project style guidelines
  • Self-reviewed code
  • No new warnings
  • Tests added or updated (if needed)
  • All tests pass (locally and CI/CD)
  • Documentation/comments updated (if needed)
  • Breaking change noted (if applicable)

Deployment Notes (if any)

No schema or migration changes. Backend adds a new GET /cases/names endpoint. Frontend behavior update only.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Enhancement] Add Case and Case Group Filtering to Simulation Browser</issue_title>
<issue_description>## Summary

Add Case and Case Group filters to the Simulation Browser to allow users to narrow execution results by experiment context while preserving the execution-centric design.

No schema changes required.

Motivation

The Simulation Browser is execution-focused, but users often need to:

  • View all executions within a specific case
  • Compare executions inside a case
  • Narrow large datasets efficiently

Currently, there is no direct way to filter executions by Case or Case Group, which increases noise and reduces usability at scale.

Filtering enables contextual narrowing without changing the execution-first hierarchy.

Scope

1. Add Filters to Simulation Browser

Add the following filters:

  • Case

    • Searchable dropdown or typeahead
    • Filters by case_id or case_name
  • Case Group (if implemented)

    • Dropdown or searchable select
    • Filters by case_group

2. Behavior

  • Filters operate at the execution level
  • Filtering does not change column order or visual hierarchy
  • Execution ID remains primary identifier
  • Filters must be combinable with existing filters (status, canonical, etc.)
  • Filtering state must persist in query parameters

3. Data Usage

  • Use existing query endpoints
  • No additional heavy joins beyond what is already required for listing simulations

Non-Goals

  • No grouping or aggregation by Case
  • No case-level summaries
  • No new routes
  • No schema or database changes
  • No redesign of simulation tables or cards</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.

Copilot AI and others added 2 commits March 6, 2026 01:22
…t filter state in URL search params

Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
Copilot AI changed the title [WIP] Add case and case group filtering to simulation browser Add Case and Case Group filtering to Simulation Browser Mar 6, 2026
@tomvothecoder
Copy link
Collaborator

@copilot Implement Case-based filtering on the Browse Simulations page.

Important context:

  • Backend support for case_name query param already exists on GET /api/v1/simulations
  • URL persistence using useSearchParams is already implemented
  • This task applies specifically to the Browse Simulations page
  • Do NOT modify the “All Simulations” page logic in the existing PR

Goal

Add a Case filter to the Browse Simulations page that:

  • Filters simulations by Case
  • Persists selection in the URL
  • Uses existing backend query param support
  • Does NOT include Case Group filtering

Requirements

1. UI — Add Case Filter Control

On the Browse Simulations page:

  • Add a searchable dropdown labeled Case
  • Populate options from existing cases endpoint (e.g., GET /cases)
  • Display case name as the visible label
  • Value must map to case_name
  • Do NOT use free text input

2. URL Query Param Integration

Use useSearchParams.

  • Query param key: caseName
  • When selected:
    • Update URL: ?caseName=<value>
  • When cleared:
    • Remove caseName from URL

Selection must:

  • Persist on refresh
  • Be shareable via URL
  • Initialize correctly from URL on first render

3. Data Fetching

When caseName exists:

Call:

GET /api/v1/simulations?case_name=<value>

When absent:

Call:

GET /api/v1/simulations

Do NOT implement client-side filtering.

Filtering must be server-side only.

4. State Rules

  • Filter state must be derived from URL only
  • No redundant useState
  • URL is the single source of truth

5. Exclusions

  • Do NOT add Case Group filtering
  • Do NOT modify backend logic
  • Do NOT change the All Simulations page
  • Do NOT introduce new API fields

Acceptance Criteria

  • Selecting a Case filters simulations correctly
  • URL updates immediately on selection
  • Refresh preserves filter
  • Clearing filter restores full list
  • No regressions on existing filters

…e` query

Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
Copilot AI changed the title Add Case and Case Group filtering to Simulation Browser Browse Simulations: URL-driven Case filter with server-side case_name query Mar 9, 2026
@tomvothecoder tomvothecoder requested a review from Copilot March 9, 2026 21:30
Copilot AI changed the title Browse Simulations: URL-driven Case filter with server-side case_name query Add Browse-page Case filter with URL state and server-side simulation query Mar 9, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a URL-persistent Case filter to the Browse Simulations page and wires it to
server-side filtering on the simulations list endpoint.

Changes:

  • Browse page now fetches simulations locally and applies case_name filtering
    server-side when caseName is present in the URL.
  • Adds a Case dropdown to the Browse filter panel with options sourced from
    /api/v1/cases.
  • Backend /simulations endpoint now supports case_name and case_group
    query params, with new test coverage.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/features/simulations/api/api.ts Adds /cases API constant and listCases() helper.
frontend/src/features/simulations/SimulationsPage.tsx Switches case filters to be URL-driven via useSearchParams.
frontend/src/features/browse/routes.tsx Removes simulations prop plumb-through; BrowsePage now fetches.
frontend/src/features/browse/components/BrowseFiltersSidePanel.tsx Adds Case dropdown (via MultiSelect) hooked to URL state.
frontend/src/features/browse/BrowsePage.tsx Implements page-local fetching of cases + simulations and URL-driven caseName.
backend/app/features/simulation/api.py Adds case_name / case_group query filtering to list simulations.
backend/tests/features/simulation/test_api.py Adds tests for filtering by case_name and case_group (including combined).

Comment on lines +87 to +123
@@ -97,14 +96,42 @@ export const SimulationsPage = ({ simulations }: SimulationsPageProps) => {
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
const navigate = useNavigate();

// Read filter state from URL query parameters.
const caseNameFilter = searchParams.get('caseName') ?? '';
const caseGroupFilter = searchParams.get('caseGroup') ?? '';

/**
* Update a single filter value and persist it in the URL query params.
* Empty values remove the parameter from the URL.
*/
const setFilter = (key: string, value: string) => {
setSearchParams(
(prev) => {
const next = new URLSearchParams(prev);
if (value) {
next.set(key, value);
} else {
next.delete(key);
}
return next;
},
{ replace: true },
);
};

const setCaseNameFilter = (v: string) => setFilter('caseName', v);
const setCaseGroupFilter = (v: string) => setFilter('caseGroup', v);
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

This page now persists caseName/caseGroup filters in the URL via useSearchParams, which changes All Simulations behavior (filter state becomes URL-driven/persistent). The PR description says Browse-only changes; either update the description/scope or revert this URL persistence from SimulationsPage to keep All Simulations unchanged.

Copilot uses AI. Check for mistakes.
Copilot AI changed the title Add Browse-page Case filter with URL state and server-side simulation query Refactor Browse data flow to URL-driven simulations queries Mar 9, 2026
Copilot AI changed the title Refactor Browse data flow to URL-driven simulations queries Decouple Browse data fetching from App-level simulations state Mar 9, 2026
@tomvothecoder
Copy link
Collaborator

@copilot Address PR review comments

…er options race

Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
@tomvothecoder tomvothecoder marked this pull request as ready for review March 9, 2026 21:49
@tomvothecoder tomvothecoder requested a review from Copilot March 9, 2026 21:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

@tomvothecoder
Copy link
Collaborator

@copilot Address latest PR review comments

…ackend case filters

Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 9, 2026

@copilot Address latest PR review comments

Addressed in 4a9e1c4:

  1. Backend (api.py) — Replaced explicit join(Simulation.case) + filter(Case.name == ...) with Simulation.case.has(name=...) / Simulation.case.has(case_group=...) to avoid double-joining the Case table alongside joinedload.

  2. Frontend (BrowsePage.tsx) — Consolidated URL param updates to a single setSearchParams mechanism. Removed the navigate() effect and useLocation dependency. Both handleCaseNameChange and the filter-sync effect now use setSearchParams with the functional updater form to preserve other params.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

@tomvothecoder
Copy link
Collaborator

@copilot Address PR reviews and double-check code to ensure no more bugs or possible bugs.

Copilot AI changed the title Add Case filtering to Browse Simulations page Stabilize Browse filter URL state and case-filter behavior Mar 10, 2026
@tomvothecoder
Copy link
Collaborator

@copilot Address PR reviews and double-check code to ensure no more bugs or possible bugs.

…es endpoint

Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot Address PR reviews and double-check code to ensure no more bugs or possible bugs.

Addressed all three review comments in 0cd9ce0:

  1. handleResetFilters() now clears caseName from URL params. "Clear All" visibility accounts for active caseName.
  2. Lightweight /cases/names endpoint added — returns list[str] instead of full CaseOut with nested simulations. Browse page uses listCaseNames() for the dropdown.
  3. URL→filter hydration now derives keys from createEmptyFilters() instead of a hardcoded subset, so all FilterState keys persist across refresh/back-forward.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Stabilize Browse filter URL state and case-filter behavior Add Case filtering to Browse Simulations with lightweight case names endpoint Mar 10, 2026
@tomvothecoder tomvothecoder merged commit 18999c9 into main Mar 10, 2026
1 check passed
@tomvothecoder tomvothecoder deleted the copilot/add-case-group-filtering branch March 10, 2026 17:07
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.

[Enhancement] Add Case and Case Group Filtering to Simulation Browser

3 participants