Add 100-item limit to getSandboxesMetrics and batch client requests
#290
Claude / Claude Code Review
completed
Apr 8, 2026 in 8m 25s
Code review found 2 important issues
Found 5 candidates, confirmed 2. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 2 |
| 🟡 Nit | 0 |
| 🟣 Pre-existing | 0 |
| Severity | File:Line | Issue |
|---|---|---|
| 🔴 Important | src/features/dashboard/sandboxes/list/hooks/use-sandboxes-metrics.tsx:91-107 |
Partial chunk failure silently shows mixed-freshness metrics |
| 🔴 Important | src/features/dashboard/sandboxes/list/hooks/use-sandboxes-metrics.tsx:78-107 |
useQueries array instability causes mergedMetrics to recompute every render |
Annotations
Check failure on line 107 in src/features/dashboard/sandboxes/list/hooks/use-sandboxes-metrics.tsx
claude / Claude Code Review
Partial chunk failure silently shows mixed-freshness metrics
When one or more batch chunks fail (e.g., a transient network error), only the successful chunks contribute to `mergedMetrics`, while the Zustand store's `setMetrics` merges the partial result into existing state (`{ ...state.metrics, ...metrics }`), leaving sandbox IDs from the failed chunk with their previous stale values indefinitely. The UI then silently displays a mixed-freshness table—some rows current, others outdated—with no error or loading indicator to alert the user. Before this PR a
Check failure on line 107 in src/features/dashboard/sandboxes/list/hooks/use-sandboxes-metrics.tsx
claude / Claude Code Review
useQueries array instability causes mergedMetrics to recompute every render
The new `useQueries` call returns a new array reference on every render (without `combine`), so `useMemo([queryResults])` recomputes `mergedMetrics` every render cycle—even when fetched data is unchanged. This causes `useEffect` to fire and `setMetrics` to be called on every render, which updates the Zustand store and re-renders all sandbox metric cells on every polling interval. The fix is to add a `combine` option to `useQueries` that merges results into a stable object, so downstream dependen
Loading