Smooth transaction volume chart clean#105
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds a smooth sliding animation to the TPS chart by introducing
Confidence Score: 5/5Safe to merge — the animation logic is well-contained and correctness degrades gracefully under unexpected conditions. The new animation helpers are isolated to the chart component, recharts explicit domain and ticks props prevent stale axis state, and all edge cases are handled. The one notable concern is that the animation progress formula uses the server-embedded timestamp rather than client receive time, which could stall animation under clock skew, but the fallback behavior is a static chart rather than a crash or data corruption. frontend/components/network-activity-tracker/tps-chart.tsx — specifically the progress formula in drawHistory if TPS timestamps are server-originated.
|
| Filename | Overview |
|---|---|
| frontend/components/network-activity-tracker/tps-chart.tsx | Adds rAF-driven sliding clock, progressive segment interpolation, and explicit tick generation for smooth chart animation; animation progress is tied to the client clock vs. server timestamps, which can cause skipped or stalled animation on clock skew. |
| frontend/pnpm-lock.yaml | Removes accidentally duplicated package and snapshot entries; no version or integrity hash changes. |
| frontend/pnpm-workspace.yaml | Adds allowBuilds entries for sharp and unrs-resolver to permit their native postinstall scripts. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["useSlidingNow (rAF setState now)"] -->|now every frame| B[TpsChart render]
C["useTps history"] --> B
B --> D["drawHistory history now"]
D --> E{history.length < 2?}
E -- yes --> F[return history unchanged]
E -- no --> G["duration = target.ts - from.ts"]
G --> H{duration <= 0?}
H -- yes --> F
H -- no --> I["progress = clamp 0 to 1"]
I --> J["head = lerp from to target at progress"]
J --> K["chartData = history slice plus head"]
B --> L["buildTicks windowStart now"]
L --> M["step = first TICK_STEPS >= span/6"]
M --> N["ticks anchored at now stepping back"]
K --> O["AreaChart domain windowStart to now"]
N --> O
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
frontend/components/network-activity-tracker/tps-chart.tsx:68
**Animation progress anchored to server timestamp, not client receive-time**
`progress` is computed as `(now - target.timestamp) / duration`, where `target.timestamp` is the timestamp embedded in the TPS data point. If those timestamps originate from the server clock, any client–server skew shifts the entire animation window: a client clock that lags the server will keep `progress` at 0 (clamped) until its clock catches up to `target.timestamp`, freezing the head at `from` and silently dropping the newest segment from the chart. The safe fix is to record the client-side receipt time and drive progress from that instead — e.g. store `receivedAt = Date.now()` alongside each incoming point and use `(now - receivedAt) / duration`.
Reviews (4): Last reviewed commit: "fix the x absis to have only 1 now" | Re-trigger Greptile
7770170 to
921a25c
Compare
Switch the X axis to a continuous time scale whose right edge eases toward the newest point's timestamp each animation frame. A freshly appended point sits just past the edge (clipped by allowDataOverflow) and is revealed sliding in from the right instead of snapping into a discrete category slot; the animation halts once the edge catches up, so the chart is still between points. isAnimationActive stays disabled to avoid Recharts re-animation loops on every TPS event. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
061abaf to
1f55e3a
Compare
* fix(tps-chart): smooth Transaction volume line Switch the TPS Area interpolation from `linear` to `monotone` so the Transaction volume chart renders as a smooth curve instead of connected straight segments between data points. * fix(tps-chart): animate new data points instead of curving the line Revert line interpolation to linear and enable Recharts' built-in animation so newly arriving data points ease into the chart instead of snapping in. This is the smoothing that was actually requested: the visible motion of new points appearing, not the line shape. * feat(tps-chart): smooth streaming via sliding time-window X axis Switch the X axis to a continuous time scale with a [now - 5min, now] domain advanced each animation frame, so new points slide in smoothly from the right edge instead of popping into discrete category slots. Keeps isAnimationActive disabled to avoid Recharts re-animation loops on each TPS event. Clamp the domain's left edge to the oldest point so the chart fills immediately instead of showing an empty 5-minute lead-in. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: update pnpm lockfile and allow sharp/unrs-resolver builds Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: minimize lockfile diff vs main Replaces frontend/pnpm-lock.yaml with main's lockfile minus the duplicate keys introduced by PR #97 (so pnpm 10 can parse it). No package versions change vs main; pnpm install --frozen-lockfile passes. The previous commit on this branch ran a non-frozen pnpm install, which silently re-resolved every floating semver in package.json and produced ~2000 lines of incidental lockfile churn. This commit reverses that. * ci: unified frontend workflow (lint + typecheck + build) * ci: add rust job (fmt + clippy + build) * ci: run rust job in rust:1.91-slim container for libclang/bindgen parity * perf(frontend): reduce GC pressure and re-renders in the live event pipeline (#98) **Motivation:** After ~1h on node.monad.xyz the renderer process is killed for OOM. There is no single growing array — every component bounds its state — but at ~200 TPS the per-event fan-out from EventsContext drives enough short-lived allocations to fragment the heap. Backgrounded tabs are worse because the browser does not throttle WebSocket onmessage. **Modifications:** 1. Memoize EventsContext value so consumers don't re-render every time TopAccesses updates. 2. Drop WebSocket messages while document.visibilityState === 'hidden' to avoid running the dispatch + decode pipeline for an invisible tab. 3. Move the in-flight block's transactions out of React state into a ref-backed Map<txnIndex, Transaction>. Per-event updates are now O(1) instead of O(N), and the block is materialized into React state once at BlockFinalized/BlockVerified. 4. Allow subscribers to register an eventTypes filter on subscribe, and apply it at dispatch time so swap/transfer/totals hooks no longer run on BlockStart/TxnHeaderStart/etc. **Result:** Live event dispatch does far less work per WebSocket message, in-flight blocks no longer reallocate their transactions array on every txn event, and a backgrounded tab is effectively idle until it becomes visible again. Co-authored-by: dak-agent[bot] <284037069+dak-agent[bot]@users.noreply.github.com> * Smooth transaction volume chart clean (#105) * feat(tps-chart): smoothly extend the line to each new point Switch the X axis to a continuous time scale whose right edge eases toward the newest point's timestamp each animation frame. A freshly appended point sits just past the edge (clipped by allowDataOverflow) and is revealed sliding in from the right instead of snapping into a discrete category slot; the animation halts once the edge catches up, so the chart is still between points. isAnimationActive stays disabled to avoid Recharts re-animation loops on every TPS event. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: update pnpm lockfile and allow sharp/unrs-resolver builds Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * drawing lines smoothly between the points creation * fix the x absis to have only 1 now --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(backend): resolve clippy lints (#101) * fix(backend): resolve auto-fixable clippy lints Addresses 6 of the 8 clippy findings surfaced by the new rust CI job: - needless_return (server.rs) - match_like_matches_macro (server.rs) - ptr_arg: &Vec<T> -> &[T] (event_filter.rs) - needless_borrow (event_filter.rs) - manual_is_multiple_of (event_listener.rs) - clone_on_copy (serializable_event.rs) Remaining (require manual judgment, deferred): large_enum_variant (server.rs), should_implement_trait for from_str (event_listener.rs). * fix(backend): resolve non-auto-fixable clippy lints - large_enum_variant: box the 640-byte Event variant of EventDataOrMetrics (Event(Box<EventData>)). Since From::from infers its parameter type from the argument (deref coercion does not apply), the match-site call passes &*event_data to select From<&EventData>; construction uses Box::new(..). - should_implement_trait: rename inherent EventName::from_str -> from_name (and its single caller) so it no longer shadows std::str::FromStr::from_str. * fix(backend): remove redundant u64 casts in client (unnecessary_cast) Surfaced once the lib compiled clean: timestamp_ns is u64, so the (u64 - u64) as u64 casts are redundant; drop the cast and parens. --------- Co-authored-by: dak-agent[bot] <284037069+dak-agent[bot]@users.noreply.github.com> Co-authored-by: Camillebzd <bcamille99@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Camillebzd <48495021+Camillebzd@users.noreply.github.com>
No description provided.