Skip to content

fix(studio): refactor GuardrailsTable to DataView - #1043

Merged
nakolean merged 2 commits into
mainfrom
nkolean/guardrails-test-details
Aug 3, 2026
Merged

fix(studio): refactor GuardrailsTable to DataView#1043
nakolean merged 2 commits into
mainfrom
nkolean/guardrails-test-details

Conversation

@nakolean

@nakolean nakolean commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-08-03 at 11 34 09 AM

Summary by CodeRabbit

  • New Features

    • Added a searchable, filterable, sortable, and paginated guardrail test-results view.
    • Added clear status indicators for Guarded, Allowed, and Not run results.
    • Added a summary bar with result counts and proportional status segments.
    • Added distinct empty states for no tests and no matching search or filter results.
  • Tests

    • Added coverage for rendering, searching, filtering, sorting, pagination, verdicts, and empty states.

Signed-off-by: Nicholas Kolean <nakolean@gmail.com>
@nakolean
nakolean requested review from a team as code owners August 3, 2026 17:34
@github-actions github-actions Bot added the fix label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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: 518a9f01-911f-4b26-bc5c-61ed914fec21

📥 Commits

Reviewing files that changed from the base of the PR and between 2477884 and 89075c0.

📒 Files selected for processing (3)
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultSummary.tsx
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.tsx
  • web/packages/studio/src/routes/guardrails/GuardrailChecksTab/index.test.tsx
💤 Files with no reviewable changes (1)
  • web/packages/studio/src/routes/guardrails/GuardrailChecksTab/index.test.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultSummary.tsx
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.tsx

📝 Walkthrough

Walkthrough

Changes

Guardrail results experience

Layer / File(s) Summary
Result status contracts and presentation
web/packages/studio/src/components/dataViews/GuardrailChecksDataView/checkStatus.ts, web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultIndicator.tsx, web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultSummary.tsx
Adds verdict buckets, sorting ranks, status badges, and proportional result summaries.
Searchable checks data view
web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.tsx, web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.test.tsx
Adds searchable, filterable, sortable, paginated check rows with empty states and behavioral tests.
Test results tab integration
web/packages/studio/src/routes/guardrails/GuardrailChecksTab/GuardrailTestCasesEditor.tsx, web/packages/studio/src/routes/guardrails/GuardrailChecksTab/index.test.tsx
Replaces GuardrailResultsTable with the summary and data view, with tab-level coverage.

Sequence Diagram(s)

sequenceDiagram
  participant GuardrailTestCasesEditor
  participant ResultSummary
  participant GuardrailChecksDataView
  participant checkStatus
  GuardrailTestCasesEditor->>ResultSummary: Render check status summary
  GuardrailTestCasesEditor->>GuardrailChecksDataView: Pass guardrail checks
  GuardrailChecksDataView->>checkStatus: Filter and rank verdicts
  checkStatus-->>GuardrailChecksDataView: Return result buckets and sort order
Loading

Possibly related PRs

Suggested reviewers: aray12, htolentino-nvidia

🚥 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 clearly describes the main change: refactoring the guardrail results table to use a DataView.
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.
✨ 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 nkolean/guardrails-test-details

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultSummary.tsx (1)

19-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse getResultFilterValue for the counts.

This duplicates the verdict bucketing in checkStatus.ts. If the mapping changes there, the summary and the table will disagree.

♻️ Proposed fix
-import { getLatestRunStatus } from '`@studio/components/dataViews/GuardrailChecksDataView/checkStatus`';
+import {
+  getLatestRunStatus,
+  getResultFilterValue,
+} from '`@studio/components/dataViews/GuardrailChecksDataView/checkStatus`';
@@
   for (const check of checks) {
-    const status = getLatestRunStatus(check);
-    if (status === 'success') {
+    const bucket = getResultFilterValue(getLatestRunStatus(check));
+    if (bucket === 'success') {
       allowed += 1;
-    } else if (status === 'blocked') {
+    } else if (bucket === 'blocked') {
       guarded += 1;
     } else {
       notRun += 1;
     }
   }
🤖 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/studio/src/components/dataViews/GuardrailChecksDataView/ResultSummary.tsx`
around lines 19 - 36, Update summarizeResults to classify each check using
getResultFilterValue from checkStatus.ts instead of comparing getLatestRunStatus
results directly. Increment allowed, guarded, or notRun according to the shared
filter-value mapping, preserving the existing returned count shape.
web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.test.tsx (1)

146-167: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a test for Result column sorting.

getResultSortRank and the sort branch in index.tsx (Lines 77-85) have no coverage. Click the Result column header and assert the row order for ascending and descending.

🤖 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/studio/src/components/dataViews/GuardrailChecksDataView/index.test.tsx`
around lines 146 - 167, Add a test near the existing filtering test that clicks
the Result column header and verifies rows are ordered correctly in both
ascending and descending directions. Exercise the getResultSortRank behavior and
the sorting branch in the GuardrailChecksDataView component, using the existing
rendered row text and established test utilities.
web/packages/studio/src/components/dataViews/GuardrailChecksDataView/checkStatus.ts (1)

17-53: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Type the bucket values instead of string.

getResultFilterValue returns string, so consumers must cast (see index.tsx Line 63). A union type keeps the buckets checked at compile time and makes RESULT_SORT_RANK exhaustive.

♻️ Proposed typing
+type ResultFilterValue = (typeof RESULT_FILTER_VALUES)[keyof typeof RESULT_FILTER_VALUES];
+
 /** Options for the "Result" single-select column filter. */
 export const RESULT_FILTER_OPTIONS: FilterItem[] = [
@@
-export const getResultFilterValue = (status: Verdict | undefined): string => {
+export const getResultFilterValue = (status: Verdict | undefined): ResultFilterValue => {
@@
-const RESULT_SORT_RANK: Record<string, number> = {
+const RESULT_SORT_RANK: Record<ResultFilterValue, number> = {

As per coding guidelines: "Use type for unions, intersections, and computed types in TypeScript".

🤖 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/studio/src/components/dataViews/GuardrailChecksDataView/checkStatus.ts`
around lines 17 - 53, Define a type alias for the three result bucket values
represented by RESULT_FILTER_VALUES, and update getResultFilterValue to return
that union instead of string. Type RESULT_SORT_RANK with the same bucket union
(using an appropriate mapped or record type) so all buckets are compile-time
checked and consumers no longer need casts.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In
`@web/packages/studio/src/components/dataViews/GuardrailChecksDataView/checkStatus.ts`:
- Around line 17-53: Define a type alias for the three result bucket values
represented by RESULT_FILTER_VALUES, and update getResultFilterValue to return
that union instead of string. Type RESULT_SORT_RANK with the same bucket union
(using an appropriate mapped or record type) so all buckets are compile-time
checked and consumers no longer need casts.

In
`@web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.test.tsx`:
- Around line 146-167: Add a test near the existing filtering test that clicks
the Result column header and verifies rows are ordered correctly in both
ascending and descending directions. Exercise the getResultSortRank behavior and
the sorting branch in the GuardrailChecksDataView component, using the existing
rendered row text and established test utilities.

In
`@web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultSummary.tsx`:
- Around line 19-36: Update summarizeResults to classify each check using
getResultFilterValue from checkStatus.ts instead of comparing getLatestRunStatus
results directly. Increment allowed, guarded, or notRun according to the shared
filter-value mapping, preserving the existing returned count shape.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3779c4fc-0fd1-47a3-9ce1-db6867babd76

📥 Commits

Reviewing files that changed from the base of the PR and between 2cb9a08 and 2477884.

📒 Files selected for processing (8)
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultIndicator.tsx
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/ResultSummary.tsx
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/checkStatus.ts
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.test.tsx
  • web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.tsx
  • web/packages/studio/src/routes/guardrails/GuardrailChecksTab/GuardrailResultsTable.tsx
  • web/packages/studio/src/routes/guardrails/GuardrailChecksTab/GuardrailTestCasesEditor.tsx
  • web/packages/studio/src/routes/guardrails/GuardrailChecksTab/index.test.tsx
💤 Files with no reviewable changes (1)
  • web/packages/studio/src/routes/guardrails/GuardrailChecksTab/GuardrailResultsTable.tsx

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 30234/38242 79.1% 63.7%
Integration Tests 17879/36911 48.4% 20.9%

Comment thread web/packages/studio/src/routes/guardrails/GuardrailChecksTab/index.test.tsx Outdated
Comment thread web/packages/studio/src/components/dataViews/GuardrailChecksDataView/index.tsx Outdated
Signed-off-by: Nicholas Kolean <nakolean@gmail.com>
@nakolean
nakolean enabled auto-merge August 3, 2026 19:57
@nakolean
nakolean added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit e31dedd Aug 3, 2026
54 checks passed
@nakolean
nakolean deleted the nkolean/guardrails-test-details branch August 3, 2026 20:21
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