Skip to content
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

fix: unify datetime components #2876

Merged
merged 6 commits into from
Feb 6, 2025
Merged

fix: unify datetime components #2876

merged 6 commits into from
Feb 6, 2025

Conversation

ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Feb 6, 2025

What does this PR do?

  • Fixes ratelimit logs ai prompt
  • Adds a future limit for date time components (future dates no longer can be selected)
  • Move datetime components into a single structure with minimal boilerplate code
  • Fixes UI shifts when loading date from query params. (Now it says "Loading" until selected suggestion is certain)
  • Adds max-width to prevent overflow in tables both for ratelimit logs and logs
  • Uses same relativeTimeParse logic across app

Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • New Features

    • Enhanced date and time selection with improved keyboard navigation and dynamic loading indicators.
    • Calendar now restricts date selection to current and past dates.
  • Style

    • Refined log tables and identifier displays with enforced width constraints for a cleaner layout.
    • Updated UI labels for clarity, including revised wording for request statuses.
  • Refactor

    • Streamlined time filtering logic now supports week-based intervals.
    • Centralized configuration of time duration options for a more consistent user experience.

Copy link

changeset-bot bot commented Feb 6, 2025

⚠️ No Changeset found

Latest commit: c357aa4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard 🛑 Canceled (Inspect) Feb 6, 2025 6:16pm
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 6:16pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 6:16pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 6:16pm

Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Warning

Rate limit exceeded

@ogzhanolguncu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 8 seconds before requesting another review.

⌛ 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 14bc9df and c357aa4.

📒 Files selected for processing (1)
  • apps/dashboard/components/logs/datetime/datetime-popover.tsx (4 hunks)
📝 Walkthrough

Walkthrough

This pull request removes legacy date-time selection components and consolidates date-time functionality. The DatetimePopover and DateTimeSuggestions components have been removed from logs and ratelimits, while the LogsDateTime components are updated to integrate with a new filters hook and improved state management. Additionally, a centralized constants file is introduced to manage time options, and minor UI tweaks (e.g., width constraints in tables and updated button labels) have been applied. Utility functions for relative time parsing are enhanced, and a Calendar component now disables future dates.

Changes

File(s) Change Summary
apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/components/datetime-popover.tsx,
apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/components/suggestions.tsx,
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/components/suggestions.tsx
Removed legacy components: DatetimePopover, PopoverHeader, and DateTimeSuggestions along with associated types and interfaces.
apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx,
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx
Updated LogsDateTime components: state management revised (title now initialized as null with a fallback to "Last 12 hours"), integration with useFilters, and adjustments to props passed to the popover.
apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/utils/process-time.ts Removed the time processing utility and its associated type (TimeUnit) and function (processTimeFilters).
apps/dashboard/app/(app)/logs/hooks/use-filters.ts,
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/hooks/use-filters.ts
Updated filter hooks: added import for getTimestampFromRelative and revised the parseAsRelativeTime parser by removing regex validation in favor of the utility function.
apps/dashboard/app/(app)/logs/components/table/logs-table.tsx,
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx
Modified rendering: added CSS classes (max-w-[500px] and max-w-40) to constrain width for log entries and identifiers.
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-search/index.tsx Changed button label from "Show rejected requests from today" to "Show blocked requests from today".
apps/dashboard/components/logs/datetime/constants.ts Introduced a new constants file exporting OPTIONS and CUSTOM_OPTION_ID to centralize date-time options.
apps/dashboard/components/logs/datetime/datetime-popover.tsx Refactored popover: removed hardcoded options and updated import structure to use centralized constants (OPTIONS, CUSTOM_OPTION_ID).
apps/dashboard/components/logs/datetime/suggestions.tsx Added a new DateTimeSuggestions component implementing keyboard navigation, focus management, and dynamic scrolling for time range selection.
apps/dashboard/lib/trpc/routers/ratelimit/llm-search/utils.ts Updated status terminology in error messages and examples from "rejected/succeeded" to "blocked/passed".
apps/dashboard/lib/utils.ts Enhanced getTimestampFromRelative: updated regex to accept week units (w) and added corresponding case logic.
internal/ui/src/components/date-time/components/calendar.tsx Added a disabled prop to the DayPicker (for both range and single modes) to disable selection of future dates.

Possibly related PRs

  • fix: ratelimit date input and time display logs #2717: The changes in the main PR, which involve the removal of the DatetimePopover component and related date-time selection functionality, are related to the modifications in the retrieved PR that refactor the date-time inputs and enhance the user interface for selecting date ranges, particularly through the new DateTimePicker component.

Suggested labels

Improvement, Bug, Needs Approval

Suggested reviewers

  • mcstepp
  • chronark
  • perkinsjr

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (3)
apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx (1)

1-89: Consider unifying LogsDateTime components.

This component is nearly identical to the one in ratelimits. Consider creating a shared component to reduce duplication.

Create a new shared component:

// components/shared/logs-datetime.tsx
interface LogsDateTimeProps {
  namespace?: string;
}

export const LogsDateTime = ({ namespace }: LogsDateTimeProps) => {
  // ... shared implementation
};
apps/dashboard/components/logs/datetime/datetime-popover.tsx (2)

48-56: Add cleanup to prevent memory leaks.

The useEffect hook should clean up when the component unmounts.

 useEffect(() => {
+  let mounted = true;
   const newTitle = since
     ? OPTIONS.find((s) => s.value === since)?.display ?? initialTitle
     : startTime
       ? "Custom"
       : initialTitle;

-  onSuggestionChange(newTitle);
+  if (mounted) {
+    onSuggestionChange(newTitle);
+  }
+  return () => {
+    mounted = false;
+  };
 }, [since, startTime, initialTitle, onSuggestionChange]);

30-31: Add cleanup for keyboard shortcut.

The keyboard shortcut should be cleaned up when the component unmounts.

 const [open, setOpen] = useState(false);
-useKeyboardShortcut("t", () => setOpen((prev) => !prev));
+useEffect(() => {
+  const cleanup = useKeyboardShortcut("t", () => setOpen((prev) => !prev));
+  return cleanup;
+}, []);
🧹 Nitpick comments (9)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx (1)

122-123: Consider making the identifier column more responsive.

The fixed width percentage (15%) combined with max-w-40 might cause layout issues on different screen sizes. Consider using responsive classes to adjust the max-width based on screen size.

-        width: "15%",
-        render: (log) => <div className="font-mono truncate mr-1 max-w-40">{log.identifier}</div>,
+        width: "auto",
+        render: (log) => <div className="font-mono truncate mr-1 max-w-32 sm:max-w-40 md:max-w-56">{log.identifier}</div>,
internal/ui/src/components/date-time/components/calendar.tsx (2)

90-133: Add more inline documentation for complex date handling logic.

While the logic is thorough and handles edge cases well, it would benefit from additional inline documentation explaining the various scenarios, especially in the handleChange function.

Consider adding more detailed comments like this:

 const handleChange = (newDate: DateRange | undefined) => {
-  //  No date selected (user cleared the selection)
+  // Case 1: No date selected (user cleared the selection)
+  // This happens when the user clicks the clear button or deselects all dates
   if (!newDate) {
     onDateChange({ from: undefined, to: undefined });
     return;
   }

-  //  End date was moved later than current end date
-  // This resets the "from" date while keeping the new "to" date
+  // Case 2: End date was moved later than current end date
+  // This resets the "from" date while keeping the new "to" date
+  // Example: Current range is Jan 1-5, user selects Jan 10
+  // Result: Range becomes undefined-Jan 10
   if (
     date?.from &&
     date?.to &&
     newDate?.to instanceof Date &&
     newDate.to.getTime() > date.to.getTime()
   ) {
     onDateChange({ from: undefined, to: newDate.to });
     return;
   }

135-169: Refactor to avoid duplicating the disabled prop.

The disabled prop is duplicated in both range and single modes. Consider moving it to commonProps to maintain DRY principles.

 const commonProps = {
-  disabled: minDateRange && { before: minDateRange, after: maxDateRange },
+  disabled: (date) => {
+    // First check the date range constraints
+    if (minDateRange && (date < minDateRange || date > maxDateRange)) {
+      return true;
+    }
+    // Then check for future dates
+    return date > new Date();
+  },
   showOutsideDays,
   className: cn("", className),
   classNames: {
     ...styleClassNames,
     ...classNames,
   },
   components: {
     Caption: CustomCaptionComponent,
   },
   ...props,
 };

Then remove the duplicate disabled props:

 <DayPicker
   {...commonProps}
   mode="range"
   selected={date}
-  disabled={(date) => date > new Date()}
   onSelect={(date: DateRange | undefined) => (date ? handleChange(date) : undefined)}
 />

 <DayPicker
   {...commonProps}
   mode="single"
   selected={singleDay}
-  disabled={(date) => date > new Date()}
   onSelect={(date: Date | undefined) => handleSingleChange(date)}
 />
apps/dashboard/components/logs/datetime/constants.ts (1)

3-100: Consider adding type validation for time unit values.

The time unit values use inconsistent formats (m, h, d, w). Consider adding validation or using an enum to ensure consistency.

+export type TimeUnitValue = "1m" | "5m" | "15m" | "30m" | "1h" | "3h" | "6h" | "12h" | "24h" | "2d" | "3d" | "1w" | "2w" | "3w" | "4w";

 export const OPTIONS: OptionsType = [
   {
     id: 1,
-    value: "1m",
+    value: "1m" as TimeUnitValue,
     display: "Last minute",
     checked: false,
   },
   // ... apply to all options
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx (2)

12-16: Consider using a default value instead of useEffect.

The current implementation might cause a brief flicker showing "Loading...". Consider setting the default value directly in useState.

-const [title, setTitle] = useState<string | null>(null);
+const [title, setTitle] = useState<string>("Last 12 hours");

-useEffect(() => {
-  if (!title) {
-    setTitle("Last 12 hours");
-  }
-}, [title]);

18-27: Extract filter field names to constants.

The hardcoded filter field names could lead to maintenance issues if they need to change.

+const TIME_FILTER_FIELDS = ["startTime", "endTime", "since"] as const;

 const timeValues = filters
-  .filter((f) => ["startTime", "endTime", "since"].includes(f.field))
+  .filter((f) => TIME_FILTER_FIELDS.includes(f.field))
   .reduce(
     (acc, f) => ({
       ...acc,
       [f.field]: f.value,
     }),
     {},
   );
apps/dashboard/lib/utils.ts (1)

133-158: LGTM! Consider adding JSDoc documentation.

The addition of the week unit and its implementation is correct. The regex pattern and error message have been properly updated to reflect this change.

Consider adding JSDoc documentation to clarify the supported time units and provide examples:

+/**
+ * Converts a relative time string to a timestamp
+ * @param relativeTime - A string in the format "number[whdm]" where:
+ *   w = weeks, h = hours, d = days, m = minutes
+ * @example
+ *   "1w" // 1 week ago
+ *   "1w2d" // 1 week and 2 days ago
+ *   "24h" // 24 hours ago
+ * @returns timestamp in milliseconds
+ */
 export const getTimestampFromRelative = (relativeTime: string): number => {
apps/dashboard/lib/trpc/routers/ratelimit/llm-search/utils.ts (1)

237-246: Consider adding more error handling examples.

The error handling examples could be more comprehensive to cover additional edge cases and help the model better understand how to handle ambiguous queries.

Consider adding examples for:

  1. Multiple ambiguous status terms in one query
  2. Invalid time formats
  3. Malformed request IDs

Would you like me to generate additional error handling examples?

apps/dashboard/components/logs/datetime/suggestions.tsx (1)

44-70: Enhance keyboard navigation accessibility.

While the keyboard navigation is comprehensive, consider adding the following improvements:

  • Support for Home and End keys to jump to the first/last options.
  • Support for PageUp and PageDown for faster navigation.

Here's how you can enhance the keyboard navigation:

 const handleKeyDown = (e: KeyboardEvent, index: number) => {
   switch (e.key) {
+    case "Home": {
+      e.preventDefault();
+      itemRefs.current[0]?.focus();
+      setFocusedIndex(0);
+      scrollIntoView(0);
+      break;
+    }
+    case "End": {
+      e.preventDefault();
+      const lastIndex = options.length - 1;
+      itemRefs.current[lastIndex]?.focus();
+      setFocusedIndex(lastIndex);
+      scrollIntoView(lastIndex);
+      break;
+    }
+    case "PageUp": {
+      e.preventDefault();
+      const newIndex = Math.max(0, index - 5);
+      itemRefs.current[newIndex]?.focus();
+      setFocusedIndex(newIndex);
+      scrollIntoView(newIndex);
+      break;
+    }
+    case "PageDown": {
+      e.preventDefault();
+      const newIndex = Math.min(options.length - 1, index + 5);
+      itemRefs.current[newIndex]?.focus();
+      setFocusedIndex(newIndex);
+      scrollIntoView(newIndex);
+      break;
+    }
     // ... existing cases
   }
 };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b7d228 and d439e11.

📒 Files selected for processing (18)
  • apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/components/datetime-popover.tsx (0 hunks)
  • apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/components/suggestions.tsx (0 hunks)
  • apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/utils/process-time.ts (0 hunks)
  • apps/dashboard/app/(app)/logs/components/table/logs-table.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs/hooks/use-filters.ts (2 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/index.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/components/suggestions.tsx (0 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx (2 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-search/index.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx (1 hunks)
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/hooks/use-filters.ts (2 hunks)
  • apps/dashboard/components/logs/datetime/constants.ts (1 hunks)
  • apps/dashboard/components/logs/datetime/datetime-popover.tsx (2 hunks)
  • apps/dashboard/components/logs/datetime/suggestions.tsx (1 hunks)
  • apps/dashboard/lib/trpc/routers/ratelimit/llm-search/utils.ts (8 hunks)
  • apps/dashboard/lib/utils.ts (1 hunks)
  • internal/ui/src/components/date-time/components/calendar.tsx (3 hunks)
💤 Files with no reviewable changes (4)
  • apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/utils/process-time.ts
  • apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/components/suggestions.tsx
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/components/suggestions.tsx
  • apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/components/datetime-popover.tsx
✅ Files skipped from review due to trivial changes (2)
  • apps/dashboard/app/(app)/logs/components/table/logs-table.tsx
  • apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-search/index.tsx
🧰 Additional context used
📓 Learnings (1)
apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx (1)
Learnt from: ogzhanolguncu
PR: unkeyed/unkey#2825
File: apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-datetime/index.tsx:0-0
Timestamp: 2025-01-30T20:38:00.058Z
Learning: In the logs dashboard, keyboard shortcuts that toggle UI elements (like popovers) should be implemented in the component that owns the state being toggled, not in the presentational wrapper components. For example, the 'T' shortcut for toggling the datetime filter is implemented in DatetimePopover, not in LogsDateTime.
🪛 Biome (1.9.4)
apps/dashboard/components/logs/datetime/suggestions.tsx

[error] 86-87: The elements with the following roles can be changed to the following elements:

For examples and more information, see WAI-ARIA Roles

(lint/a11y/useSemanticElements)

⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: Test Packages / Test ./packages/rbac
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx (1)

123-123: LGTM! Good UI improvement.

Adding max-w-40 class to constrain the identifier's width prevents text overflow and improves table readability.

internal/ui/src/components/date-time/components/calendar.tsx (2)

4-5: LGTM! Properly documented linting override.

The biome-ignore comment is well-documented and follows the correct format.


73-89: LGTM! Well-structured component with proper type definitions.

The Calendar component is well-implemented with:

  • Clear prop types
  • Proper context usage
  • Good state management
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/hooks/use-filters.ts (1)

1-1: LGTM! Good refactoring to centralize validation logic.

The changes improve code maintainability by reusing the centralized validation logic from getTimestampFromRelative.

Also applies to: 19-24

apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/index.tsx (1)

59-59: LGTM! Good defensive programming.

The addition of optional chaining prevents potential runtime errors when accessing originalTimestamp.

apps/dashboard/app/(app)/logs/hooks/use-filters.ts (1)

1-1: LGTM! Consistent with ratelimits implementation.

The changes maintain consistency in relative time validation across the application.

Also applies to: 21-24

apps/dashboard/lib/trpc/routers/ratelimit/llm-search/utils.ts (3)

44-44: LGTM! Clear and consistent error message examples.

The error message examples have been updated to use the new "blocked/passed" terminology, providing clear guidance to users.

Also applies to: 48-48


84-84: LGTM! Clear status field constraints and system role description.

The status field constraints and system role description have been updated to consistently use "blocked/passed" terminology.

Also applies to: 91-91


20-20: Verify the OpenAI model name.

The model name "gpt-4o-mini" appears to be incorrect. OpenAI's model names typically don't include the 'o' character.

-      model: "gpt-4o-mini",
+      model: "gpt-4",  // or another valid OpenAI model that supports structured outputs
apps/dashboard/components/logs/datetime/suggestions.tsx (1)

1-20: LGTM! Well-structured component setup.

The component's props interface and state management are well-defined, with proper TypeScript types and appropriate use of refs for DOM manipulation.

Copy link

pullflow-com bot commented Feb 6, 2025

From Oguzhan Olguncu@perkinsjr This also includes fix for ratelimit prompt

Copy link
Collaborator

Oh awesome! I was just about to take a look...

Copy link

pullflow-com bot commented Feb 6, 2025

From Oguzhan Olguncu ‣ Give it another try.I haven't tested it thorough. Issues was it was trying use rejected and succeded as a status

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
apps/dashboard/components/logs/datetime/constants.ts (1)

96-96: ⚠️ Potential issue

Add null check for CUSTOM_OPTION_ID.

The find operation could return undefined, potentially causing runtime issues.

-export const CUSTOM_OPTION_ID = OPTIONS.find((o) => o.value === undefined)?.id;
+export const CUSTOM_OPTION_ID = OPTIONS.find((o) => o.value === undefined)?.id ?? 16;
🧹 Nitpick comments (1)
apps/dashboard/components/logs/datetime/constants.ts (1)

3-94: Consider improvements to the OPTIONS array structure.

A few suggestions to enhance maintainability and flexibility:

  1. Consider making time ranges configurable through environment variables or a configuration file.
  2. Use meaningful constants for IDs instead of sequential numbers to make reordering safer.
  3. Add validation for the time range format to ensure consistency.
  4. Consider setting a default selected option.

Example refactor for using constants for IDs:

+export const TimeRangeIds = {
+  ONE_MINUTE: 'one_minute',
+  FIVE_MINUTES: 'five_minutes',
+  // ... other constants
+  CUSTOM: 'custom'
+} as const;

 export const OPTIONS: OptionsType = [
   {
-    id: 1,
+    id: TimeRangeIds.ONE_MINUTE,
     value: "1m",
     display: "Last minute",
     checked: false,
   },
   // ... other options
 ];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d439e11 and 14bc9df.

📒 Files selected for processing (1)
  • apps/dashboard/components/logs/datetime/constants.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Test Packages / Test ./packages/nextjs
  • GitHub Check: Test Packages / Test ./packages/hono
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./packages/api
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Test Packages / Test ./internal/resend
  • GitHub Check: Test Packages / Test ./internal/keys
  • GitHub Check: Test Packages / Test ./internal/id
  • GitHub Check: Test Packages / Test ./internal/hash
  • GitHub Check: Test Packages / Test ./internal/encryption
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Build / Build
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/dashboard/components/logs/datetime/constants.ts (1)

1-2: LGTM!

Good use of TypeScript types for better type safety and code maintainability.

Copy link

pullflow-com bot commented Feb 6, 2025

From Oguzhan Olguncu ‣ It's now blocked or passed

@perkinsjr perkinsjr added this pull request to the merge queue Feb 6, 2025
Merged via the queue into main with commit 30f17bd Feb 6, 2025
28 checks passed
@perkinsjr perkinsjr deleted the unify-datetime-components branch February 6, 2025 18:38
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