Skip to content

fix: update performance tests counter to use camelCase API Key#7870

Open
Sumedh-6504 wants to merge 5 commits into
layer5io:masterfrom
Sumedh-6504:fix/performance-runs-counter
Open

fix: update performance tests counter to use camelCase API Key#7870
Sumedh-6504 wants to merge 5 commits into
layer5io:masterfrom
Sumedh-6504:fix/performance-runs-counter

Conversation

@Sumedh-6504

@Sumedh-6504 Sumedh-6504 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes #7860

Notes for Reviewers

Description

Fixes the performance test run counters displaying as 0 across several pages (Meshery page, Nighthawk page, etc.) due to an API response key mismatch. Additionally resolves an ESLint warning in sistent-component.js that was blocking the pre-commit checks.

Root Cause

  1. API Key Mismatch: The API endpoint at https://cloud.layer5.io/api/performance/results/total returns {"totalRuns": 160375}. However, the components were expecting result.total_runs (snake_case) instead of result.totalRuns (camelCase). Since the snake_case key was undefined, the counter fell back to the initial state of 0.
  2. Husky Pre-commit Block: There was an unused variable warning (isDark declared but never used in sistent-component.js) which blocked the pre-commit hooks due to --max-warnings=0 constraints.

Changes Made

  • src/sections/Counters/index.js — Updated key parsing to support totalRuns || total_runs and added a .catch() block with error logging.
  • src/sections/Meshery/How-meshery-works/specs/data-card.js — Updated key parsing and added error handling (rendered on /cloud-native-management/meshery).
  • src/sections/Projects/Nighthawk/index.js — Updated key parsing and added error handling (rendered on /projects/nighthawk).
  • src/sections/Meshery/Features-Col/index.js — Updated key parsing and changed console.log to console.error in the catch block for consistency.
  • src/templates/sistent-component.js — Removed the unused isDark variable and its unused import to satisfy ESLint constraints and allow pre-commit hooks to pass successfully.

Local Testing & CORS Restriction

Important

The performance test run count will still show 0 (or log a CORS warning) on localhost:8000. The API endpoint restricts CORS requests to the production origin (layer5.io), meaning the browser blocks network requests originating from localhost. The fix is verified to match the production API payload structure and will render correctly once deployed to the production or preview environment.

Screenshots

Screenshot 2026-07-15 014909

Signed commits

  • Yes, I signed my commits.

Summary by CodeRabbit

  • New Features

    • Sistent component pages now display descriptions alongside page titles.
    • Guidance and code navigation tabs have clearer, consistent links.
  • Bug Fixes

    • Performance counters now recognize multiple response formats and handle unavailable data more reliably.
    • Fetch failures are handled gracefully without disrupting the page.
    • Integration totals now display a fallback value when no integrations are reported.

Signed-off-by: Sumedh-6504 <sumedhrmundewadi@gmail.com>
@Sumedh-6504

Sumedh-6504 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@rishiraj38 @KatalKavya96 The reason behind that I could not make a video is this, http://localhost:8000 is restricted from the CORS. So now you can actually review the code change.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Preview deployment: https://layer5.io/pr-preview/pr-7870/

Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment here

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes update performance-count fetching to support two response field names and log failures. They also add a zero-count fallback for integrations, adjust Sistent template structure, and reformat JSX, styling, theme logic, and render hooks without changing most existing behavior.

Changes

Site updates

Layer / File(s) Summary
Performance count retrieval and fallback handling
src/sections/Counters/index.js, src/sections/Meshery/Features-Col/..., src/sections/Meshery/How-meshery-works/..., src/sections/Projects/Nighthawk/index.js
Performance responses support totalRuns and total_runs, fetch failures are logged, numeric validation is added in Features-Col, and zero integrations fall back to the lifecycle count.
Feature data and counter rendering
src/sections/Meshery/Features-Col/..., src/sections/Meshery/How-meshery-works/...
Feature data, counters, SVG markup, and styled-component CSS are reformatted while retaining the described values and styles.
Sistent template structure and navigation
src/templates/sistent-component.js
Header descriptions, MDX shortcodes, tab paths, tab classes, and main content structure are updated.
Page, theme, and hook formatting
onRenderBody.js, src/components/MeetInfo-Table/index.js, src/sections/Projects/Nighthawk/index.js, src/theme/app/ThemeManager.js
Render hooks, table markup, Nighthawk JSX, and theme manager expressions are reformatted without described runtime changes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes unrelated formatting-only edits in files like onRenderBody.js, MeetInfo-Table, and ThemeManager.js beyond the performance counter fix. Split unrelated formatting and refactor changes into a separate PR and keep this one focused on performance counter updates.
✅ 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 reflects the main change: fixing the performance counter to read the API's camelCase key.
Linked Issues check ✅ Passed The counter logic now reads totalRuns with a fallback to total_runs, so the performance count should display correctly again.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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

@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: 2

🤖 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 `@src/sections/Counters/index.js`:
- Around line 15-21: Standardize performance-count parsing by introducing one
shared helper that prefers totalRuns, falls back to total_runs with nullish
coalescing, and preserves valid zero values. Update the fetch consumers in
src/sections/Counters/index.js, src/sections/Meshery/Features-Col/index.js,
src/sections/Meshery/How-meshery-works/specs/data-card.js, and
src/sections/Projects/Nighthawk/index.js to use that helper, including replacing
Features-Col’s 250000 non-OK fallback so all sections share the same contract.

In `@src/templates/sistent-component.js`:
- Around line 41-43: Remove the inner h1 rendered by the component around
displayName in the template, since SistentLayout already provides the page-level
heading. Preserve the description paragraph and ensure the rendered page retains
exactly one semantic h1.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cb21e8ca-6b18-4486-9c19-98be76af5679

📥 Commits

Reviewing files that changed from the base of the PR and between f330ab8 and cee5934.

📒 Files selected for processing (9)
  • onRenderBody.js
  • src/components/MeetInfo-Table/index.js
  • src/sections/Counters/index.js
  • src/sections/Meshery/Features-Col/data/index.js
  • src/sections/Meshery/Features-Col/index.js
  • src/sections/Meshery/How-meshery-works/specs/data-card.js
  • src/sections/Projects/Nighthawk/index.js
  • src/templates/sistent-component.js
  • src/theme/app/ThemeManager.js

Comment on lines +15 to +21
.then((response) => response.json())
.then((result) =>
setPerformanceCount(result.totalRuns || result.total_runs),
)
.catch((error) => {
console.error("Failed to fetch performance count:", error.message);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== File list ==\n'
git ls-files 'src/sections/Counters/index.js' \
  'src/sections/Meshery/Features-Col/index.js' \
  'src/sections/Meshery/How-meshery-works/specs/data-card.js' \
  'src/sections/Projects/Nighthawk/index.js'

printf '\n== Relevant excerpts ==\n'
for f in \
  src/sections/Counters/index.js \
  src/sections/Meshery/Features-Col/index.js \
  src/sections/Meshery/How-meshery-works/specs/data-card.js \
  src/sections/Projects/Nighthawk/index.js
do
  echo "--- $f"
  nl -ba "$f" | sed -n '1,220p'
done

Repository: layer5io/layer5

Length of output: 444


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

files = [
    Path("src/sections/Counters/index.js"),
    Path("src/sections/Meshery/Features-Col/index.js"),
    Path("src/sections/Meshery/How-meshery-works/specs/data-card.js"),
    Path("src/sections/Projects/Nighthawk/index.js"),
]
for path in files:
    text = path.read_text()
    print(f"\n== {path} ==")
    for needle in ["fetch(", "response.ok", "totalRuns", "total_runs", "setPerformanceCount", "250000", "0 if fetch fails"]:
        if needle in text:
            print(f"contains: {needle}")
PY

Repository: layer5io/layer5

Length of output: 772


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,220p' src/sections/Counters/index.js
printf '\n----\n'
sed -n '1,220p' src/sections/Meshery/Features-Col/index.js
printf '\n----\n'
sed -n '1,220p' src/sections/Meshery/How-meshery-works/specs/data-card.js
printf '\n----\n'
sed -n '1,220p' src/sections/Projects/Nighthawk/index.js

Repository: layer5io/layer5

Length of output: 17078


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
files = [
    "src/sections/Counters/index.js",
    "src/sections/Meshery/Features-Col/index.js",
    "src/sections/Meshery/How-meshery-works/specs/data-card.js",
    "src/sections/Projects/Nighthawk/index.js",
]
for f in files:
    text = Path(f).read_text().splitlines()
    print(f"\n== {f} ==")
    for i, line in enumerate(text, 1):
        if any(key in line for key in ["performanceCount", "250000", "totalRuns", "total_runs", "fetch(", "response.ok"]):
            start = max(1, i-2)
            end = min(len(text), i+2)
            print(f"-- lines {start}-{end}")
            for j in range(start, end+1):
                print(f"{j:4d}: {text[j-1]}")
PY

Repository: layer5io/layer5

Length of output: 4551


Standardize the performance-count fallback across these callers.

  • src/sections/Counters/index.js, src/sections/Meshery/How-meshery-works/specs/data-card.js, and src/sections/Projects/Nighthawk/index.js use result.totalRuns || result.total_runs, which drops a valid 0 and can set performanceCount to undefined.
  • src/sections/Meshery/Features-Col/index.js uses a different non-OK fallback (250000), so the same metric renders inconsistently in this section.

Use ?? and one shared parser/helper so every consumer follows the same contract.

📍 Affects 4 files
  • src/sections/Counters/index.js#L15-L21 (this comment)
  • src/sections/Meshery/Features-Col/index.js#L96-L105
  • src/sections/Meshery/How-meshery-works/specs/data-card.js#L50-L57
  • src/sections/Projects/Nighthawk/index.js#L27-L34
🤖 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 `@src/sections/Counters/index.js` around lines 15 - 21, Standardize
performance-count parsing by introducing one shared helper that prefers
totalRuns, falls back to total_runs with nullish coalescing, and preserves valid
zero values. Update the fetch consumers in src/sections/Counters/index.js,
src/sections/Meshery/Features-Col/index.js,
src/sections/Meshery/How-meshery-works/specs/data-card.js, and
src/sections/Projects/Nighthawk/index.js to use that helper, including replacing
Features-Col’s 250000 non-OK fallback so all sections share the same contract.

Comment on lines +41 to 43
<h1>{displayName}</h1>
{frontmatter.description && <p>{frontmatter.description}</p>}
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Avoid adding a second page-level heading.

SistentLayout already renders an <h1> at Line 8-23, so this new heading creates duplicate page titles for users and assistive technologies. Remove the inner <h1> or move the description into SistentLayout while retaining a single page heading.

As per coding guidelines, rendered JSX must meet WCAG 2.1 Level AA accessibility requirements and use semantic HTML.

🤖 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 `@src/templates/sistent-component.js` around lines 41 - 43, Remove the inner h1
rendered by the component around displayName in the template, since
SistentLayout already provides the page-level heading. Preserve the description
paragraph and ensure the rendered page retains exactly one semantic h1.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inaccurate: "0" performance tests results being reported

1 participant