Skip to content

test(ui): add coverage for use-latency-history rolling localStorage history#7948

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7904
Jul 24, 2026
Merged

test(ui): add coverage for use-latency-history rolling localStorage history#7948
JSONbored merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7904

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

Closes #7904

Adds unit-test coverage for the rolling localStorage latency-history hook.

Screenshots

Viewport · Theme Before After
Desktop · Light
before

after
Desktop · Dark
before

after
Tablet · Light
before

after
Tablet · Dark
before

after
Mobile · Light
before

after
Mobile · Dark
before

after

…istory

Extracts the merge/dedup step of useLatencyHistory into an exported
mergeLatencyHistory and exports the useSyncExternalStore snapshot getter so
the module's dedup-by-minute, 30-day retention pruning, endpoint-count cap,
and referential-stability behavior (the fix for a real infinite-render bug)
can all be tested directly, in line with this repo's no-jsdom convention of
testing a hook's pure functions rather than renderHook.

Closes JSONbored#7904
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 24, 2026 14:09
@superagent-security

Copy link
Copy Markdown

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

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.58%. Comparing base (487ef64) to head (7fc59bd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7948   +/-   ##
=======================================
  Coverage   97.58%   97.58%           
=======================================
  Files         204      204           
  Lines       26365    26365           
  Branches    10452    10452           
=======================================
  Hits        25729    25729           
  Misses        150      150           
  Partials      486      486           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-24 16:13:38 UTC

2 files · 1 AI reviewer · no blockers · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): apps/ui/src/hooks/use-latency-history.test.ts (matched apps/ui/**), apps/ui/src/hooks/use-latency-history.ts (matched apps/ui/**).

Review summary
This is a pure test-addition PR (plus a small, behavior-preserving refactor extracting the existing merge logic into an exported `mergeLatencyHistory` function and exporting `getSnapshot`) that adds unit coverage for the rolling localStorage latency-history hook, closing issue #7904. The extracted `mergeLatencyHistory` is a faithful lift of the prior inline `useMemo` body with no logic change, and the new tests correctly exercise dedup, retention pruning, endpoint capping, SSR no-op paths, and the useSyncExternalStore snapshot-stability regression. The screenshot table is irrelevant here since this PR touches no rendered UI — the vision summary correctly notes no visible UI difference, which is expected for a hooks-only test/refactor PR.

Nits — 6 non-blocking
  • The PR ships a cosmetic before/after screenshot table for a change with zero visual impact (pure test/refactor of a non-rendering hook); the automated capture pipeline will supply the same non-diff evidence, so the table adds no signal here.
  • apps/ui/src/hooks/use-latency-history.ts:141-146 — mergeLatencyHistory is now a standalone exported function purely for testability; consider a brief note that it's intentionally pure/exported for unit tests rather than for external consumers, to avoid future callers treating it as public API surface.
  • Confirm issue test(ui): add coverage for use-latency-history.ts (rolling localStorage latency history) #7904 is scoped specifically to test coverage (not a UI-visible fix), since the PR title and diff are consistent with that but worth a one-line cross-check against the issue body.
  • Consider adding a co-located test for useLatencyHistory's useMemo wrapper itself (e.g. via @​testing-library/react-hooks) to cover the memoization dependency array, though this is optional given mergeLatencyHistory is now unit-tested directly.
  • Possible screenshot-table issue: pair 1 — Advisory only — verify the screenshot-table images against the stated change before deciding.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ⚠️ Gate result — Not blocking (Advisory; not blocking this PR.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7904
Related work ⚠️ 1 scoped overlap Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High 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: 50 registered-repo PR(s), 27 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 50 PR(s), 0 issue(s).
Linked issue satisfaction

Addressed
The PR adds a dedicated test file for use-latency-history.ts covering minute-bucket dedup, 30-day retention pruning, endpoint-count capping, and explicitly tests getSnapshot's referential stability which is the exact useSyncExternalStore infinite-render fix the issue calls out; it also stays confined to the hooks directory with no .tsx changes.

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 50 PR(s), 0 issue(s).
  • Related work: Titles/paths share 7 meaningful terms. (PR #7949)
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

andriypolanski pushed a commit to andriypolanski/metagraphed that referenced this pull request Jul 24, 2026
…istory (JSONbored#7948)

Extracts the merge/dedup step of useLatencyHistory into an exported
mergeLatencyHistory and exports the useSyncExternalStore snapshot getter so
the module's dedup-by-minute, 30-day retention pruning, endpoint-count cap,
and referential-stability behavior (the fix for a real infinite-render bug)
can all be tested directly, in line with this repo's no-jsdom convention of
testing a hook's pure functions rather than renderHook.

Closes JSONbored#7904

Co-authored-by: bitfathers94 <237535319+bitfathers94@users.noreply.github.com>
@JSONbored
JSONbored merged commit e0b16cb into JSONbored:main Jul 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix or unsolicited PR — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(ui): add coverage for use-latency-history.ts (rolling localStorage latency history)

2 participants