Skip to content

test(miner-ui): add unit coverage for chat-scroll stick-to-bottom logic - #7847

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:test/chat-scroll-coverage-7793
Jul 21, 2026
Merged

test(miner-ui): add unit coverage for chat-scroll stick-to-bottom logic#7847
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:test/chat-scroll-coverage-7793

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What & why

Closes #7793.

apps/loopover-miner-ui/src/lib/chat-scroll.ts (isChatViewportNearBottom, scrollChatViewportToBottom, CHAT_NEAR_BOTTOM_PX) encodes the boundary threshold and clamp math for the chat stick-to-bottom auto-scroll — fiddly logic that already needed a dedicated bug-fix once (#7229/#7298). No test exercised it directly: message-list.test.tsx only checks DOM structure/StateBoundary branches, and jsdom doesn't meaningfully simulate scrollTop/scrollHeight there. This closes that gap, following the one-test-per-pure-module convention demo-data.test.ts establishes in the same directory.

What's tested (a co-located chat-scroll.test.ts)

  • isChatViewportNearBottom: distance 0 (at bottom); exactly at the 80px boundary (<= 80 → true) and one pixel past it (81 > 80 → false) — the both-sides boundary case that motivated the prior bug-fix; scrolled well up → false; short content (viewport taller than content, negative distance) → true; a custom threshold overriding the default (proving the arg is used); and that CHAT_NEAR_BOTTOM_PX === 80.
  • scrollChatViewportToBottom: sets scrollTop to scrollHeight - clientHeight for scrollable content, and the Math.max(0, …) clamp pinning it to 0 when content is shorter than the viewport.

Pure coverage addition — no source change. Per the issue, apps/loopover-miner-ui is not under the src/** 99% patch gate; this new test file is the issue's own coverage deliverable.

Validation

  • apps/loopover-miner-ui vitest run: 9 tests pass; tsc --noEmit exit 0; eslint clean; Prettier clean.
  • Tests genuinely bite: mutating the boundary (<=<) and dropping the Math.max(0, …) clamp each fail a test.
  • New file only; branched off current main, mergeable-clean.

apps/loopover-miner-ui/src/lib/chat-scroll.ts (isChatViewportNearBottom,
scrollChatViewportToBottom, CHAT_NEAR_BOTTOM_PX) had no direct test despite
already needing a dedicated bug-fix once (JSONbored#7229/JSONbored#7298), and message-list.test.tsx
only covers DOM structure, not the scroll math. Add a co-located unit test
following the one-test-per-pure-module convention (demo-data.test.ts): cover
isChatViewportNearBottom's <= 80px boundary on both sides, short-content and
custom-threshold cases, and scrollChatViewportToBottom's Math.max(0, ...) clamp.
@shin-core
shin-core requested a review from JSONbored as a code owner July 21, 2026 15:00
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 21, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@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 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-21 15:08:15 UTC

1 file · 1 AI reviewer · no blockers · CI green · unstable

⏸️ Suggested Action - Manual Review

Review summary
This is a pure, additive test file for the already-existing `chat-scroll.ts` module, closing the coverage gap noted in issue #7793 with no production code changes. The boundary-condition tests (80px inclusive vs 81px exclusive) and the `Math.max(0, ...)` clamp test correctly mirror the actual implementation shown in the reference file, and the assertions match the real math rather than a fabricated scenario. This is a low-risk, well-scoped test-only PR that directly closes its linked issue.

Nits — 3 non-blocking
  • The `viewport()` helper and file-level comment duplicate explanation already present inline per-test; could trim one or the other for brevity.
  • Consider also testing a fractional/negative custom threshold edge case, though the current coverage of the core boundary is sufficient.
  • No changes required; optionally add a one-line test asserting `scrollChatViewportToBottom` is a no-op when scrollTop already equals the target, though this is not required for coverage.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7793
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: 90 registered-repo PR(s), 50 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor shin-core; Gittensor profile; 90 PR(s), 0 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal
Linked issue satisfaction

Addressed
The PR adds a co-located chat-scroll.test.ts directly exercising isChatViewportNearBottom (including both sides of the 80px boundary, custom threshold, and short-content cases) and scrollChatViewportToBottom's clamp behavior, matching the one-test-per-pure-module convention the issue asks for.

Review context
  • Author: shin-core
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript, JavaScript, Solidity, Dart, Python, CSS, PHP, Rust
  • Official Gittensor activity: 90 PR(s), 0 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.
🧪 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 &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; 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

@loopover-orb loopover-orb Bot left a comment

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.

LoopOver approves — the gate is satisfied and CI is green.

@JSONbored
JSONbored merged commit 5aad506 into JSONbored:main Jul 21, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chat-scroll.ts (auto-scroll stick-to-bottom logic) has zero test coverage despite a prior dedicated bug-fix PR

2 participants