-
Notifications
You must be signed in to change notification settings - Fork 68
feat: extend sandboxes monitoring charts to support up to 90 days #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
3
commits into
main
Choose a base branch
from
devin/1780334031-90d-timepicker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
7c34e66
feat: extend sandboxes monitoring to support up to 90 days
devin-ai-integration[bot] 8de383e
fix: use '90 days' in user-facing error messages and update mock data…
devin-ai-integration[bot] 543fbf8
refactor: use exact 90-day MAX_DAYS_AGO with separate buffer constant
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The validation error messages now reference "91 days" (
Start date cannot be more than 91 days ago/Date range cannot exceed 91 days) but the UI advertises 90 days everywhere — the new "Last 90 days" preset in TIME_OPTIONS/TIME_RANGES and the header card's "(90-day max)" label. A user who selects "Last 90 days" and nudges the start a touch earlier in the custom picker will see an error referencing a 91-day limit the UI never promised. The same drift propagates server-side becauseget-team-metrics.ts:29,get-team-metrics-max.ts:32,schemas.ts:18,36, andapp/api/teams/[teamSlug]/metrics/types.ts:18,35interpolateMAX_DAYS_AGO / 86_400_000(= 91) into their error text. Either hardcode "90 days" in user-facing messages and keepMAX_DAYS_AGOas the internal clock-skew buffer, or tightenMAX_DAYS_AGOto 90 days and add a separate small buffer constant (the existingCLOCK_SKEW_TOLERANCE = 60_000already covers clock skew).Extended reasoning...
What the bug is
The PR introduces a "Last 90 days" preset and updates the header card to read "(90-day max)" — the user-visible product surface promises 90 days. Internally, however,
MAX_DAYS_AGOis set to 91 days (apparently a 1-day safety buffer over the advertised 90), and the validation error strings invalidation.tswere rewritten to literally say91 days:The same
91leaks into server-side error toasts because several schemas build their messages by dividingMAX_DAYS_AGOby86_400_000:src/core/server/functions/sandboxes/get-team-metrics.ts:29and:46src/core/server/functions/sandboxes/get-team-metrics-max.ts:32and:50src/core/modules/sandboxes/schemas.ts:18and:36src/app/api/teams/[teamSlug]/metrics/types.ts:18and:35All of those now interpolate
91into user-facing error messages.How it manifests — step-by-step proof
setTimeRange('90d')is called, which computesnow - 90 * 24 * 60 * 60 * 1000and writes the resulting start/end to the URL.superRefinechecksstartTimestamp < now - MAX_DAYS_AGO.MAX_DAYS_AGOis now 91 days, so the picker happily accepts up to 91 days back — but if the user moves the start more than 1 day before the original 90-day preset (still well within what "90-day max" suggests should be allowed/rejected boundary), they'll first see no error.91baked into their template-literal error text, so any path that hits the API directly (or any case where client-side validation is bypassed/raced) surfaces "91 days" to the user as well.Why existing code doesn't prevent it
The PR deliberately left
MAX_DAYS_AGO = 91 * 24 * 60 * 60 * 1000as a 1-day safety buffer (mirrored by the60_000ms margin inheader.tsx:162for the same reason). That buffer is sensible internally, but it leaks because (a) the new copy invalidation.tshard-codes the buffered number into the human-readable string, and (b) the server-side schemas compute the user-facing copy directly fromMAX_DAYS_AGO. There's no separate "advertised max" constant to drive UX copy independently.Impact
UX polish, not a functional bug — the picker still works and the data still loads. But a user who reads "(90-day max)" and then sees "91 days" in a validation toast is left wondering which is correct, and the inconsistency surfaces an implementation detail (the clock-skew buffer) as if it were a product limit. It's more visually jarring at 90/91 than at the previous 30/31 because the larger numbers are read more carefully.
How to fix
Two clean options:
validation.ts:46and:111to say'90 days'instead of'91 days', and change the server-side templates inget-team-metrics.ts,get-team-metrics-max.ts,schemas.ts, andmetrics/types.tsto interpolate a separateADVERTISED_MAX_DAYS = 90constant (or just hardcode90) instead ofMAX_DAYS_AGO / 86_400_000.MAX_DAYS_AGOto 90 days and rely on the existingCLOCK_SKEW_TOLERANCE = 60 * 1000(already imported intovalidation.ts) for the buffer. Theheader.tsxquery already subtracts a separate60_000margin, so it would continue to work.Option 1 is the smaller change and keeps the existing buffer semantics. The pre-existing 30/31 split shows the pattern was already in the codebase, but the larger number makes it more noticeable now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 8de383e — all user-facing validation error messages now hardcode "90 days" instead of interpolating
MAX_DAYS_AGO / 86_400_000(which yielded 91). This applies tovalidation.ts,get-team-metrics.ts,get-team-metrics-max.ts,schemas.ts, andtypes.ts.MAX_DAYS_AGOstays at 91 days as an internal buffer so the "Last 90 days" preset never hits the validation boundary.