Add Case filtering to Browse Simulations with lightweight case names endpoint#130
Conversation
…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 Implement Case-based filtering on the Browse Simulations page. Important context:
GoalAdd a Case filter to the Browse Simulations page that:
Requirements1. UI — Add Case Filter ControlOn the Browse Simulations page:
2. URL Query Param IntegrationUse
Selection must:
3. Data FetchingWhen Call:
When absent: Call:
Do NOT implement client-side filtering. Filtering must be server-side only. 4. State Rules
5. Exclusions
Acceptance Criteria
|
…e` query Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
case_name query
case_name queryThere was a problem hiding this comment.
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_namefiltering
server-side whencaseNameis present in the URL. - Adds a Case dropdown to the Browse filter panel with options sourced from
/api/v1/cases. - Backend
/simulationsendpoint now supportscase_nameandcase_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). |
| @@ -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); | |||
There was a problem hiding this comment.
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 Address PR review comments |
…er options race Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
|
@copilot Address latest PR review comments |
…ackend case filters Co-authored-by: tomvothecoder <25624127+tomvothecoder@users.noreply.github.com>
Addressed in 4a9e1c4:
|
|
@copilot Address PR reviews and double-check code to ensure no more bugs or possible bugs. |
|
@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>
Addressed all three review comments in 0cd9ce0:
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
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
GET /cases/namesendpoint (returnslist[str]only, no nested simulation summaries).caseNamequery param usinguseSearchParams.GET /simulations?case_name=<value>.Backend additions
GET /cases/names— returns sorted case names without loading simulation relationships.case_nameandcase_groupquery params onGET /simulations, usingSimulation.case.has(...)to avoid double-joining alongsidejoinedload.Browse filter correctness
Clear AllclearscaseNamealong with all other applied filters.caseNamein addition toappliedFilters.URL state consistency
FilterStatesurface (derived fromcreateEmptyFilters()), preventing dropped filters on refresh/back-forward.setSearchParamspath to avoid dual-writer drift.Scope
Checklist
Deployment Notes (if any)
No schema or migration changes. Backend adds a new
GET /cases/namesendpoint. Frontend behavior update only.Original prompt
💡 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.