Skip to content

feat(ui): reversal-rate + auto-action health card (#2193) - #4750

Merged
JSONbored merged 3 commits into
JSONbored:mainfrom
andriypolanski:feat/ui-reversal-health-card-2193
Jul 10, 2026
Merged

feat(ui): reversal-rate + auto-action health card (#2193)#4750
JSONbored merged 3 commits into
JSONbored:mainfrom
andriypolanski:feat/ui-reversal-health-card-2193

Conversation

@andriypolanski

@andriypolanski andriypolanski commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a read-only Reversal health card to /app/analytics showing reversal rate, reversal count, recent auto-actions, and manual rate from computeAgentHealth (AgentHealth in src/review/ops.ts). Lists reversed targets when present; EmptyState when none.

Closes #2193, Part of #1967.

Changes

Area Change
src/review/ops.ts Expose recentAutoActions on AgentHealth (7d reversal-rate denominator)
src/services/operator-dashboard.ts Surface agentHealth via computeAgentHealth
apps/gittensory-ui/src/components/site/app-panels/reversal-health-card-model.ts UI types + REVERSAL_ALERT_MIN threshold + status helpers
apps/gittensory-ui/src/components/site/app-panels/reversal-health-card.tsx Stats + reversed-target list / EmptyState
apps/gittensory-ui/src/routes/app.analytics.tsx Wire card after cycle time
Tests reversal-health-card.test.tsx, operator-dashboard.test.ts, ops.test.ts

UI Evidence

Required before opening the PR — upload screenshots via GitHub drag-and-drop (do not commit images):

Page / Feature Before After
/app/analytics image image

Test plan

  • ReversalHealthCard — zero reversals + EmptyState
  • ReversalHealthCard — above-threshold reversals + target list
  • ReversalHealthCard — empty-denominator (recentAutoActions === 0, reversalRate === 0)
  • reversalHealthStatus — ready / warn / info ternary arms
  • Operator dashboard payload includes empty agentHealth
  • npm run ui:testreversal-health-card.test.tsx (6/6)
  • npm run ui:typecheck
  • npm run test:unit -- test/unit/operator-dashboard.test.ts test/unit/ops.test.ts (41/41)
  • Manual: sign in as operator, open /app/analytics, confirm card renders
  • Before/after screenshots uploaded to PR (required — issue is visual)

Notes

  • Issue is labeled visual (owner-led). Confirm eligibility before opening a contributor PR.
  • StatusPill threshold: REVERSAL_ALERT_MIN = 1 — mirrors detectAnomalies (alerts.ts:204), which flags any human reversal of a bot auto-action.
  • Agent slug resolves from GITHUB_APP_SLUG (fallback gittensory) for single-tenant health reads.

@andriypolanski
andriypolanski marked this pull request as draft July 10, 2026 22:21
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 10, 2026
@loopover-orb

loopover-orb Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-10 23:37:15 UTC

8 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): src/services/operator-dashboard.ts (matched src/services/**).

Review summary
This PR exposes an already-computed `recentAutoActions` field from `computeAgentHealth` (src/review/ops.ts) and wires a new read-only Reversal-health card into the operator dashboard and analytics route. The change is small, additive, and doesn't touch the underlying computation logic — `recentAutoActions` was already being computed for `reversalRate`'s denominator, just not returned, so this is a low-risk plumbing change with no schema/migration impact. Test coverage for the model helpers is real but incomplete: several branches in `formatReversalEventType` and the `reversedTargets ?? []` fallback are untested, which lines up with the failed `codecov/patch` check (50% vs 99% target). The PR links issue #2193 as required.

Nits — 6 non-blocking
  • `formatReversalEventType` in reversal-health-card-model.ts:26-30 has three branches (`reversal_reverted`, `reversal_reopened`, default) but the test suite (reversal-health-card.test.tsx) only exercises `reversal_reopened` — add cases for `reversal_reverted` and an unrecognized eventType.
  • `reversedTargets ?? []` in reversal-health-card.tsx:14 is never tested with `reversedTargets` actually omitted — the test helper always supplies an explicit `[]` or populated array, so the `??` fallback arm is unverified.
  • The '7 days' window described in reversal-health-card.tsx:22 duplicates the `ANOMALY_WINDOW` constant in src/review/ops.ts as a hardcoded string — if the ops window ever changes, the UI copy silently drifts out of sync.
  • reversal-health-card.tsx:64 hardcodes `https:​//github.com/` for PR links; if gittensory ever supports GitHub Enterprise/self-host with a different host, this link breaks — worth a nit if that's in scope for Maintainer analytics dashboard (gate precision, calibration, acceptance rate) #1967.
  • `ReversalHealthCard`'s body is ~75 lines, above the repo's informal 60-line function-size flag — mostly JSX markup, not a real complexity concern, but consider extracting the reversed-target list item into a small subcomponent.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2193
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 139 registered-repo PR(s), 93 merged, 25 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 139 PR(s), 25 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: andriypolanski
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 139 PR(s), 25 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/app/analytics desktop before /app/analytics after /app/analytics
/app/analytics mobile before /app/analytics (mobile) after /app/analytics (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.22%. Comparing base (2d6377c) to head (f47c8fc).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4750   +/-   ##
=======================================
  Coverage   94.22%   94.22%           
=======================================
  Files         440      440           
  Lines       38715    38718    +3     
  Branches    14103    14104    +1     
=======================================
+ Hits        36479    36482    +3     
  Misses       1576     1576           
  Partials      660      660           
Files with missing lines Coverage Δ
src/review/ops.ts 99.13% <ø> (ø)
src/services/operator-dashboard.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 1aa2aa1 into JSONbored:main Jul 10, 2026
10 checks passed
@loopover-orb loopover-orb Bot added gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. and removed gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. labels Jul 10, 2026
@JSONbored JSONbored added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 11, 2026
@andriypolanski
andriypolanski deleted the feat/ui-reversal-health-card-2193 branch July 16, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

feat(ui): reversal-rate + auto-action health card

2 participants