Skip to content

fix(audit): color workflow response node by status code#252

Merged
SantiagoDePolonia merged 1 commit intomainfrom
fix/audit-response-status-color
Apr 21, 2026
Merged

fix(audit): color workflow response node by status code#252
SantiagoDePolonia merged 1 commit intomainfrom
fix/audit-response-status-color

Conversation

@SantiagoDePolonia
Copy link
Copy Markdown
Contributor

@SantiagoDePolonia SantiagoDePolonia commented Apr 21, 2026

Summary

  • color the Audit Logs workflow chart Response node using the same status buckets as audit log entry badges
  • show the response status code on the Response node in the workflow chart
  • add dashboard workflow tests covering success, neutral, warning, and error response states

Testing

  • make test-dashboard

Summary by CodeRabbit

  • New Features

    • Response nodes in workflow charts now display HTTP status codes with dynamic color-coded indicators based on status ranges (2xx success, 3xx neutral, 4xx warnings, 5xx errors).
  • Style

    • Added new visual styling variants for workflow node states.
  • Tests

    • Expanded test coverage for HTTP status code mapping and response node classification.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

The PR adds HTTP status code visualization to workflow response nodes. It includes new CSS styling classes for warning and neutral states, updates the response node class computation logic to distinguish HTTP status families (3xx, 4xx, 5xx), and adds a sublabel element to display the exact status code.

Changes

Cohort / File(s) Summary
CSS Styling
internal/admin/dashboard/static/css/dashboard.css
Added new .workflow-node-warning and .workflow-node-neutral CSS class blocks with themed styling for node containers, icons, labels, and badges using color-mix() with --warning and --text-muted variables.
Response Node Logic
internal/admin/dashboard/static/js/modules/workflows.js, internal/admin/dashboard/static/js/modules/workflows.test.js
Updated response node classification to extract HTTP statusCode and compute CSS class from status code ranges (5xx→error, 4xx→warning, 3xx→neutral, 2xx→success) instead of boolean responseSuccess. Added responseNodeSublabel field to expose status code as a string. Extended test coverage to verify status-to-class mappings and sublabel generation.
Template Markup
internal/admin/dashboard/templates/workflow-chart.html
Added optional <span class="workflow-node-sub"> element in the Response node, conditionally displayed via x-show="workflow.responseNodeSublabel" and populated with the status code string.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 With whiskers twitching and nose in the air,
I've colored the workflow nodes with such care,
Warnings in amber, neutral in gray,
Status codes dancing in their display,
Five-zero-zero errors shine bold and bright—
Dashboards are beautiful under my sight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding color styling to the workflow response node based on HTTP status codes, which is confirmed by all modified files (CSS variants, status code mapping logic, tests, and template updates).
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 fix/audit-response-status-color

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR enhances the Audit Logs workflow chart by coloring the Response node according to the same HTTP status buckets used by audit log entry badges, and by displaying the raw status code as a sublabel on the node. It adds two new helper methods (workflowResponseNodeClass, workflowResponseNodeSublabel), the corresponding CSS rules for workflow-node-warning and workflow-node-neutral, a template update to render the sublabel, and four new tests covering the full range of status-code outcomes.

Key changes:

  • workflowResponseNodeClass maps status codes to node colors: 2xx → workflow-node-success, 3xx → workflow-node-neutral, 4xx → workflow-node-warning, 5xx → workflow-node-error; absent or invalid status codes produce no class
  • workflowResponseNodeSublabel returns the raw status code string (or null) so the template can render it inside the node
  • Both values are wired into workflowChartModel and the chart contract snapshots are updated across all existing tests
  • CSS adds fully-specified workflow-node-warning and workflow-node-neutral rule sets (icon, label, sub, badge sub-selectors), consistent with the existing success/error patterns
  • Template change follows the same x-show / x-text pattern used by Auth, Guardrails, Cache, and Failover nodes
  • New tests cover: uncached 200 success, cache-hit 200 success, 304 redirect (neutral), 429 client error (warning), 503 server error (error)

Confidence Score: 5/5

Safe to merge — purely additive UI enhancement with no changes to data flow, API contracts, or backend logic.

The feature is self-contained: two new pure functions, one CSS block, and one template line. The logic is simple and mirrors the existing audit-badge convention. Four new tests explicitly validate all status-code buckets, and all pre-existing chart contract snapshot tests are updated consistently. No regressions in scope.

No files require special attention.

Important Files Changed

Filename Overview
internal/admin/dashboard/static/js/modules/workflows.js Added workflowResponseNodeClass and workflowResponseNodeSublabel helpers; wired both into workflowChartModel. Status-bucket logic (2xx→success, 3xx→neutral, 4xx→warning, 5xx→error) mirrors the audit log badge convention correctly.
internal/admin/dashboard/static/js/modules/workflows.test.js Four new tests cover success (200 cached + uncached), neutral (3xx), warning (4xx), and error (5xx) response states. Existing chart-contract snapshots updated to include responseNodeClass/responseNodeSublabel fields.
internal/admin/dashboard/templates/workflow-chart.html Response node now binds :class to responseNodeClass and shows a workflow-node-sub span for the status code sublabel, consistent with how Auth/Guardrails/Failover nodes expose their sublabels.
internal/admin/dashboard/static/css/dashboard.css Adds workflow-node-warning and workflow-node-neutral CSS rules (with icon, icon-endpoint, label, sub, and badge sub-selectors) alongside the existing success/error/skipped classes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[workflowResponseNodeClass\nruntime] --> B{runtime exists?}
    B -- No --> Z[return empty string]
    B -- Yes --> C{statusCode is\nfinite number?}
    C -- No --> Z
    C -- Yes --> D{statusCode >= 500?}
    D -- Yes --> E[workflow-node-error\n5xx Server Error]
    D -- No --> F{statusCode >= 400?}
    F -- Yes --> G[workflow-node-warning\n4xx Client Error]
    F -- No --> H{statusCode >= 300?}
    H -- Yes --> I[workflow-node-neutral\n3xx Redirect]
    H -- No --> J{statusCode >= 200?}
    J -- Yes --> K[workflow-node-success\n2xx Success]
    J -- No --> Z
Loading

Comments Outside Diff (1)

  1. internal/admin/dashboard/static/js/modules/workflows.js, line 1341-1345 (link)

    P2 Cache-hit response connector dimmed but node fully colored

    workflowResponseConnClass returns workflow-conn-dim on cache hits (consistent with how the AI and Failover connectors are dimmed), but workflowResponseNodeClass ignores cacheHit and applies the full status-color class. Every other node that is "bypassed" by the cache path (AI, Failover) uses workflow-node-skipped. The Response node behaves differently — it shows the live status color even when the preceding connection is dimmed.

    This is a minor visual inconsistency, not a bug: the final response to the client is a true success regardless of whether it came from cache, so a green Response node while everything upstream is dimmed/skipped is arguably the correct design. However, if the intent is to visually communicate "this response came from cache", using a different class (e.g. workflow-node-skipped) or no class on the Response node for cache hits would be more internally consistent.

    No code change is strictly required — confirming this is the intended behavior is sufficient.

Reviews (1): Last reviewed commit: "fix(audit): color workflow response node..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/admin/dashboard/static/js/modules/workflows.test.js (1)

1908-1923: ⚠️ Potential issue | 🟡 Minor

Add test cases for invalid status codes in response helper tests.

The helpers workflowResponseNodeClass and workflowResponseNodeSublabel already validate against non-finite status codes using Number.isFinite(), but test coverage is missing for these edge cases. Add tests confirming that values like 99, 200.5, and 600 return empty string ('') and null respectively, alongside the existing coverage for valid 2xx, 3xx, 4xx, and 5xx codes.

Also applies to: 1926-1955

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/admin/dashboard/static/js/modules/workflows.test.js` around lines
1908 - 1923, Add tests that exercise invalid/non-finite status codes for the
response helpers: create runtime entries with status_code values 99, 200.5, and
600 and assert that module.workflowResponseNodeClass(...) returns '' and
module.workflowResponseNodeSublabel(...) returns null for each; place these
assertions alongside the existing valid-status assertions near the current
workflowResponseNodeClass/workflowResponseNodeSublabel tests (the
uncachedSuccess block) and repeat similarly where other response-helper tests
exist (the following block referenced in the comment).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/admin/dashboard/static/js/modules/workflows.js`:
- Around line 1347-1360: The code accepts non-integer or out-of-range status
codes; update workflowResponseNodeClass and workflowResponseNodeSublabel to
first coerce/validate an integer HTTP status (e.g., use Math.floor or parseInt
then Number.isInteger) and only proceed if the integer is within the 100–599
range; otherwise return '' for class and null for sublabel. Ensure you reference
runtime.statusCode when validating so both methods reject values like 99, 200.5,
or 600 before computing classes or labels.

---

Outside diff comments:
In `@internal/admin/dashboard/static/js/modules/workflows.test.js`:
- Around line 1908-1923: Add tests that exercise invalid/non-finite status codes
for the response helpers: create runtime entries with status_code values 99,
200.5, and 600 and assert that module.workflowResponseNodeClass(...) returns ''
and module.workflowResponseNodeSublabel(...) returns null for each; place these
assertions alongside the existing valid-status assertions near the current
workflowResponseNodeClass/workflowResponseNodeSublabel tests (the
uncachedSuccess block) and repeat similarly where other response-helper tests
exist (the following block referenced in the comment).
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 830f612e-a466-4be9-accf-3fc26d42dfad

📥 Commits

Reviewing files that changed from the base of the PR and between 0553801 and 1eb30de.

📒 Files selected for processing (4)
  • internal/admin/dashboard/static/css/dashboard.css
  • internal/admin/dashboard/static/js/modules/workflows.js
  • internal/admin/dashboard/static/js/modules/workflows.test.js
  • internal/admin/dashboard/templates/workflow-chart.html

Comment on lines 1347 to +1360
workflowResponseNodeClass(runtime) {
if (!runtime) return '';
return runtime.responseSuccess ? 'workflow-node-success' : '';
const statusCode = runtime.statusCode;
if (!Number.isFinite(statusCode)) return '';
if (statusCode >= 500) return 'workflow-node-error';
if (statusCode >= 400) return 'workflow-node-warning';
if (statusCode >= 300) return 'workflow-node-neutral';
if (statusCode >= 200) return 'workflow-node-success';
return '';
},

workflowResponseNodeSublabel(runtime) {
if (!runtime || !Number.isFinite(runtime.statusCode)) return null;
return String(runtime.statusCode);
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.

⚠️ Potential issue | 🟡 Minor

Reject malformed finite status codes before coloring or displaying them.

Number.isFinite still accepts non-HTTP values like 99, 200.5, or 600; these can be rendered as real response statuses, and 600 would be colored as an error. Normalize to integer HTTP status codes before both class and sublabel computation.

Proposed fix
+            workflowResponseStatusCode(runtime) {
+                if (!runtime) return null;
+                const statusCode = Number(runtime.statusCode);
+                if (!Number.isInteger(statusCode) || statusCode < 100 || statusCode > 599) return null;
+                return statusCode;
+            },
+
             workflowResponseNodeClass(runtime) {
-                if (!runtime) return '';
-                const statusCode = runtime.statusCode;
-                if (!Number.isFinite(statusCode)) return '';
+                const statusCode = this.workflowResponseStatusCode(runtime);
+                if (statusCode === null) return '';
                 if (statusCode >= 500) return 'workflow-node-error';
                 if (statusCode >= 400) return 'workflow-node-warning';
                 if (statusCode >= 300) return 'workflow-node-neutral';
                 if (statusCode >= 200) return 'workflow-node-success';
                 return '';
             },
 
             workflowResponseNodeSublabel(runtime) {
-                if (!runtime || !Number.isFinite(runtime.statusCode)) return null;
-                return String(runtime.statusCode);
+                const statusCode = this.workflowResponseStatusCode(runtime);
+                return statusCode === null ? null : String(statusCode);
             },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/admin/dashboard/static/js/modules/workflows.js` around lines 1347 -
1360, The code accepts non-integer or out-of-range status codes; update
workflowResponseNodeClass and workflowResponseNodeSublabel to first
coerce/validate an integer HTTP status (e.g., use Math.floor or parseInt then
Number.isInteger) and only proceed if the integer is within the 100–599 range;
otherwise return '' for class and null for sublabel. Ensure you reference
runtime.statusCode when validating so both methods reject values like 99, 200.5,
or 600 before computing classes or labels.

@SantiagoDePolonia SantiagoDePolonia merged commit 5af6f27 into main Apr 21, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant