Skip to content

Persist mass chart slider state to URL parameters#64

Merged
lookbusy1344 merged 4 commits intomainfrom
copilot/fix-slider-state-management
Dec 9, 2025
Merged

Persist mass chart slider state to URL parameters#64
lookbusy1344 merged 4 commits intomainfrom
copilot/fix-slider-state-management

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

The ship mass over time sliders on the 'constant accel' and 'flip' tabs were not persisted to the URL, preventing users from sharing specific chart views.

Changes

  • URL state configuration: Added massSlider parameter to motion and flip tab configs, enabling automatic URL sync through existing infrastructure
  • Deferred restoration: Implemented applyPendingSliderValue() to restore slider values after chart initialization, when slider ranges are known
  • Chart integration: Updated accel/flip handlers in main.ts to apply pending URL values post-initialization

Implementation

The slider values are synced bidirectionally:

  • Write path: Existing setupURLSync() automatically captures slider changes
  • Read path: New mechanism stores URL values as pending, then applies them after chart/slider initialization completes
// Store pending value from URL during initial load
if (paramName === 'massSlider') {
    const numValue = parseFloat(paramValue);
    if (!isNaN(numValue)) {
        pendingSliderValues[inputId] = numValue;
    }
}

// Apply after chart initialization (50ms delay for async chart rendering)
setTimeout(() => {
    initializeMassChartSlider(...);
    applyPendingSliderValue('accelMassSlider', 'accelMassSliderValue', 'days', 'accelMassChart', chartRegistry);
}, 50);

Range validation ensures slider values remain within chart data bounds, with error handling for chart update failures.

Original prompt

This section details on the original issue you should resolve

<issue_title>Slider state management</issue_title>
<issue_description>In the JavaScript project, the ‘constant accel’ and ‘flip’ tabs have diagrams for ship mass over time. This has a slider to control the x axis, but it is not persisted on the URL. Let’s fix that</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 9, 2025 15:26
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix slider state management for URL persistence Persist mass chart slider state to URL parameters Dec 9, 2025
Copilot AI requested a review from lookbusy1344 December 9, 2025 15:33
@lookbusy1344 lookbusy1344 marked this pull request as ready for review December 9, 2025 16:27
@lookbusy1344 lookbusy1344 merged commit aeb198c into main Dec 9, 2025
7 of 8 checks passed
@lookbusy1344 lookbusy1344 deleted the copilot/fix-slider-state-management branch December 9, 2025 16:27
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.

Slider state management

2 participants