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

feat: logs v2 selective display #2820

Merged
merged 14 commits into from
Jan 17, 2025
Merged

Conversation

ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Jan 15, 2025

What does this PR do?

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

Release Notes: Logs Dashboard Improvements

  • New Features

    • Added keyboard shortcuts for enhanced navigation in logs interface.
    • Introduced a new Display component for configuring log view options.
    • Implemented context-based log management for improved state handling.
  • Enhancements

    • Refined keyboard navigation across log filters and search functionality.
    • Updated status filter display with more user-friendly representations.
    • Improved error handling in search and filter interactions.
  • UI/UX Updates

    • Adjusted styling for checkboxes, labels, and filter controls.
    • Enhanced log table with additional column options.
    • Streamlined log details panel interaction.
    • Modified tooltip format in charts to simplify timestamp display.
  • Performance

    • Optimized keyboard shortcut handling.
    • Improved filter and search query management.

Copy link

changeset-bot bot commented Jan 15, 2025

⚠️ No Changeset found

Latest commit: 851c1f3

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 Jan 15, 2025

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

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 5 resolved Jan 17, 2025 0:18am
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 0:18am
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 0:18am
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 0:18am

Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

📝 Walkthrough

Walkthrough

This pull request introduces significant enhancements to the logs dashboard in the logs-v2 component. The changes focus on improving user interaction, keyboard navigation, and state management across multiple components. Key modifications include adding a new LogsContext for managing log selections, introducing keyboard shortcuts for filters and displays, refactoring component structures to use context-based state management, and updating the styling of various UI elements. The changes aim to create a more intuitive and flexible logging interface with improved navigation and filter capabilities.

Changes

File Change Summary
apps/dashboard/app/(app)/logs-v2/context/logs.tsx Added new LogsContext, LogsProvider, and useLogsContext for centralized log state management.
apps/dashboard/app/(app)/logs-v2/components/logs-client.tsx Removed selectedLog state, integrated LogsProvider.
apps/dashboard/app/(app)/logs-v2/components/table/log-details/index.tsx Updated to use context for log selection instead of props.
apps/dashboard/app/(app)/logs-v2/components/table/logs-table.tsx Refactored to use logs context, added WarningIcon, enhanced column definitions.
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/index.tsx Added new LogsDisplay component.
apps/dashboard/app/(app)/logs-v2/components/controls/index.tsx Integrated LogsDisplay component.
Multiple filter components Updated styling for checkboxes, gaps, and layout.
apps/dashboard/app/(app)/logs-v2/components/control-cloud/index.tsx Added keyboard shortcut functionality and modified status message formatting.
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/filter-checkbox.tsx Adjusted checkbox and label styling.
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/status-filter.tsx Introduced display property in StatusOption type.
apps/dashboard/app/(app)/logs-v2/hooks/use-keyboard-shortcut.tsx Enhanced keyboard shortcut handling to ignore unwanted modifiers.
apps/dashboard/app/(app)/logs-v2/filters.schema.ts Added transformStructuredOutputToFilters function for filter processing.

Possibly related PRs

Suggested Labels

Feature, Dashboard, 🕹️ oss.gg, :joystick: 300 points

Suggested Reviewers

  • mcstepp
  • perkinsjr
  • chronark

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 Jan 15, 2025

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

Copy link

pullflow-com bot commented Jan 15, 2025

From Oguzhan Olguncu@chronark this includes feedback changes too, fyi.

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 (4)
apps/dashboard/lib/trpc/routers/logs/llm-search.ts (1)

Line range hint 24-26: Verify the model identifier.

The model identifier gpt-4o-2024-08-06 appears to be incorrect. OpenAI's model naming typically doesn't include an 'o'.

-      model: "gpt-4o-2024-08-06",
+      model: "gpt-4-0125-preview",
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/filter-checkbox.tsx (2)

Line range hint 72-84: Consider using native HTML checkbox elements for better accessibility.

The current implementation uses a label with a custom role="checkbox". While it works, using native <input type="checkbox"> elements would provide better accessibility support out of the box.

-    <label
-      className="flex items-center gap-[18px] cursor-pointer"
-      role="checkbox"
-      aria-checked={checkboxes.every((checkbox) => checkbox.checked)}
-      onKeyDown={handleKeyDown}
-    >
+    <label className="flex items-center gap-[18px] cursor-pointer">
+      <input
+        type="checkbox"
+        className="hidden"
+        checked={checkboxes.every((checkbox) => checkbox.checked)}
+        onChange={handleSelectAll}
+        onKeyDown={handleKeyDown}
+      />
🧰 Tools
🪛 Biome (1.9.4)

[error] 92-94: 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)


Line range hint 92-103: Apply consistent accessibility improvements to individual checkboxes.

Similar to the "Select All" checkbox, individual checkboxes should also use native HTML elements.

-    <label
-      className="flex gap-[18px] items-center py-1 cursor-pointer"
-      role="checkbox"
-      aria-checked={checkbox.checked}
-      onKeyDown={(e) => handleKeyDown(e, index)}
-    >
+    <label className="flex gap-[18px] items-center py-1 cursor-pointer">
+      <input
+        type="checkbox"
+        className="hidden"
+        checked={checkbox.checked}
+        onChange={() => handleCheckboxChange(index)}
+        onKeyDown={(e) => handleKeyDown(e, index)}
+      />
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/paths-filter.tsx (1)

Line range hint 10-66: Remove duplicate path entries in options array.

The options array contains duplicate paths which could lead to confusion:

  • /v1/auth.login appears at id: 4 and id: 10
  • /v1/auth.logout appears at id: 5 and id: 11
  • /v1/auth.refreshToken appears at id: 6 and id: 12
  • /v1/data.delete appears at id: 7 and id: 13
  • /v1/data.fetch appears at id: 8 and id: 14
  • /v1/data.submit appears at id: 9 and id: 15

Remove the duplicate entries or ensure they are intentional. If these paths need to be differentiated, consider adding additional metadata to distinguish them.

🧰 Tools
🪛 Biome (1.9.4)

[error] 139-154: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)


[error] 139-145: The HTML element with the interactive role "checkbox" is not focusable.

A non-interactive HTML element that is not focusable may not be reachable for users that rely on keyboard navigation, even with an added role like "checkbox".
Add a tabIndex attribute to make this element focusable.

(lint/a11y/useFocusableInteractive)


[error] 140-142: 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)

♻️ Duplicate comments (1)
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/paths-filter.tsx (1)

140-154: 🛠️ Refactor suggestion

Apply consistent accessibility improvements from FilterCheckbox component.

The same accessibility concerns apply here. Use native HTML checkbox elements instead of custom roles.

🧰 Tools
🪛 Biome (1.9.4)

[error] 139-154: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)


[error] 140-142: 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)

🧹 Nitpick comments (15)
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/index.tsx (1)

10-16: Enhance keyboard interaction hint visibility.

The keyboard shortcut hint is only visible in the title attribute. Consider making it more discoverable by adding a visible keyboard shortcut indicator.

 <Button
   variant="ghost"
   className={cn("group-data-[state=open]:bg-gray-4 px-2")}
   aria-label="Filter logs"
   aria-haspopup="true"
   title="Press 'F' to toggle filters"
 >
   <Sliders className="text-accent-9 size-4" />
-  <span className="text-accent-12 font-medium text-[13px]">Display</span>
+  <span className="text-accent-12 font-medium text-[13px]">Display <kbd className="ml-1 text-[10px] text-accent-9">(F)</kbd></span>
 </Button>
apps/dashboard/components/virtual-table/types.ts (2)

1-8: Add JSDoc comments to improve type documentation.

The ColumnWidth type provides great flexibility, but could benefit from JSDoc comments explaining when to use each option.

+/**
+ * Defines the width configuration for a table column.
+ * @typedef {ColumnWidth}
+ */
 type ColumnWidth =
-  | number // Fixed pixel width
-  | string // CSS values like "165px", "15%", etc.
-  | "1fr" // Flex grow
-  | "min" // Minimum width based on content
-  | "auto" // Automatic width based on content
-  | { min: number; max: number } // Responsive range
-  | { flex: number }; // Flex grow ratio
+  | number /** Fixed pixel width */
+  | string /** CSS values like "165px", "15%", etc. */
+  | "1fr" /** Flex grow - column takes up remaining space */
+  | "min" /** Minimum width based on content */
+  | "auto" /** Automatic width based on content */
+  | { min: number; max: number } /** Responsive range between min and max pixels */
+  | { flex: number }; /** Flex grow ratio relative to other columns */

18-18: Consider adding type for noTruncate metadata.

The noTruncate property could benefit from additional metadata to control truncation behavior.

-  noTruncate?: boolean; // Add this to disable truncation for specific columns
+  truncation?: {
+    enabled: boolean;
+    maxLength?: number;
+    showTooltip?: boolean;
+  };
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/status-filter.tsx (2)

Line range hint 12-37: Extract status options configuration.

Consider moving the status options to a separate configuration file and expanding the ranges to cover all common HTTP status codes.

Create a new file status-options.config.ts:

export const HTTP_STATUS_RANGES = {
  SUCCESS: {
    range: [200, 299],
    display: "2xx",
    label: "Success",
    colorClass: "bg-success-9"
  },
  CLIENT_ERROR: {
    range: [400, 499],
    display: "4xx",
    label: "Warning",
    colorClass: "bg-warning-8"
  },
  SERVER_ERROR: {
    range: [500, 599],
    display: "5xx",
    label: "Error",
    colorClass: "bg-error-9"
  }
} as const;

export const createStatusOptions = () => 
  Object.entries(HTTP_STATUS_RANGES).map(([key, config], index) => ({
    id: index + 1,
    status: config.range[0],
    display: config.display,
    label: config.label,
    color: config.colorClass,
    checked: false
  }));

Line range hint 54-63: Simplify status color logic using the configuration.

The color logic in createFilterValue can be simplified by using the status ranges configuration.

 createFilterValue={(option) => ({
   value: option.status,
   metadata: {
-    colorClass:
-      option.status >= 500
-        ? "bg-error-9"
-        : option.status >= 400
-          ? "bg-warning-8"
-          : "bg-success-9",
+    colorClass: Object.values(HTTP_STATUS_RANGES).find(
+      ({range: [min, max]}) => option.status >= min && option.status <= max
+    )?.colorClass ?? "bg-accent-9"
   },
 })}
apps/dashboard/app/(app)/logs-v2/components/table/log-details/index.tsx (1)

35-37: Consider adding error handling for context-related errors.

While the implementation is correct, consider wrapping the component with an error boundary to gracefully handle potential context-related errors.

class LogDetailsErrorBoundary extends React.Component<{children: React.ReactNode}> {
  componentDidCatch(error: Error) {
    // Handle context errors gracefully
    console.error('Failed to load log details:', error);
  }
  
  render() {
    return this.props.children;
  }
}
apps/dashboard/app/(app)/logs-v2/context/logs.tsx (2)

26-32: Consider making default properties immutable.

To prevent accidental modifications, consider making the default properties array readonly.

-const DEFAULT_DISPLAY_PROPERTIES: DisplayProperty[] = [
+const DEFAULT_DISPLAY_PROPERTIES: readonly DisplayProperty[] = [

54-65: Consider memoizing the context value.

To prevent unnecessary re-renders of context consumers, consider memoizing the context value.

+import { useMemo } from 'react';

 export const LogsProvider = ({ children }: PropsWithChildren) => {
   const [selectedLog, setSelectedLog] = useState<Log | null>(null);
   const [displayProperties, setDisplayProperties] = useState<Set<DisplayProperty>>(
     new Set(DEFAULT_DISPLAY_PROPERTIES),
   );

+  const value = useMemo(
+    () => ({
+      selectedLog,
+      setSelectedLog,
+      displayProperties,
+      toggleDisplayProperty,
+    }),
+    [selectedLog, displayProperties]
+  );

   return (
-    <LogsContext.Provider
-      value={{
-        selectedLog,
-        setSelectedLog,
-        displayProperties,
-        toggleDisplayProperty,
-      }}
-    >
+    <LogsContext.Provider value={value}>
       {children}
     </LogsContext.Provider>
   );
 };
apps/dashboard/app/(app)/logs-v2/hooks/use-keyboard-shortcut.tsx (1)

36-46: Consider extracting modifier check logic.

The modifier check logic could be extracted into a separate function for better readability and reusability.

+const hasUnwantedModifiers = (combo: KeyCombo, event: KeyboardEvent): boolean => {
+  return (
+    (combo.ctrl === undefined && event.ctrlKey) ||
+    (combo.meta === undefined && event.metaKey) ||
+    (combo.shift === undefined && event.shiftKey) ||
+    (combo.alt === undefined && event.altKey)
+  );
+};

-const hasUnwantedModifiers =
-  (combo.ctrl === undefined && e.ctrlKey) ||
-  (combo.meta === undefined && e.metaKey) ||
-  (combo.shift === undefined && e.shiftKey) ||
-  (combo.alt === undefined && e.altKey);
+if (hasUnwantedModifiers(combo, e)) {
+  return;
+}
apps/dashboard/components/virtual-table/components/table-row.tsx (1)

65-65: Consider memoizing the grid template calculation.

The gridTemplateColumns calculation could be expensive for tables with many columns. Consider memoizing the result using useMemo to optimize performance.

-  const gridTemplateColumns = calculateGridTemplateColumns(columns);
+  const gridTemplateColumns = useMemo(
+    () => calculateGridTemplateColumns(columns),
+    [columns]
+  );

Also applies to: 109-113

apps/dashboard/app/(app)/logs-v2/filters.schema.ts (1)

57-102: Consider adding input validation for the status field.

While the function handles status conversion well, it should validate the numeric value before pushing to filters.

 if (filterGroup.field === "status") {
   const numericValue =
     typeof filter.value === "string" ? Number.parseInt(filter.value) : filter.value;
+  if (isNaN(numericValue) || numericValue < 100 || numericValue > 599) {
+    return; // Skip invalid status codes
+  }
   uniqueFilters.push({
     id: crypto.randomUUID(),
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/components/display-popover.tsx (2)

78-130: Consider memoizing keyboard navigation calculations.

The handleKeyNavigation function recalculates layout dimensions on every key press. Consider memoizing these calculations.

+  const itemsPerRow = useMemo(
+    () => Math.floor(384 / 120),
+    []
+  );
+
   const handleKeyNavigation = useCallback(
     (e: KeyboardEvent) => {
-      const itemsPerRow = Math.floor(384 / 120); // Approximate width / item width
       const totalItems = DISPLAY_PROPERTIES.length;

13-25: Consider moving DISPLAY_PROPERTIES to a separate constants file.

The display properties array could be reused across components. Consider moving it to a dedicated constants file.

apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/paths-filter.tsx (1)

Line range hint 89-98: Consider debouncing the scroll handler.

The scroll event handler could fire frequently during scrolling. Consider debouncing the handler for better performance.

import { debounce } from 'lodash';

// Inside component:
const debouncedHandleScroll = useCallback(
  debounce(() => {
    if (scrollContainerRef.current) {
      const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current;
      const isBottom = Math.abs(scrollHeight - clientHeight - scrollTop) < 1;
      setIsAtBottom(isBottom);
    }
  }, 100),
  []
);
🧰 Tools
🪛 Biome (1.9.4)

[error] 139-154: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)


[error] 139-145: The HTML element with the interactive role "checkbox" is not focusable.

A non-interactive HTML element that is not focusable may not be reachable for users that rely on keyboard navigation, even with an added role like "checkbox".
Add a tabIndex attribute to make this element focusable.

(lint/a11y/useFocusableInteractive)


[error] 140-142: 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)

apps/dashboard/app/(app)/logs-v2/components/table/logs-table.tsx (1)

100-118: Consider memoizing additional columns.

The additionalColumns array is recreated on every render. Consider moving it outside the component or memoizing it with useMemo to optimize performance.

-const additionalColumns: Column<Log>[] = [
+const additionalColumns: Column<Log>[] = useMemo(() => [
   // ... column definitions
-].map((key) => ({
+], []).map((key) => ({
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0fc7d1c and 9744826.

📒 Files selected for processing (18)
  • apps/dashboard/app/(app)/logs-v2/components/control-cloud/index.tsx (4 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/components/display-popover.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/index.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/filter-checkbox.tsx (3 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/filters-popover.tsx (8 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/paths-filter.tsx (2 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/status-filter.tsx (3 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-search/index.tsx (7 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/index.tsx (2 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/logs-client.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/table/log-details/index.tsx (2 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/table/logs-table.tsx (6 hunks)
  • apps/dashboard/app/(app)/logs-v2/context/logs.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs-v2/filters.schema.ts (2 hunks)
  • apps/dashboard/app/(app)/logs-v2/hooks/use-keyboard-shortcut.tsx (1 hunks)
  • apps/dashboard/components/virtual-table/components/table-row.tsx (3 hunks)
  • apps/dashboard/components/virtual-table/types.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/logs/llm-search.ts (1 hunks)
👮 Files not reviewed due to content moderation or server errors (1)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-search/index.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/components/display-popover.tsx

[error] 46-47: 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)

apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/filter-checkbox.tsx

[error] 72-74: 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)

apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/paths-filter.tsx

[error] 140-142: 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)


[error] 163-165: 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: Build / Build
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: Test API / API Test Local
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (16)
apps/dashboard/app/(app)/logs-v2/components/logs-client.tsx (1)

19-25: Great architectural improvement!

Moving to context-based state management with LogsProvider effectively eliminates prop drilling and centralizes log state management. This change improves code maintainability and component reusability.

apps/dashboard/app/(app)/logs-v2/components/controls/index.tsx (1)

1-2: LGTM! Clean replacement of static display control with dynamic component.

The changes effectively replace the static display control with the new LogsDisplay component, aligning with the PR's objective of implementing selective display functionality.

Also applies to: 32-33

apps/dashboard/app/(app)/logs-v2/components/table/log-details/index.tsx (1)

5-5: LGTM! Good migration to context-based state management.

The shift from prop-based to context-based state management reduces prop drilling and improves maintainability.

Also applies to: 27-28

apps/dashboard/app/(app)/logs-v2/context/logs.tsx (1)

6-17: LGTM! Well-defined type-safe display properties.

The DisplayProperty type ensures type safety for all possible display options.

apps/dashboard/app/(app)/logs-v2/hooks/use-keyboard-shortcut.tsx (1)

36-46: LGTM! Good enhancement to prevent unwanted shortcut triggers.

The addition of unwanted modifier detection prevents shortcuts from triggering when users accidentally press additional modifier keys.

apps/dashboard/components/virtual-table/components/table-row.tsx (1)

5-40: LGTM! Well-structured column width calculation logic.

The implementation handles various width specifications comprehensively and provides good fallbacks.

apps/dashboard/lib/trpc/routers/logs/llm-search.ts (1)

Line range hint 57-76: LGTM! Comprehensive error handling.

The error handling is robust, with specific error messages for different scenarios and proper error logging.

apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/paths-filter.tsx (1)

Line range hint 163-175: Apply consistent accessibility improvements to individual checkboxes.

The same accessibility improvements should be applied to individual checkboxes.

🧰 Tools
🪛 Biome (1.9.4)

[error] 161-168: The HTML element with the interactive role "checkbox" is not focusable.

A non-interactive HTML element that is not focusable may not be reachable for users that rely on keyboard navigation, even with an added role like "checkbox".
Add a tabIndex attribute to make this element focusable.

(lint/a11y/useFocusableInteractive)


[error] 163-165: 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)

apps/dashboard/app/(app)/logs-v2/components/control-cloud/index.tsx (3)

30-34: LGTM! Consistent status code formatting.

The status code formatting is now consistently using lowercase 'xx' suffix, which improves readability.


109-111: LGTM! Enhanced keyboard navigation.

The addition of the Command+C shortcut to focus filters improves accessibility and user experience.


213-222: LGTM! Improved layout structure.

The new layout with separate rows for "Clear filters" and "Focus filters" improves visual organization and makes keyboard shortcuts more discoverable.

apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/components/filters-popover.tsx (3)

23-23: LGTM! Improved keyboard shortcut.

Changed status filter shortcut from 's' to 'e' to avoid conflict with the search shortcut.


45-51: LGTM! Proper cleanup of filter state.

Added cleanup effect to prevent unnecessary renders when opening/closing the popover.


178-194: LGTM! Enhanced focus management.

The new focus management logic properly handles:

  1. Focus transfer to sub-popover
  2. First focusable element selection
  3. Fallback focus behavior
apps/dashboard/app/(app)/logs-v2/components/table/logs-table.tsx (2)

89-98: LGTM! Well-structured warning icon component.

The WarningIcon component effectively handles different status ranges and maintains consistent styling.


206-227: LGTM! Robust column visibility management.

The visibleColumns implementation effectively:

  1. Combines basic and additional columns
  2. Filters based on display properties
  3. Properly handles the warning icon integration

Copy link

pullflow-com bot commented Jan 16, 2025

From Oguzhan Olguncu@chronark give it a try

Copy link
Collaborator

after the gym

Copy link

pullflow-com bot commented Jan 16, 2025

From Oguzhan Olguncu ‣ Can we move comments to main branch and merge this first?

Copy link
Collaborator

sure

Copy link
Collaborator

if you figure out how to move them

Copy link

pullflow-com bot commented Jan 16, 2025

From Oguzhan Olguncu ‣ leave it then i'll fix it tomorrow and merge it. it's not that urgent

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: 1

🧹 Nitpick comments (5)
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-search/index.tsx (3)

Line range hint 13-48: Consider extracting toast configuration to constants.

The toast configuration (duration, position, style) is duplicated. Consider extracting these to shared constants to improve maintainability.

+const TOAST_CONFIG = {
+  duration: 8000,
+  important: true,
+  position: "top-right" as const,
+  style: {
+    whiteSpace: "pre-line",
+  },
+};

 const queryLLMForStructuredOutput = trpc.logs.llmSearch.useMutation({
   onSuccess(data) {
     if (data) {
       const transformedFilters = transformStructuredOutputToFilters(data, filters);
       updateFilters(transformedFilters);
     } else {
-      toast.error("Try to be more descriptive about your query", {
-        duration: 8000,
-        important: true,
-        position: "top-right",
-        style: {
-          whiteSpace: "pre-line",
-        },
-      });
+      toast.error("Try to be more descriptive about your query", TOAST_CONFIG);
     }
   },
   onError(error) {
-    toast.error(error.message, {
-      duration: 8000,
-      important: true,
-      position: "top-right",
-      style: {
-        whiteSpace: "pre-line",
-      },
-    });
+    toast.error(error.message, TOAST_CONFIG);
   },
 });

80-115: Consider extracting UI text to constants.

The loading message "AI consults the Palantír..." is hardcoded. Consider moving it to a constants file for better maintainability and potential internationalization.

+const UI_TEXT = {
+  LOADING_MESSAGE: "AI consults the Palantír...",
+  PLACEHOLDER: "Search and filter with AI…",
+};

 {isLoading ? (
   <div className="text-accent-11 text-sm animate-pulse">
-    AI consults the Palantír...
+    {UI_TEXT.LOADING_MESSAGE}
   </div>
 ) : (
   <input
     // ...
-    placeholder="Search and filter with AI…"
+    placeholder={UI_TEXT.PLACEHOLDER}
     // ...
   />
 )}

Line range hint 118-168: Consider increasing tooltip delay for better accessibility.

The current tooltip delay of 150ms might be too short for users who need more time to read or process the information. Consider increasing it to at least 300ms for better accessibility.

-<Tooltip delayDuration={150}>
+<Tooltip delayDuration={300}>
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/components/display-popover.tsx (2)

65-75: Add cleanup for keyboard shortcut and improve focus management.

Consider these improvements:

  1. Add cleanup for keyboard shortcut subscription
  2. Consider using useCallback for the toggle handler
  3. Add focus trap for better keyboard navigation
 useKeyboardShortcut("d", () => {
   setOpen((prev) => !prev);
   if (!open) {
     setFocusedIndex(0);
   }
-});
+}, [open]);

+// Add focus trap
+useEffect(() => {
+  if (!open) return;
+  
+  const handleTabKey = (e: KeyboardEvent) => {
+    if (e.key === 'Tab') {
+      e.preventDefault();
+    }
+  };
+  
+  document.addEventListener('keydown', handleTabKey);
+  return () => document.removeEventListener('keydown', handleTabKey);
+}, [open]);

79-80: Extract magic numbers into named constants.

The layout calculation uses magic numbers which could make maintenance difficult. Consider extracting these into named constants or calculating them dynamically based on the container width.

-const itemsPerRow = Math.floor(384 / 120); // Approximate width / item width
+const POPOVER_WIDTH = 384;
+const ITEM_WIDTH = 120;
+const itemsPerRow = Math.floor(POPOVER_WIDTH / ITEM_WIDTH);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9744826 and 851c1f3.

📒 Files selected for processing (6)
  • apps/dashboard/app/(app)/logs-v2/components/charts/index.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/control-cloud/index.tsx (4 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/components/display-popover.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/index.tsx (1 hunks)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-search/index.tsx (6 hunks)
  • apps/dashboard/app/(app)/logs-v2/context/logs.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-filters/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/app/(app)/logs-v2/context/logs.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/components/display-popover.tsx

[error] 45-46: 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 (15)
  • 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 API / API Test Local
  • GitHub Check: Test Packages / Test ./internal/billing
  • GitHub Check: Test Agent Local / test_agent_local
  • GitHub Check: Build / Build
  • GitHub Check: autofix
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-search/index.tsx (2)

1-12: LGTM! Well-organized imports and hooks setup.

The imports are logically grouped and the new additions support the enhanced filtering functionality.


71-76: LGTM! Clean preset query handling.

The handlePresetQuery function is well-implemented, following the single responsibility principle.

apps/dashboard/app/(app)/logs-v2/components/controls/components/logs-display/components/display-popover.tsx (4)

1-24: LGTM! Well-structured imports and constants.

The imports are well-organized, and the DISPLAY_PROPERTIES array provides a clear, maintainable way to define display properties.


26-56: Replace div with button element for better accessibility.

This is a duplicate of a previous review comment. The DisplayPropertyItem component should use a native button element instead of a div with role="button" for better accessibility.

🧰 Tools
🪛 Biome (1.9.4)

[error] 45-46: 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)


58-63: LGTM! Clean and focused header component.

The PopoverHeader component is well-structured with clear responsibility for displaying the title and keyboard shortcut.


118-125: Add error handling for invalid property access.

The property access at DISPLAY_PROPERTIES[focusedIndex] could potentially be undefined if focusedIndex is out of bounds. Consider adding error handling.

 if (focusedIndex !== null) {
+  if (focusedIndex >= DISPLAY_PROPERTIES.length) {
+    console.error('Invalid focus index');
+    return;
+  }
   const prop = DISPLAY_PROPERTIES[focusedIndex];
   if (isDisplayProperty(prop.id)) {
     toggleDisplayProperty(prop.id);
   }
 }
apps/dashboard/app/(app)/logs-v2/components/charts/index.tsx (1)

36-36: Verify if removing seconds from timestamp affects debugging capabilities.

While the simplified timestamp format improves readability, consider if second-level precision is important for debugging scenarios in the logs dashboard.

Let's check for timestamp format consistency across the codebase:

✅ Verification successful

Simplified timestamp format in chart tooltips is acceptable

The removal of seconds from chart tooltips doesn't impact debugging capabilities because:

  • Full timestamp precision (including seconds and milliseconds) is preserved in the log details view
  • Chart tooltips are for overview purposes, where second-level precision is less critical
  • Detailed timestamps are still available when needed for debugging
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for date formatting patterns to ensure consistency
rg -A 2 "format\([^,]+,\s*['\"].*(?:HH|hh|mm|ss|SS).*['\"]" --type ts

Length of output: 3354

apps/dashboard/app/(app)/logs-v2/components/control-cloud/index.tsx (3)

30-34: LGTM! Status code format change improves readability.

The change from uppercase (XX) to lowercase (xx) in status codes follows common conventions and improves readability.


199-199: LGTM! UI improvements enhance usability.

The changes improve the UI by:

  1. Better spacing with items-start alignment
  2. Clear visual hierarchy with divider
  3. Consistent keyboard shortcut indicators

Also applies to: 212-217


109-111: Consider potential conflict with browser shortcuts.

The Cmd+C (⌘+C) shortcut might conflict with the browser's copy functionality. Consider using a different key combination or implementing a check to prevent interference with native browser shortcuts.

Alternative implementation:

-  useKeyboardShortcut({ key: "c", meta: true }, () => {
+  useKeyboardShortcut({ key: "f", meta: true }, () => {
     setFocusedIndex(0);
   });

Copy link

pullflow-com bot commented Jan 17, 2025

From Oguzhan Olguncu@perkinsjr Can you skim over this when you are free? See how it looks give feedback on main branch. I'll rebase from this one and try to open PR for data fetching

Copy link
Collaborator

Sure I will do it now.

@ogzhanolguncu ogzhanolguncu added this pull request to the merge queue Jan 17, 2025
Merged via the queue into main with commit f8fa80a Jan 17, 2025
28 checks passed
@ogzhanolguncu ogzhanolguncu deleted the feat/logs-v2-selective-display branch January 17, 2025 14: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.

3 participants