Skip encoding slider parameters at default max values in URL#68
Skip encoding slider parameters at default max values in URL#68lookbusy1344 merged 7 commits intomainfrom
Conversation
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>
|
@claude how does this look? |
|
Claude finished @lookbusy1344's task in 1m 18s —— View job Code Review Complete ✓
OverviewThis PR successfully addresses the URL encoding issue where slider values at default positions were being unnecessarily encoded in URLs. The implementation is clean and well-tested. What Works Well1. Implementation Logic (urlState.ts:390-410)
2. Test Coverage (urlState.test.ts)
3. Code Quality
Suggestions for Improvement1. Test Isolation (Minor) // Option A: Import and test the actual updateURL() function
import { updateURL } from './urlState';
it('should skip encoding mass slider when at max value', () => {
const slider = document.getElementById('accelMassSlider') as HTMLInputElement;
slider.value = '365';
updateURL();
const url = new URLSearchParams(window.location.search);
expect(url.has('massSlider')).toBe(false);
});However, I understand this would require more complex DOM setup (Bootstrap tabs, etc.), so the current helper approach is pragmatic. Just be aware that the helpers test the logic, not the integration. 2. Edge Case: Values Above Max (Very Minor) // More explicit boundary check
if (!isNaN(sliderMax) && !isNaN(sliderValue) && sliderValue >= sliderMax) {
continue;
}Current code is fine though - using 3. Distance Slider: Percentage Above 100 (Very Minor) Testing RecommendationPer the CLAUDE.md guidelines: yarn test:run # Verify tests pass
yarn type-check # Verify TypeScript compilation
yarn build # Verify production buildVerification of FixThe PR correctly addresses the examples from issue #67:
VerdictThis looks great! ✓ The implementation is solid, well-tested, and follows the existing codebase patterns. The only suggestions above are very minor refinements - the current code is ready to merge as-is. The approach of checking slider positions before encoding is clean, efficient, and solves the stated problem effectively. Nice work! |
|
@copilot does this have any precision issues, where the value is very close to but not at max? Like 99.99 instead of 100 |
…ction Co-authored-by: lookbusy1344 <3680611+lookbusy1344@users.noreply.github.com>
Good catch! I've added an epsilon tolerance of 0.01 to handle floating-point precision issues. The code now treats slider values within 0.01 of the maximum as being "at max" to avoid encoding them. This handles cases where:
The epsilon of 0.01 is chosen to be smaller than the slider step sizes (0.5 for distance, 0.1 for mass) but large enough to catch rounding errors. Added 2 new tests to verify this behavior works correctly. Commit: 2667a36
The implementation looks good! The fix correctly identifies when sliders are at their default maximum positions and skips encoding them in the URL. I've now also added epsilon tolerance to handle floating-point precision issues that you mentioned in your follow-up comment. All 372 tests pass, including 9 new tests specifically for this URL encoding logic. |
… 0.5 Resolves issue where slider at chart max (3.4 years) was incorrectly encoded in URL because it didn't match HTML default (4 years). Now rounds up chart max to encompass calculation result, then checks if slider is at its current maximum. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code Review: Skip encoding slider parameters at default max values in URLSummaryThis PR successfully addresses the issue of unnecessarily encoding slider parameters in URLs when they're at their default maximum positions. The implementation is well-thought-out and includes comprehensive test coverage. ✅ Strengths1. Well-Defined Problem & Solution
2. Excellent Test Coverage
3. Precision Handling
4. Timing Coordination
|
Plan: Fix default parameter URL encoding for sliders
updateURL()function inurlState.tsto skip encoding sliders at max valuesSummary
Successfully fixed the issue where slider parameters were unnecessarily encoded in URLs when at their default maximum positions.
Changes Made:
Modified
/Javascript/src/urlState.ts:massSliderwhen at maximum value (lines 390-400)distSliderwhen at 100% (lines 402-413)Added comprehensive tests in
/Javascript/src/urlState.test.ts:Precision Handling:
The code now uses an epsilon tolerance of 0.01 to handle cases where:
This ensures that sliders very close to their maximum (within 0.01) are still treated as being at max and not encoded in the URL.
Results:
Before:
?tab=motion&distSlider=10.00&massSlider=365appeared even when sliders were at defaultsAfter:
?tab=motionwhen sliders are at default positionsAll tests pass (372 total), build succeeds, and no security vulnerabilities detected.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.