replace hardcoded panel selection indices in CompareV2 metrics#13277
replace hardcoded panel selection indices in CompareV2 metrics#13277pnaik1 wants to merge 1 commit intokubeflow:masterfrom
Conversation
|
Hi @pnaik1. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Pull request overview
Refactors CompareV2 metrics selection to remove hardcoded two-panel indexing and to resolve selected artifacts using stable run_id identity (with display_name fallback for older selections). This addresses #13270 by making panel-related logic more uniform and less fragile.
Changes:
- Introduces a shared
COMPARE_PANEL_COUNTconstant and replaces magic2literals in CompareV2 initialization. - Migrates
MetricsDropdownselection state to an array-driven approach (instead of separate first/second states) and adds a runtime guard for unexpected panel counts. - Adds
runId/idplumbing throughTwoLevelDropdownand updates artifact verification/equality to account forrunId.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/pages/CompareV2.tsx | Uses COMPARE_PANEL_COUNT, adds runId to selection equality, and refactors selection verification to prefer run_id. |
| frontend/src/lib/v2/CompareUtils.ts | Exports COMPARE_PANEL_COUNT to centralize compare panel sizing. |
| frontend/src/components/viewers/MetricsDropdown.tsx | Reworks selection handling to be array-based, adds middleCell, and resolves artifacts via runId when available. |
| frontend/src/components/viewers/MetricsDropdown.test.tsx | Updates/extends tests and adds a new test intended to cover runId-based resolution. |
| frontend/src/components/TwoLevelDropdown.tsx | Extends dropdown selection payload to include an optional runId sourced from an optional item id. |
|
/ok-to-test |
|
Panel validation bug using display name (discovered during investigation) Screen.Recording.2026-04-15.at.3.17.06.PM.movAfter: Screen.Recording.2026-04-15.at.3.52.17.PM.mov |
manaswinidas
left a comment
There was a problem hiding this comment.
Some frontend e2e tests are failing - can you look into them ?
|
@manaswinidas I think this is unrelated to my changes, I believe more of infra issue
|
|
/retest |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: pnaik1 <pnaik@redhat.com>
|
/retest |
manaswinidas
left a comment
There was a problem hiding this comment.
/lgtm
but the branch has conflicts now that #13282 is merged

Closes: #13270
Summary
[0]/[1]panel indices inMetricsDropdownwith a generic array-basedselectedItemsstateCOMPARE_PANEL_COUNTconstant fromCompareUtils.tsto eliminate magic2literals inCompareV2runIdtoSelectedItemandidtoDropdownItemso artifact lookup uses stablerun_ididentity instead ofdisplay_namegetVerifiedTwoPanelSelectioninCompareV2to useSet-based lookups withrun_id-first,display_namefallbackmiddleCellCSS class inMetricsDropdownto correctly style any panel that is neither the first nor lastrunId-based artifact resolution inMetricsDropdownWhy
The previous implementation hardcoded panel positions as
[0]and[1]throughoutMetricsDropdownandCompareV2, making it fragile and difficult to extend. Specifically:MetricsDropdownmaintained separatefirstSelectedItem/secondSelectedItemstate variables, meaningadding a third panel would require duplicating state and handler logic
getVerifiedTwoPanelSelectioniterated run artifacts comparing bydisplay_name, which is not a stableidentifier — runs with the same name could resolve to the wrong artifact
areSelectedArtifactsEqualdid not account forrunId, so selection equality checks could produce falsepositives
This change makes the panel count driven by a single constant, loops over panels uniformly, and anchors
artifact resolution to
run_idfor correctness.Verification
cd frontend && fnm exec --using .nvmrc -- npx prettier@3.8.1 --check
src/components/TwoLevelDropdown.tsx
src/components/viewers/MetricsDropdown.tsx
src/components/viewers/MetricsDropdown.test.tsx
src/lib/v2/CompareUtils.ts
src/pages/CompareV2.tsx
cd frontend && fnm exec --using .nvmrc -- npm run test:ui --
src/components/viewers/MetricsDropdown.test.tsx
src/pages/CompareV2.test.tsx
cd frontend && fnm exec --using .nvmrc -- npm run typecheck
cd frontend && fnm exec --using .nvmrc -- npm run lint
Checklist: