The Issue
Inside renderProgressHistoryChart, the fallback logic calculates baseTotal by running .sort() directly on the history array. Because JavaScript arrays are passed by reference, this mutates selectedUserData.sh.history in-place within the global state cache.
The Impact
Subsequent chart updates, data re-renders, or filter toggles read a corrupted, scrambled timeline. This breaks chronological rendering, causing line plots to wildly zigzag or crash entirely.
Action Items for Maintainers
We need to determine the best path forward based on how the global state is intended to be structured:
- Option 1 (Isolate with a Copy): If the global cache requires a strict, predictable order (e.g., newest to oldest) for other components, we should create a shallow copy (
[...history].sort()) to isolate the chart's logic.
- Option 2 (Standardize Global Order): If the array should naturally be ordered from oldest to newest across the entire app, we should move this sorting logic up to the data-fetching or state-initialization layer instead of letting a rendering function mutate it downstream.
I would like to work on this.
The Issue
Inside
renderProgressHistoryChart, the fallback logic calculatesbaseTotalby running.sort()directly on thehistoryarray. Because JavaScript arrays are passed by reference, this mutatesselectedUserData.sh.historyin-place within the global state cache.The Impact
Subsequent chart updates, data re-renders, or filter toggles read a corrupted, scrambled timeline. This breaks chronological rendering, causing line plots to wildly zigzag or crash entirely.
Action Items for Maintainers
We need to determine the best path forward based on how the global state is intended to be structured:
[...history].sort()) to isolate the chart's logic.I would like to work on this.