Skip to content

fix(studio): Consolidate StatusBadge logic#326

Merged
steramae-nvidia merged 2 commits into
mainfrom
steramae/astd-233-unify-the-statusbadge-components
Jun 13, 2026
Merged

fix(studio): Consolidate StatusBadge logic#326
steramae-nvidia merged 2 commits into
mainfrom
steramae/astd-233-unify-the-statusbadge-components

Conversation

@steramae-nvidia

@steramae-nvidia steramae-nvidia commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-06-12 at 4 23 02 PM

Summary by CodeRabbit

  • New Features

    • Status badges now accept configurable mappings with custom labels, colors, and optional icons.
    • Added configurable fallback handling and label override support.
  • Tests

    • Expanded tests for config-driven badge behavior: known/unknown statuses, icon presence, fallback behavior, label overrides, and case-sensitivity.
  • Refactor

    • Unified status badge usage across the app for consistent rendering and reduced duplication.

Signed-off-by: Sean Teramae <steramae@nvidia.com>
@steramae-nvidia steramae-nvidia requested review from a team as code owners June 12, 2026 23:19
@github-actions github-actions Bot added the fix label Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0efd00da-e4f3-4275-9598-3d3bee7c09bf

📥 Commits

Reviewing files that changed from the base of the PR and between 2e697be and 09460af.

📒 Files selected for processing (1)
  • web/packages/common/src/components/StatusBadge/StatusBadge.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/packages/common/src/components/StatusBadge/StatusBadge.test.tsx

📝 Walkthrough

Walkthrough

StatusBadge is extended to accept an optional config mapping (StatusConfigEntry) and fallback; badge resolution and rendering now use that config or the legacy mapping. Two consumer components (IntakeTelemetryStatusBadge, CustomizationStatusBadge) are refactored to use the shared StatusBadge. Tests added for the config-driven path.

Changes

StatusBadge Config-Driven Consolidation

Layer / File(s) Summary
StatusBadge config contract
web/packages/common/src/components/StatusBadge/badgeStatus.tsx, web/packages/common/src/components/StatusBadge/index.tsx
StatusConfigEntry interface defines badge metadata (label, color, optional icon) and is exported/re-exported.
StatusBadge component enhancement
web/packages/common/src/components/StatusBadge/index.tsx
Props expanded to accept optional statusConfig Record, fallback entry, and label override. Badge resolution branches to use provided statusConfig (with fallback/default) or the existing badgeStatus mapping. Rendering uses resolved color, icon, and label.
StatusBadge config-driven tests
web/packages/common/src/components/StatusBadge/StatusBadge.test.tsx
New test group covers config label rendering, icon presence/absence per config entry, fallback behavior for unknown/undefined statuses (with and without explicit fallback), label prop precedence, and case-sensitive status key matching.
IntakeTelemetryStatusBadge refactor
web/packages/studio/src/components/IntakeTelemetryStatusBadge/index.tsx
Component simplified to render shared StatusBadge with STATUS_CONFIG and fallback, removing custom Badge + icon/label selection logic.
CustomizationStatusBadge refactor
web/packages/studio/src/components/dataViews/CustomModelsDataView/CustomizationStatusBadge/index.tsx
Component refactored to use shared StatusBadge with STATUS_CONFIG mapping, replacing switch-based color resolver while preserving computed label from getFormattedCustomizationStatus.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(studio): Consolidate StatusBadge logic' accurately describes the main change: refactoring scattered StatusBadge implementations across the codebase into a unified, configurable component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch steramae/astd-233-unify-the-statusbadge-components

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/packages/common/src/components/StatusBadge/index.tsx (1)

36-48: 📐 Maintainability & Code Quality

Document statusConfig key case-sensitivity
statusConfig is intentionally case-sensitive (statusConfig[status]), while the legacy badgeStatus path lowercases (String(status).toLowerCase()); StatusBadge.test.tsx asserts "SUCCESS" doesn’t match STATUS_CONFIG (case-sensitive), whereas uppercase statuses normalize only on the badgeStatus path. Consider calling out this contract for consumers to prevent surprises.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/common/src/components/StatusBadge/index.tsx` around lines 36 -
48, The conditional treats statusConfig as case-sensitive (accessed with
statusConfig[status]) while the legacy badgeStatus path lowercases the input via
statusKey = String(status).toLowerCase(), causing tests like
StatusBadge.test.tsx to expect "SUCCESS" not to match STATUS_CONFIG; update the
StatusBadge component's public documentation (docblock above the StatusBadge
component and/or component props docs) to explicitly state this contract:
statusConfig keys are case-sensitive and must match the exact status string,
whereas badgeStatus is matched case-insensitively via lowercasing, or
alternatively normalize the incoming status before checking statusConfig if you
prefer case-insensitive matching; reference statusConfig, badgeStatus,
statusKey, and CONFIG_DEFAULT in the doc so consumers know which behavior
applies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/packages/common/src/components/StatusBadge/StatusBadge.test.tsx`:
- Around line 159-163: The test in StatusBadge.test.tsx leaves a TODO for
verifying icon rendering; update the it('renders icon when config entry has
one') test to import CircleCheck from lucide-react, create a statusConfig entry
that includes { icon: CircleCheck } (or an icon-bearing config constant), render
<StatusBadge status="error" statusConfig={...} />, and assert the icon is
present (e.g., query for role="img" or the SVG by test id/alt/title depending on
implementation) while keeping the original assertion that the non-icon config
renders no image; reference the StatusBadge component and the test name to
locate where to add the import, config, render call, and assertions.

---

Nitpick comments:
In `@web/packages/common/src/components/StatusBadge/index.tsx`:
- Around line 36-48: The conditional treats statusConfig as case-sensitive
(accessed with statusConfig[status]) while the legacy badgeStatus path
lowercases the input via statusKey = String(status).toLowerCase(), causing tests
like StatusBadge.test.tsx to expect "SUCCESS" not to match STATUS_CONFIG; update
the StatusBadge component's public documentation (docblock above the StatusBadge
component and/or component props docs) to explicitly state this contract:
statusConfig keys are case-sensitive and must match the exact status string,
whereas badgeStatus is matched case-insensitively via lowercasing, or
alternatively normalize the incoming status before checking statusConfig if you
prefer case-insensitive matching; reference statusConfig, badgeStatus,
statusKey, and CONFIG_DEFAULT in the doc so consumers know which behavior
applies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d2c185cd-391f-43b8-84fa-de492bc16ea5

📥 Commits

Reviewing files that changed from the base of the PR and between a8a0283 and 2e697be.

📒 Files selected for processing (5)
  • web/packages/common/src/components/StatusBadge/StatusBadge.test.tsx
  • web/packages/common/src/components/StatusBadge/badgeStatus.tsx
  • web/packages/common/src/components/StatusBadge/index.tsx
  • web/packages/studio/src/components/IntakeTelemetryStatusBadge/index.tsx
  • web/packages/studio/src/components/dataViews/CustomModelsDataView/CustomizationStatusBadge/index.tsx

Comment thread web/packages/common/src/components/StatusBadge/StatusBadge.test.tsx
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 19457/25820 75.4% 60.9%
Integration Tests 11362/24592 46.2% 20.2%

Signed-off-by: Sean Teramae <steramae@nvidia.com>
@steramae-nvidia steramae-nvidia added this pull request to the merge queue Jun 13, 2026
Merged via the queue into main with commit 8113b1d Jun 13, 2026
49 checks passed
@steramae-nvidia steramae-nvidia deleted the steramae/astd-233-unify-the-statusbadge-components branch June 13, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants