Skip to content

refactor: replace date-fns with safe date formatting functions across…#1053

Open
jsbroks wants to merge 3 commits intomainfrom
jbrooks/fix-datetime
Open

refactor: replace date-fns with safe date formatting functions across…#1053
jsbroks wants to merge 3 commits intomainfrom
jbrooks/fix-datetime

Conversation

@jsbroks
Copy link
Copy Markdown
Member

@jsbroks jsbroks commented Apr 23, 2026

… deployment components

Copilot AI review requested due to automatic review settings April 23, 2026 18:28
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@jsbroks has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 14 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 22 minutes and 14 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4175be62-ac3f-4f82-a40c-cc4d17dc535a

📥 Commits

Reviewing files that changed from the base of the PR and between ee4f0c8 and 75f8d3d.

📒 Files selected for processing (14)
  • apps/web/app/lib/date.ts
  • apps/web/app/routes/ws/deployments/_components/environmentversiondecisions/rule-results/DeploymentWindowDetail.tsx
  • apps/web/app/routes/ws/deployments/_components/environmentversiondecisions/rule-results/EnvironmentProgressionDetail.tsx
  • apps/web/app/routes/ws/deployments/_components/environmentversiondecisions/rule-results/GradRolloutDetail.tsx
  • apps/web/app/routes/ws/deployments/_components/environmentversiondecisions/rule-results/VersionCooldownDetail.tsx
  • apps/web/app/routes/ws/deployments/_components/release-targets/VerificationMetricStatus.tsx
  • apps/web/app/routes/ws/deployments/_components/release-targets/argocd/ArgoCD.tsx
  • apps/web/app/routes/ws/deployments/_components/release-targets/datadog/Datadog.tsx
  • apps/web/app/routes/ws/deployments/_components/release-targets/prometheus/Prometheus.tsx
  • apps/web/app/routes/ws/deployments/page.$deploymentId.release-targets.$releaseTargetKey.tsx
  • apps/web/app/routes/ws/resource-aggregates.tsx
  • apps/web/app/routes/ws/settings/work-queue.tsx
  • apps/web/app/routes/ws/workflows/_components/WorkflowRunsTable.tsx
  • apps/web/app/routes/ws/workflows/page.$workflowId.runs.$runId.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jbrooks/fix-datetime

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors deployment-related web UI components to use centralized “safe” date formatting utilities, preventing crashes when timestamps are null/invalid.

Changes:

  • Added apps/web/app/lib/date.ts with safe wrappers around date-fns formatting/comparison helpers.
  • Replaced direct date-fns usage with safeFormatDistance* helpers in several deployment components, adding UI fallbacks for null results.
  • Removed a duplicated local safe date helper in EnvironmentProgressionDetail in favor of the shared utilities.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apps/web/app/routes/ws/deployments/page.$deploymentId.release-targets.$releaseTargetKey.tsx Uses safeFormatDistanceToNow with fallbacks for evaluation timestamps.
apps/web/app/routes/ws/deployments/_components/release-targets/prometheus/Prometheus.tsx Uses safe strict “time ago” formatting and renders placeholder on null.
apps/web/app/routes/ws/deployments/_components/release-targets/datadog/Datadog.tsx Uses safe strict “time ago” formatting and renders placeholder on null.
apps/web/app/routes/ws/deployments/_components/release-targets/argocd/ArgoCD.tsx Uses safe strict formatting for “Last Synced” with "unknown" fallback.
apps/web/app/routes/ws/deployments/_components/release-targets/VerificationMetricStatus.tsx Switches to safe strict formatter for latest measurement timestamp.
apps/web/app/routes/ws/deployments/_components/environmentversiondecisions/rule-results/EnvironmentProgressionDetail.tsx Removes inline safe helper and imports shared safe formatter.
apps/web/app/routes/ws/deployments/_components/environmentversiondecisions/rule-results/DeploymentWindowDetail.tsx Replaces some date-fns calls with safe helpers, but leaves broken references (see comments).
apps/web/app/lib/date.ts Introduces shared safe date helpers wrapping date-fns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +17
import {
safeFormatDistanceStrict,
safeFormatDistanceToNowStrict,
safeIsPast,
} from "~/lib/date";
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file still references isPast and formatDistanceToNowStrict later in WindowRow (e.g. checks for ended/next window), but those date-fns imports were removed and the safe replacements are imported instead. This will cause a TypeScript compile error (unresolved identifiers) and also defeats the goal of using safe formatters. Update the remaining usages to safeIsPast / safeFormatDistanceToNowStrict (and handle null returns) or reintroduce the needed imports consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +252 to +262
{evaluation.satisfiedAt != null &&
safeFormatDistanceToNow(evaluation.satisfiedAt, {
addSuffix: true,
}) != null && (
<span>
Satisfied{" "}
{safeFormatDistanceToNow(evaluation.satisfiedAt, {
addSuffix: true,
})}
</span>
)}
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safeFormatDistanceToNow(evaluation.satisfiedAt, { addSuffix: true }) is computed twice (once in the conditional and again for rendering). Consider computing it once into a local variable and reusing it to avoid duplicate parsing/formatting and ensure the displayed value matches the conditional check.

Suggested change
{evaluation.satisfiedAt != null &&
safeFormatDistanceToNow(evaluation.satisfiedAt, {
addSuffix: true,
}) != null && (
<span>
Satisfied{" "}
{safeFormatDistanceToNow(evaluation.satisfiedAt, {
addSuffix: true,
})}
</span>
)}
{(() => {
const satisfiedAtDistance =
evaluation.satisfiedAt == null
? null
: safeFormatDistanceToNow(evaluation.satisfiedAt, {
addSuffix: true,
});
return (
satisfiedAtDistance != null && (
<span>
Satisfied {satisfiedAtDistance}
</span>
)
);
})()}

Copilot uses AI. Check for mistakes.
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.

2 participants