feat: standardize chart legend lists#1141
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on standardizing and enhancing the chart displays within the application. It introduces a new Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a standardized ChartLegend component to improve UI consistency, and refactors several existing chart components to use it. The changes are a good step towards a more maintainable frontend. My review focuses on a few areas: an incomplete refactoring in one of the components, potential UI layout changes due to default props, and security and reliability improvements for the new test script.
| interface LegendItem { | ||
| index: number; | ||
| name: string; | ||
| color: string; | ||
| throughput: number; | ||
| requestCount: number; | ||
| } |
There was a problem hiding this comment.
While this PR aims to standardize chart legends, this component (FastestPerformersCard) seems to have been missed in the refactoring. It still defines its own ChartLegend component internally. To complete the standardization, this component should be updated to use the new shared ChartLegend component from chart-legend.tsx. This would make this LegendItem interface and the local ChartLegend component obsolete.
scripts/capture-dashboard.js
Outdated
| await page.fill('[data-testid="sign-in-email"]', '[email protected]'); | ||
| await page.fill('[data-testid="sign-in-password"]', 'pwd123456'); |
There was a problem hiding this comment.
Hardcoding credentials is a security risk. These values should be loaded from environment variables to avoid exposing them in the source code.
| await page.fill('[data-testid="sign-in-email"]', '[email protected]'); | |
| await page.fill('[data-testid="sign-in-password"]', 'pwd123456'); | |
| await page.fill('[data-testid="sign-in-email"]', process.env.TEST_USER_EMAIL || '[email protected]'); | |
| await page.fill('[data-testid="sign-in-password"]', process.env.TEST_USER_PASSWORD || 'pwd123456'); |
scripts/capture-dashboard.js
Outdated
|
|
||
| await page.click('button[type="submit"]'); | ||
|
|
||
| await page.waitForTimeout(8000); |
There was a problem hiding this comment.
Using a fixed timeout with waitForTimeout can lead to flaky tests. If the page loads slower, the test might fail. If it loads faster, the test waits unnecessarily long. It's better to wait for a specific element to be visible or for network activity to be idle.
| await page.waitForTimeout(8000); | |
| await page.waitForLoadState('networkidle'); |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request does a great job of standardizing the chart legends by introducing a reusable ChartLegend component. The refactoring across multiple chart components will improve maintainability and ensure a consistent user experience.
I've left a few comments on potential improvements:
- Using a more robust
keyfor list rendering in the newChartLegendcomponent. - Correcting some duplicated color definitions in chart constants.
- Improving the new Playwright test script by removing hardcoded credentials and brittle waits.
Additionally, while the PR aims to standardize legends, the fastest-performers-card.tsx component still uses its own local legend implementation. To fully achieve the goal of this PR, it would be beneficial to refactor this component to use the new shared ChartLegend as well.
Overall, this is a solid improvement to the dashboard's codebase.
| }} | ||
| > | ||
| {items.map((item) => ( | ||
| <div key={item.name} className='grid w-full grid-cols-[auto_auto_1fr_auto] items-start gap-3'> |
There was a problem hiding this comment.
Using item.name as the key for mapped elements can lead to issues if names are not unique, which can cause incorrect rendering behavior in React. A more robust key would combine the name with another unique attribute like the index.
| <div key={item.name} className='grid w-full grid-cols-[auto_auto_1fr_auto] items-start gap-3'> | |
| <div key={item.index !== undefined ? `${item.name}-${item.index}` : item.name} className='grid w-full grid-cols-[auto_auto_1fr_auto] items-start gap-3'> |
| import type { TimePeriod } from '@/components/time-period-selector'; | ||
| import { ChartLegend } from './chart-legend'; | ||
|
|
||
| const COLORS = ['var(--chart-1)', 'var(--chart-2)', 'var(--chart-3)', 'var(--chart-4)', 'var(--chart-5)', 'var(--chart-1)']; |
There was a problem hiding this comment.
The COLORS array contains a duplicate value (var(--chart-1)). This will cause the sixth item in the chart to have the same color as the first, which might be confusing for users. It should likely be var(--chart-6) to maintain color uniqueness.
| const COLORS = ['var(--chart-1)', 'var(--chart-2)', 'var(--chart-3)', 'var(--chart-4)', 'var(--chart-5)', 'var(--chart-1)']; | |
| const COLORS = ['var(--chart-1)', 'var(--chart-2)', 'var(--chart-3)', 'var(--chart-4)', 'var(--chart-5)', 'var(--chart-6)']; |
frontend/src/features/dashboard/components/requests-by-model-chart.tsx
Outdated
Show resolved
Hide resolved
frontend/src/features/dashboard/components/tokens-by-api-key-chart.tsx
Outdated
Show resolved
Hide resolved
frontend/src/features/dashboard/components/tokens-by-model-chart.tsx
Outdated
Show resolved
Hide resolved
…ase/v0.9.x * 'release/v0.9.x' of github.com:NekoNuo/axonhub: doc: add request processing (looplj#1155) chore(codex): upgrade codex ua version (looplj#1151) chore: update VERSION to v0.9.22 [skip ci] fix: anthropic adaptive thinking effort did not pass to other outbound (looplj#1150) feat: add cli + skill, close looplj#1085 (looplj#1149) chore: add freebsd support to releases (looplj#1146) feat: standardize chart legend lists (looplj#1141)
Summary
Standardize chart legend lists across the dashboard by introducing a reusable
ChartLegendcomponent and refactoring all charts to use consistent legend styling.Purpose
Unify how chart legends are displayed across all dashboard charts by creating a shared component and standardizing legend layouts, while fixing related bugs.
Changes
New Components
Refactoring
ChartLegendcomponentBug Fixes
fastest-performers-card.tsx(missingLegendIteminterface)