Skip to content

[codex] Test stats health action filters#2096

Merged
riderx merged 3 commits into
mainfrom
codex/test-stats-health-events
May 10, 2026
Merged

[codex] Test stats health action filters#2096
riderx merged 3 commits into
mainfrom
codex/test-stats-health-events

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented May 10, 2026

What

  • Add a shared stats action filter catalog for the logs UI.
  • Add unit coverage that compares frontend filters with backend allowed stats actions.
  • Cover the app/WebView health action set explicitly.
  • Remove an unused Credits.vue local variable that currently breaks full lint.

Why

  • The health stats events need a guard so future backend/frontend changes do not silently drop filter support.

How

  • Extracted LogTable action filter data into src/services/statsActions.ts.
  • Added a Vitest unit test for backend enum and frontend filter parity.

Testing

  • bunx vitest run tests/stats-actions.unit.test.ts
  • bun run lint
  • bun run test:plugin
  • bun run build

Not Tested

  • Full backend test suite beyond the plugin/stats slice.

Summary by CodeRabbit

  • Refactor

    • Optimized log table component to use shared action filter helpers, reducing code duplication.
  • Chores

    • Removed unused code in organization credits component.
  • Tests

    • Added unit tests to ensure stats action filter mappings stay synchronized between frontend and backend.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@riderx has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 20 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 20809b7d-7213-4803-baf8-6a28ed19adfb

📥 Commits

Reviewing files that changed from the base of the PR and between 6d09728 and c494e85.

📒 Files selected for processing (1)
  • tests/stats-actions.unit.test.ts
📝 Walkthrough

Walkthrough

This PR extracts hardcoded action filter configuration from LogTable.vue into a new shared statsActions.ts module, reducing duplication and centralizing the source of truth for action-to-filter mappings across the frontend.

Changes

Stats Action Filter Centralization

Layer / File(s) Summary
Shared Stats Actions Mapping
src/services/statsActions.ts
Defines statsActionFilters as a readonly tuple array mapping filter keys to action identifiers (e.g., ['ping', 'action-ping']).
Filter Lookup Utilities
src/services/statsActions.ts
Exports filterToAction and actionToFilter lookup tables derived from the mapping, plus createActionFilterState() to initialize per-filter boolean state.
LogTable Component Integration
src/components/tables/LogTable.vue
Imports shared helpers; replaces 92 lines of local hardcoded filter config with createActionFilterState() call; removes duplicate statsActionFilters and mapping construction logic.
Tests & Cleanup
tests/stats-actions.unit.test.ts, src/pages/settings/organization/Credits.vue
Vitest suite validates bidirectional sync between frontend statsActionFilters and backend ALLOWED_STATS_ACTIONS; health action round-trip mapping verified. Minor cleanup: removes unused intermediate variable in formatMetricAmount.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Cap-go/capgo#2087: Directly related; both PRs modify the action-filter mapping and LogTable.vue filtering logic using shared statsActionFilters, filterToAction, and actionToFilter utilities.

Poem

🐰 Filters shared, no longer alone,
Actions mapped in a module of stone,
LogTable's burden now gone with the dawn,
Tests verify truth from dusk until morn.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive The pull request description includes What/Why/How sections and testing instructions, but is missing the standard template sections (Summary, Test plan, Screenshots, Checklist). Reformat the description to follow the repository template with standard sections: Summary, Test plan, Screenshots, and Checklist with verification items.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title '[codex] Test stats health action filters' clearly summarizes the main change: adding unit test coverage for stats health action filters.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/test-stats-health-events

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

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented May 10, 2026

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing codex/test-stats-health-events (c494e85) with main (0d6204c)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@riderx riderx marked this pull request as ready for review May 10, 2026 18:53
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@riderx
Copy link
Copy Markdown
Member Author

riderx commented May 10, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@riderx
Copy link
Copy Markdown
Member Author

riderx commented May 10, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (1)
tests/stats-actions.unit.test.ts (1)

24-27: ⚡ Quick win

Add a uniqueness check for filter keys as well.

Current assertions validate unique action values, but duplicate filter keys would still silently override entries in the generated lookup map.

Suggested change
   it('keeps the frontend action filters in sync with the backend action enum', () => {
+    const frontendFilterKeys = statsActionFilters.map(([filterKey]) => filterKey)
     const frontendActions = statsActionFilters.map(([, action]) => action)

+    expect(new Set(frontendFilterKeys).size).toBe(frontendFilterKeys.length)
     expect(new Set(frontendActions).size).toBe(frontendActions.length)
     expect([...frontendActions].sort()).toEqual([...ALLOWED_STATS_ACTIONS].sort())
   })
🤖 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 `@tests/stats-actions.unit.test.ts` around lines 24 - 27, The test currently
only checks uniqueness of action values from statsActionFilters; add a parallel
uniqueness assertion for the filter keys by extracting keys via
statsActionFilters.map(([key]) => key) (or similar), then assert new
Set(filterKeys).size === filterKeys.length to ensure no duplicate filter keys
override entries in the generated lookup map; place this alongside the existing
frontendActions checks in tests/stats-actions.unit.test.ts.
🤖 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 `@tests/stats-actions.unit.test.ts`:
- Line 2: Replace the relative import in tests/stats-actions.unit.test.ts with
the repo alias: change the import that currently references
'../src/services/statsActions.ts' to use the '~/services/statsActions' path so
the exported symbols actionToFilter, filterToAction, and statsActionFilters are
imported via the alias consistent with project conventions.

---

Nitpick comments:
In `@tests/stats-actions.unit.test.ts`:
- Around line 24-27: The test currently only checks uniqueness of action values
from statsActionFilters; add a parallel uniqueness assertion for the filter keys
by extracting keys via statsActionFilters.map(([key]) => key) (or similar), then
assert new Set(filterKeys).size === filterKeys.length to ensure no duplicate
filter keys override entries in the generated lookup map; place this alongside
the existing frontendActions checks in tests/stats-actions.unit.test.ts.
🪄 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

Run ID: a577abdd-cc5d-4a6a-8dbb-73d8a698fabf

📥 Commits

Reviewing files that changed from the base of the PR and between cb23097 and 6d09728.

📒 Files selected for processing (4)
  • src/components/tables/LogTable.vue
  • src/pages/settings/organization/Credits.vue
  • src/services/statsActions.ts
  • tests/stats-actions.unit.test.ts
💤 Files with no reviewable changes (1)
  • src/pages/settings/organization/Credits.vue

Comment thread tests/stats-actions.unit.test.ts Outdated
@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx merged commit ba43565 into main May 10, 2026
40 checks passed
@riderx riderx deleted the codex/test-stats-health-events branch May 10, 2026 19:59
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