Format date/time slider URL query params as ISO strings#14120
Format date/time slider URL query params as ISO strings#14120mayagbarnes merged 13 commits intodevelopfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull request overview
This pull request enhances the user experience of date/time/datetime sliders with bind="query-params" by formatting URL query parameters as human-readable ISO strings instead of raw microsecond timestamps.
Changes:
- Date sliders now display
?date=2024-06-15instead of?date=1718409600000000 - Time sliders format as
?time=14:30and datetime as?datetime=2024-06-15T14:30 - Backend parses ISO strings when reading from URLs; frontend formats to ISO when writing to URLs
- Wire protocol remains unchanged (still uses microsecond floats internally)
- Old bookmarked URLs with raw microsecond values continue to work (backward compatible)
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
lib/streamlit/runtime/state/query_params.py |
Added _try_parse_iso_to_micros() function to parse ISO date/time/datetime strings to microseconds, integrated into parse_url_param() for double_array_value types |
lib/tests/streamlit/runtime/state/query_params_test.py |
Added comprehensive unit tests for ISO parsing function and integration with parse_url_param, including backward compatibility tests |
lib/streamlit/elements/widgets/slider.py |
Updated comment to cross-reference the TIME_BASE_DATE constant used in query_params.py |
frontend/lib/src/WidgetStateManager.ts |
Added microsToIsoString() function and DateType type; modified registerQueryParamBinding() and convertToUrlValue() to handle date type formatting |
frontend/lib/src/WidgetStateManager.test.ts |
Added unit tests for ISO formatting in URL updates, default value handling, and range sliders |
frontend/lib/src/hooks/useQueryParamBinding.ts |
Added dateType to QueryParamBindingOptions interface and passed to registerQueryParamBinding() |
frontend/lib/src/hooks/useBasicWidgetState.ts |
Added dateType to QueryParamBindingConfig and included in memoized options |
frontend/lib/src/components/widgets/Slider/Slider.tsx |
Added dateType to query param binding configuration for date/time/datetime sliders |
e2e_playwright/st_slider.py |
Added four new test sliders (date, time, datetime, date range) with query param binding |
e2e_playwright/st_slider_test.py |
Added E2E tests verifying ISO URL seeding, invalid input handling, and out-of-range value handling |
This comment was marked as duplicate.
This comment was marked as duplicate.
Consolidated Code Review — PR #14120Format date/time slider URL query params as ISO strings SummaryThis PR improves URL readability for date/time/datetime sliders when using The conversion is localized to the URL boundary:
The internal wire format (protobuf Code QualityBoth reviewers agreed the code is well-structured and follows existing patterns:
Timezone handling in
|
602b56f to
bddc264
Compare
Consolidated Code ReviewSummaryThis PR improves the URL readability of date/time/datetime slider query parameters when using The conversion is cleanly localized to the URL boundary:
Reviewer AgreementBoth reviewers (
Code QualityThe implementation is well-structured and follows existing codebase patterns:
Minor observation (non-blocking): In Test CoverageTest coverage is thorough across all three testing layers:
Backwards CompatibilityBackward compatibility is well-handled:
Security & RiskLow risk. The AccessibilityNo accessibility concerns. This PR does not modify any UI rendering, DOM structure, or ARIA attributes — changes are purely in URL serialization logic. Recommendations (non-blocking)
VerdictAPPROVED: Both reviewers approve. The change is well-designed, backwards-compatible, and thoroughly tested across all layers. The recommendations above are minor, non-blocking refinements. Consolidated review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR changes date/time/datetime slider query-param behavior to use human-readable ISO strings in the URL while preserving the internal microsecond wire format. The frontend now serializes slider micros to ISO for URL writes, and the backend parses ISO URL values back to micros on seeding. The change is scoped to query-param boundaries and includes frontend unit tests, backend unit tests, and e2e coverage updates. Code QualityThe implementation is cleanly split across boundaries and follows existing patterns:
No code-quality issues were identified that should block merge. Test CoverageCoverage is strong overall:
One remaining test gap is that legacy raw-microsecond URLs for date/time/datetime sliders are validated at unit level, but not explicitly by an end-to-end scenario. Backwards CompatibilityBackwards compatibility looks preserved:
Given the current tests, I see low compatibility risk. Security & RiskNo security concerns were identified. The change is primarily data-format transformation for query parameters and does not introduce new sensitive data flows, auth paths, or unsafe execution behavior. Regression risk is low and concentrated in query-param parsing/serialization paths. AccessibilityNo material accessibility impact observed. The frontend changes are in state/query-param handling and do not alter slider semantics, focus behavior, ARIA labels, or interaction affordances. Recommendations
VerdictAPPROVED: The change is well-scoped, well-tested, and ready to merge; only minor non-blocking test hardening is recommended. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR improves the URL readability of date/time/datetime slider query parameters when using The conversion is localized to the URL boundary:
Code QualityThe code is well-structured with clear separation of concerns. The implementation follows existing patterns in the codebase and is well-documented with inline comments explaining design decisions. Strengths:
Minor observations:
Test CoverageTest coverage is thorough across all three testing layers: Frontend unit tests (
Backend unit tests (
E2E tests (
Potential gap: The E2E test suite adds many individual test functions. Per the E2E AGENTS.md guidance ("prefer aggregated scenario tests over many micro-tests"), some of the seeding tests (date, time, datetime, date range) could potentially be consolidated into a single aggregated test to reduce browser loads. However, the test isolation makes each test's intent very clear, which is valuable for debugging. Backwards CompatibilityBackward compatibility is well-handled:
Security & RiskLow risk. The changes are localized to URL serialization/deserialization:
AccessibilityNo accessibility concerns. This PR does not modify any UI rendering, DOM structure, or ARIA attributes. The changes are purely in URL serialization logic. The only Slider.tsx change is passing The unrelated change to Recommendations
VerdictAPPROVED: A well-designed, backwards-compatible improvement to URL readability for date/time sliders with comprehensive test coverage across all layers. The minor suggestions above are non-blocking refinements. This is an automated AI review by |
Describe your changes
?date=2024-06-15,?time=14:30,?dt=2024-06-15T14:30) instead of raw microsecond timestamps (e.g., ?date=1718409600000000).Testing Plan