feat: add custom days input to time window picker#339
feat: add custom days input to time window picker#339egeoztass wants to merge 3 commits intoOpenpanel-dev:mainfrom
Conversation
Adds a "Last X days" input field to the time window dropdown, allowing users to quickly filter by any number of days (1-365) without opening the full calendar picker. The input calculates start/end dates and uses the existing custom range mechanism, so no backend changes are needed. Closes Openpanel-dev#168 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an inline "Last X days" numeric control (1–365) to TimeWindowPicker that computes start/end timestamps, selects the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/start/src/components/time-window-picker.tsx`:
- Around line 231-239: The onKeyDown handler for the custom days input (the
arrow function attached to onKeyDown) handles Enter but does not call
e.preventDefault(), which can cause form submission when this dropdown is inside
a form; update that handler to call e.preventDefault() before processing the
Enter key, then parse and validate customDays and call handleCustomDays(days)
and setCustomDays('') as before, while keeping e.stopPropagation() to preserve
existing behavior.
- Around line 53-54: The end and start date calculations call new Date() twice
which can drift across midnight; capture a single timestamp (e.g., const now =
new Date()) once in the TimeWindowPicker component and use it for both
endOfDay(now) and startOfDay(subDays(now, days - 1)) so the computed window is
consistent; update references to "end" and "start" (and any dependent variables)
to use that single now snapshot.
- Around line 224-243: The custom days numeric input (the Input component using
value={customDays}, onChange={setCustomDays} and onKeyDown that calls
handleCustomDays) lacks a programmatic label; add an accessible label by either
giving the input an aria-label like "Custom days" or adding an id to the input
and an associated <label htmlFor="..."> or aria-labelledby that references the
visible "days" text so screen readers announce the field correctly; update the
Input props to include the chosen aria-label or id and ensure any referenced
label element has the matching id.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b4223dc6-f144-4323-80f4-3deed010f902
📒 Files selected for processing (1)
apps/start/src/components/time-window-picker.tsx
- Use single Date snapshot to avoid midnight drift - Add aria-label for accessibility - Add e.preventDefault() on Enter to prevent form submission Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/start/src/components/time-window-picker.tsx`:
- Around line 227-239: The onKeyDown handler for the customDays input currently
uses Number.parseInt(customDays, 10) which truncates exponential/decimal input;
update the parsing to use const days = Number(customDays) and then validate with
Number.isFinite(days) and Number.isInteger(days) (or allow decimals per UX)
before checking the 1–365 range, then call handleCustomDays(days) and reset via
setCustomDays(''); keep references to the same handlers (onKeyDown,
setCustomDays, handleCustomDays, customDays) when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9340cd07-8b6e-4593-9384-55f2a5cc30c0
📒 Files selected for processing (1)
apps/start/src/components/time-window-picker.tsx
Prevents truncation of edge-case inputs like 1e2 or 12.5 by using
Number() with Number.isInteger() validation. Also adds step={1} to
the input to hint integer-only values.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
customrange mechanism — no backend or constant changes neededapps/start/src/components/time-window-picker.tsxHow it works
Implementation details
startOfDay(today - X + 1)toendOfDay(today)getDefaultIntervalByDates()to auto-select hour/day/month intervalstopPropagationTest plan
Closes #168
🤖 Generated with Claude Code
Summary by CodeRabbit