Skip to content

fix: add loading indicator overlay to velocity heatmap page#1504

Open
eran132 wants to merge 1 commit intohasadna:mainfrom
eran132:fix/velocity-heatmap-loading-indicator
Open

fix: add loading indicator overlay to velocity heatmap page#1504
eran132 wants to merge 1 commit intohasadna:mainfrom
eran132:fix/velocity-heatmap-loading-indicator

Conversation

@eran132
Copy link
Copy Markdown

@eran132 eran132 commented Apr 13, 2026

Summary

  • Replaced the pink "loading!" text div with a proper semi-transparent overlay containing an MUI CircularProgress spinner and descriptive "Loading heatmap data..." text
  • Added an MUI Alert component for error states, positioned at the top of the map
  • Loading/error state is propagated from VelocityHeatmapRectangles to the parent page via callbacks, consistent with patterns used in the gaps and timeline pages

Closes #1483

Test plan

  • TypeScript compiles clean (tsc --noEmit)
  • ESLint, Stylelint, Prettier all pass with 0 warnings (npm run lint)
  • Jest unit tests pass (9/9)
  • Verify loading overlay appears on velocity heatmap page when data is loading
  • Verify error alert appears when API returns an error
  • Verify overlay disappears once data loads and heatmap renders

🤖 Generated with Claude Code

The velocity heatmap page loads data slowly but previously showed only
a pink div with "loading!" text, making users think the page was broken.

Replaced with a proper semi-transparent overlay with MUI CircularProgress
spinner and descriptive text, consistent with loading patterns used in
the gaps and timeline pages. Also added an Alert component for error
states.

Closes hasadna#1483

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 13, 2026 21:01
@eran132 eran132 requested a review from AvivAbachi as a code owner April 13, 2026 21:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the velocity heatmap page UX by replacing the basic loading/error UI with a proper loading overlay and an error alert, using MUI components and propagating loading/error state from the rectangles layer up to the page.

Changes:

  • Added page-level loading overlay with CircularProgress and “Loading heatmap data…” text.
  • Added page-level error Alert shown over the map when the data request fails.
  • Propagated loading/error state from VelocityHeatmapRectangles to the parent via optional callbacks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/pages/velocityHeatmap/index.tsx Adds loading overlay + error alert UI and wires callbacks from the rectangles layer.
src/pages/velocityHeatmap/components/VelocityHeatmapRectangles.tsx Introduces onLoadingChange / onErrorChange props and forwards react-query state upward.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +88 to +94
backgroundColor: 'rgba(255, 255, 255, 0.7)',
zIndex: 1000,
gap: 12,
}}>
<CircularProgress size={48} />
<span style={{ fontSize: '1.1em', color: '#333' }}>Loading heatmap data...</span>
</div>
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loading overlay uses zIndex: 1000, but .map-info .expand-button is styled with z-index: 2000 (see src/resources/map.scss). This means the expand button will remain above the overlay and still be clickable while loading, which defeats the purpose of an interaction-blocking overlay. Consider raising the overlay z-index above 2000 (or temporarily lowering/disabled the button / pointer events while loading).

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +94
useEffect(() => {
onErrorChange?.(error ? String(error) : null)
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onErrorChange?.(error ? String(error) : null) will render UI text like Error: ... for thrown Errors, and may degrade to [object Object] for non-Error rejections (e.g. from the API client). Consider normalizing the message (e.g., error instanceof Error ? error.message : JSON.stringify(error)), so the Alert shows a user-friendly string.

Suggested change
useEffect(() => {
onErrorChange?.(error ? String(error) : null)
const getErrorMessage = (errorValue: unknown): string | null => {
if (!errorValue) return null
if (errorValue instanceof Error) return errorValue.message
if (typeof errorValue === 'string') return errorValue
try {
return JSON.stringify(errorValue) || String(errorValue)
} catch {
return String(errorValue)
}
}
useEffect(() => {
onErrorChange?.(getErrorMessage(error))

Copilot uses AI. Check for mistakes.
Comment on lines 84 to 86
React.useEffect(() => {
if (setMinMax) setMinMax(minV, maxV)
}, [minV, maxV, setMinMax])
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component mixes React.useEffect (for setMinMax) with the named useEffect import (for loading/error propagation). For consistency and easier scanning, it would be better to use one style throughout (e.g. switch the React.useEffect call to useEffect).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@AvivAbachi AvivAbachi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks for contributing.

gap: 12,
}}>
<CircularProgress size={48} />
<span style={{ fontSize: '1.1em', color: '#333' }}>Loading heatmap data...</span>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add translation in src\locale for he and en
you can also use ai for ar\ru

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix loading indication in the velocity map page

3 participants