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

Refactor: prelaunch UX/UI Changes #336

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

Bran18
Copy link
Contributor

@Bran18 Bran18 commented Jan 10, 2025

Summary by Sourcery

New Features:

  • Introduce a new onboarding experience for new users to guide them through the chatbot selection process.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added mobile onboarding views for chat routes.
    • Enhanced sidebar styling with dynamic route-based gradients.
    • Improved chatbot selection and interaction experience.
    • Introduced new components for displaying selected chatbots in mobile view.
  • UI/UX Changes

    • Simplified navigation links in header.
    • Removed font size selector from chat options.
    • Updated mobile chat views with more intuitive design.
    • Conditional rendering of search input based on available threads.
  • Performance & Environment

    • Added environment-specific model selection in chat combobox.
    • Refined route type detection.
  • Dependency Updates

    • Updated Radix UI Tooltip to version 1.1.6.

@Bran18 Bran18 self-assigned this Jan 10, 2025
Copy link

vercel bot commented Jan 10, 2025

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

Name Status Preview Comments Updated (UTC)
masterbots ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 11:28pm

Copy link

sourcery-ai bot commented Jan 10, 2025

Reviewer's Guide by Sourcery

This PR introduces several UX/UI improvements to the prelaunch experience, enhancing user onboarding and navigation. It simplifies the onboarding process on both desktop and mobile, improves UI elements in the sidebar, and streamlines the model selection process.

State diagram for sidebar and chat interface states

stateDiagram-v2
    [*] --> Welcome
    Welcome --> BotSelection: User clicks sidebar
    BotSelection --> ChatInterface: Bot selected
    ChatInterface --> ActiveChat: Start chat
    ActiveChat --> BotSelection: Change bot

    state ChatInterface {
        [*] --> ShowBotDetails
        ShowBotDetails --> ReadyToChat
        ReadyToChat --> [*]
    }

    state BotSelection {
        [*] --> PublicRoute
        [*] --> ChatRoute
        PublicRoute --> SelectBot
        ChatRoute --> SelectBot
    }
Loading

File-Level Changes

Change Details Files
Improved UI elements in the sidebar to enhance navigation and user experience.
  • Added route-based background gradients to the sidebar links.
  • Added a selected state for better visual feedback.
  • Improved styling for active and hover states.
apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx
apps/masterbots.ai/app/globals.css
Simplified onboarding experience on desktop and mobile devices.
  • Removed unnecessary elements from the onboarding view.
  • Added clearer instructions for new users.
  • Improved visual appeal of the onboarding screens.
  • Created separate mobile views for onboarding and selected bot states.
apps/masterbots.ai/components/routes/chat/onboarding-chatbot-details.tsx
apps/masterbots.ai/components/routes/chat/chat-chatbot-details.tsx
apps/masterbots.ai/components/routes/chat/chat-selected-chatbot-mobile.tsx
apps/masterbots.ai/components/routes/chat/chat-onboarding-chatbot-mobile.tsx
Streamlined model selection in non-production environments.
  • Simplified model selection to default Masterbot's model in production.
  • Full model selection is retained for development and local environments.
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx
Removed publicity switch and font size selector from chat options.
  • Removed the publicity switch from the thread popup.
  • Removed the font size selector from chat options.
apps/masterbots.ai/components/routes/chat/chat-options.tsx
apps/masterbots.ai/components/routes/thread/thread-popup.tsx
Improved prompt form interaction and bot selection.
  • Added a clickable overlay to prompt bot selection when no bot is selected.
  • Improved prompt form height and padding for better mobile responsiveness.
apps/masterbots.ai/components/routes/chat/prompt-form.tsx
Updated routing and navigation.
  • Added a getRouteType utility function to determine route types.
  • Updated sidebar styling based on route.
  • Updated header links.
  • Refactored navigation logic in the profile sidebar.
apps/masterbots.ai/components/layout/sidebar/profile-sidebar.tsx
apps/masterbots.ai/components/layout/header/header.tsx
apps/masterbots.ai/lib/utils.ts
apps/masterbots.ai/components/layout/sidebar/sidebar.tsx
Improved search input visibility.
  • Search input is now only visible when there are threads to search.
apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx
Updated tooltip styling and animation.
  • Updated tooltip styles for better visibility and animation.
apps/masterbots.ai/components/ui/tooltip.tsx
Upgraded Radix UI tooltip package.
  • Upgraded @radix-ui/react-tooltip to version 1.1.6.
apps/masterbots.ai/package.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/masterbots.ai/components/routes/browse/browse-chatbot-desktop-details.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/masterbots.ai/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

This pull request introduces comprehensive visual and functional enhancements to the Masterbots.ai application, focusing on route-specific styling, sidebar interactions, and mobile view improvements. The changes span multiple components, including CSS customization, header and sidebar modifications, and the introduction of new mobile view components for chat and onboarding experiences. The updates aim to improve user interface consistency, route-based styling, and mobile responsiveness.

Changes

File Change Summary
apps/masterbots.ai/app/globals.css Added new CSS custom properties for chat and public route gradients, enabling dynamic background styling for the sidebar.
apps/masterbots.ai/components/layout/header/header.tsx Simplified navigation links, removing "Ww" link and conditionally rendering "Pro" link.
apps/masterbots.ai/components/layout/sidebar/* Updated sidebar components with route-specific styling, improved readability, and added data-route attributes.
apps/masterbots.ai/components/routes/chat/* Introduced new mobile view components (OnboardingMobileView, SelectedBotMobileView), removed OnboardingMobileChatbotDetails, and updated chat-related components.
apps/masterbots.ai/lib/utils.ts Added getRouteType function to determine route types.
apps/masterbots.ai/package.json Updated @radix-ui/react-tooltip dependency version.

Possibly related PRs

Suggested labels

enhancement, feature

Suggested reviewers

  • AndlerRL

Poem

🐰 Hopping through routes with style and grace,
Gradients dancing at a playful pace
Sidebars shimmer, mobile views delight
CodeRabbit's magic makes everything bright!
A digital warren of UI might! 🌈✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 636891b and f3482ca.

📒 Files selected for processing (2)
  • apps/masterbots.ai/components/routes/browse/browse-chatbot-desktop-details.tsx (2 hunks)
  • apps/masterbots.ai/components/routes/browse/browse-chatbot-mobile-details.tsx (3 hunks)
🔇 Additional comments (3)
apps/masterbots.ai/components/routes/browse/browse-chatbot-mobile-details.tsx (2)

9-9: LGTM! Icon replacement is consistent

The replacement of BotMessageSquareIcon with MessageSquareIcon maintains consistency across components while using more semantic naming.

Also applies to: 46-46


68-68: LGTM! Class ordering follows convention

The reordering of classes (p-0 m-0 size-fullsize-full p-0 m-0) maintains the same visual outcome while following the project's className ordering convention.

apps/masterbots.ai/components/routes/browse/browse-chatbot-desktop-details.tsx (1)

6-6: LGTM! Consistent icon usage across components

The changes maintain consistency with the mobile version:

  1. Consolidated imports from lucide-react
  2. Consistent use of MessageSquareIcon for thread count display

Also applies to: 112-112


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

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Bran18 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider fixing the dependency arrays in useCallback/useEffect hooks instead of using biome-ignore comments. Missing dependencies could lead to stale closures and bugs.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

🧹 Nitpick comments (17)
apps/masterbots.ai/components/routes/chat/onboarding-chatbot-details.tsx (6)

8-12: Consider adding prop validation for required fields.

With the removal of default values, botName and other props are now required. Consider adding PropTypes or TypeScript type guards to ensure these required props are properly validated at runtime.


15-16: Remove commented code.

Remove the commented background styling code if it's no longer needed. If this is temporary, consider creating a task to address this later.


17-18: Extract magic number into a named constant.

The height calculation uses a magic number (196px). Consider extracting this into a named constant to improve maintainability and document its purpose.

+const HEADER_OFFSET = 196; // Document why this specific value is used
-<div className="hidden h-[calc(100vh-196px)] md:flex items-center justify-center -translate-y-8 relative">
+<div className={`hidden h-[calc(100vh-${HEADER_OFFSET}px)] md:flex items-center justify-center -translate-y-8 relative`}>

32-36: Simplify className concatenation.

Consider using a CSS module or creating a dedicated style constant for better maintainability.

+const avatarStyles = {
+  base: 'size-32 rounded-full relative',
+  background: 'bg-zinc-200 dark:bg-black',
+  ring: 'ring-4 ring-[#be16e8] dark:ring-[#82e46a]'
+};
-className={cn(
-  'size-32 rounded-full relative',
-  'bg-zinc-200 dark:bg-black',
-  'ring-4 ring-[#be16e8] dark:ring-[#82e46a]'
-)}
+className={cn(avatarStyles.base, avatarStyles.background, avatarStyles.ring)}

38-44: Add loading and error handling for the avatar image.

The Image component should handle loading states and potential errors gracefully.

<Image
  src={avatar}
  alt={`${botName} avatar`}
  height={128}
  width={128}
+ loading="eager"
+ onError={(e) => {
+   e.currentTarget.src = '/default-avatar.png'
+ }}
  className="object-cover rounded-full"
/>

51-54: Consider using CSS Grid for responsive layout.

The current approach uses complex width calculations. CSS Grid could provide a more maintainable solution for the layout.

-<p className="pt-2.5 max-w-[calc(100%-160px)] text-base text-zinc-500 dark:text-zinc-500 min-h-24">
+<div className="grid grid-cols-[1fr_160px] gap-4">
+  <p className="pt-2.5 text-base text-zinc-500 dark:text-zinc-500 min-h-24">
apps/masterbots.ai/components/routes/chat/chat-onboarding-chatbot-mobile.tsx (1)

7-7: Use CSS variables for theme colors.

Hard-coded colors like #be16e8 and #82e46a should be moved to CSS variables for better maintainability and theme consistency.

Consider using CSS variables like:

-<Card className="w-full bg-white dark:bg-[#09090B]">
+<Card className="w-full bg-card">
-<PanelLeft className="size-6 text-[#be16e8] dark:text-[#82e46a]" />
+<PanelLeft className="size-6 text-accent" />

Also applies to: 25-26

apps/masterbots.ai/components/layout/sidebar/sidebar.tsx (2)

19-26: Explain the useEffect dependency warning ignore.

The biome-ignore comment should include a proper explanation for why the exhaustive dependencies warning is being ignored.

Consider either:

  1. Adding the missing dependencies
  2. Explaining the reason in the ignore comment

36-39: Use CSS variables for route-specific styling.

The background colors are hardcoded, which makes theme maintenance difficult.

Consider using CSS variables:

-          isChatRoute 
-            ? 'bg-[#eeffea] dark:bg-[#081D02]' // For /c routes
-            : 'bg-[#fae8ff] dark:bg-[#17021D]'  // For other routes
+          isChatRoute 
+            ? 'bg-chat-gradient dark:bg-chat-gradient-dark'
+            : 'bg-public-gradient dark:bg-public-gradient-dark'
apps/masterbots.ai/components/routes/chat/chat-selected-chatbot-mobile.tsx (2)

45-51: Optimize image loading for better UX.

The Image component could benefit from additional optimization properties.

Consider adding priority and loading properties:

 <Image
   src={avatar}
   alt={`${botName} avatar`}
   height={64}
   width={64}
+  priority
+  loading="eager"
   className="object-cover rounded-full"
 />

38-43: Use CSS variables for consistent theming.

Similar to other components, the colors and dimensions should use CSS variables.

Consider using CSS variables:

-                    'ring-4 ring-[#be16e8] dark:ring-[#82e46a]'
+                    'ring-4 ring-accent dark:ring-accent-dark'
apps/masterbots.ai/components/routes/chat/chat-chatbot-details.tsx (1)

98-107: Consider extracting mobile view props.

The mobile view components receive multiple props that could be simplified using a shared props object, similar to how sharedProps is used for OnboardingChatbotDetails.

-      {isWelcomeView ? (
-        <OnboardingMobileView />
-      ) : (
-        <SelectedBotMobileView
-          botName={botName}
-          description={activeChatbot?.description || ''}
-          avatar={activeChatbot?.avatar || randomChatbot?.avatar || ''}
-          onNewChat={handleNewChat}
-        />
-      )}{' '}
+      {isWelcomeView ? (
+        <OnboardingMobileView />
+      ) : (
+        <SelectedBotMobileView {...sharedProps} />
+      )}
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (1)

48-48: Consider using a constant for environment check.

The environment check could be moved to a constant or utility function for reusability and consistency across the application.

+const ENV = {
+  isProd: process.env.NEXT_PUBLIC_APP_ENV === 'prod',
+  isDev: process.env.NEXT_PUBLIC_APP_ENV !== 'prod'
+} as const
+
-const isDevEnv = process.env.NEXT_PUBLIC_APP_ENV !== 'prod'
+const isDevEnv = ENV.isDev
apps/masterbots.ai/components/layout/sidebar/profile-sidebar.tsx (2)

46-57: Consider adding loading state for profile navigation.

The goToProfile function should handle loading states to provide better user feedback during navigation.

+  const [isNavigating, setIsNavigating] = useState(false)
   const goToProfile = useCallback(
     async (e: React.MouseEvent) => {
       e.preventDefault()
       e.stopPropagation()
+      setIsNavigating(true)
       const userSlug = toSlugWithUnderScore(user.name || '')
       if (userSlug) {
         setIsOpen(false)
-        router.push(`/u/${userSlug}/t`)
+        try {
+          await router.push(`/u/${userSlug}/t`)
+        } finally {
+          setIsNavigating(false)
+        }
       }
     },
-    [router, user.name]
+    [router, user.name, setIsNavigating]
   )

129-144: Consider extracting navigation config to a constant.

The navigation buttons could be defined in a configuration object for better maintainability.

+const NAVIGATION_ITEMS = {
+  pro: {
+    path: '/c/p',
+    label: 'Pro',
+    requiresDevMode: true
+  },
+  wordware: {
+    path: '/wordware',
+    label: 'Ww',
+    requiresDevMode: true
+  }
+} as const

 {appConfig.features.devMode && (
   <>
-    <Button
-      variant="ghost"
-      className="justify-start w-full text-sm"
-      onClick={() => handleNavigation('/c/p')}
-    >
-      Pro
-    </Button>
-    <Button
-      variant="ghost"
-      className="justify-start w-full text-sm"
-      onClick={() => handleNavigation('/wordware')}
-    >
-      Ww
-    </Button>
+    {Object.entries(NAVIGATION_ITEMS).map(([key, item]) => (
+      <Button
+        key={key}
+        variant="ghost"
+        className="justify-start w-full text-sm"
+        onClick={() => handleNavigation(item.path)}
+      >
+        {item.label}
+      </Button>
+    ))}
   </>
 )}
apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx (1)

29-29: Consider memoizing route type calculation.

The getRouteType(pathname) is called in multiple components. Consider memoizing this value at a higher level to avoid recalculation.

-const routeType = getRouteType(pathname)
+const routeType = useMemo(() => getRouteType(pathname), [pathname])
apps/masterbots.ai/lib/utils.ts (1)

337-342: Consider handling additional edge cases for route determination.

While the current implementation works for basic routes, consider these improvements:

  1. Handle subpaths that might contain 'chat' or 'public' elsewhere in the URL
  2. Consider normalizing the pathname to handle trailing slashes consistently

Here's a more robust implementation:

 export function getRouteType(pathname: string | null): 'chat' | 'public' | '' {
   if (!pathname) return ''
-  if (pathname.startsWith('/c')) return 'chat'
-  if (pathname.startsWith('/')) return 'public'
+  // Normalize pathname by removing trailing slash
+  const normalizedPath = pathname.replace(/\/$/, '')
+  // Match exact /c or /c/ prefix or /c/<anything> pattern
+  if (/^\/c(?:\/|$)/.test(normalizedPath)) return 'chat'
+  // Any other valid path starting with / is public
+  if (normalizedPath.startsWith('/')) return 'public'
   return ''
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ed5de7 and 444f364.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (18)
  • apps/masterbots.ai/app/globals.css (3 hunks)
  • apps/masterbots.ai/components/layout/header/header.tsx (1 hunks)
  • apps/masterbots.ai/components/layout/sidebar/profile-sidebar.tsx (2 hunks)
  • apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx (8 hunks)
  • apps/masterbots.ai/components/layout/sidebar/sidebar.tsx (2 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-chatbot-details.tsx (3 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (4 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-onboarding-chatbot-mobile.tsx (1 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-options.tsx (1 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-selected-chatbot-mobile.tsx (1 hunks)
  • apps/masterbots.ai/components/routes/chat/onboarding-chatbot-details.tsx (1 hunks)
  • apps/masterbots.ai/components/routes/chat/onboarding-chatbot-mobile-details.tsx (0 hunks)
  • apps/masterbots.ai/components/routes/chat/prompt-form.tsx (5 hunks)
  • apps/masterbots.ai/components/routes/thread/thread-popup.tsx (0 hunks)
  • apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx (1 hunks)
  • apps/masterbots.ai/components/ui/tooltip.tsx (2 hunks)
  • apps/masterbots.ai/lib/utils.ts (1 hunks)
  • apps/masterbots.ai/package.json (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/masterbots.ai/components/routes/thread/thread-popup.tsx
  • apps/masterbots.ai/components/routes/chat/onboarding-chatbot-mobile-details.tsx
✅ Files skipped from review due to trivial changes (2)
  • apps/masterbots.ai/package.json
  • apps/masterbots.ai/components/ui/tooltip.tsx
🔇 Additional comments (10)
apps/masterbots.ai/components/routes/chat/onboarding-chatbot-details.tsx (1)

20-28: Well-structured conditional rendering!

The component effectively handles different states with clear, distinct UI elements and appropriate messaging for each view.

Also applies to: 57-64, 67-78

apps/masterbots.ai/components/layout/header/header.tsx (1)

23-24: LGTM! Navigation structure simplified.

The navigation changes improve clarity by replacing specialized links with a more intuitive "Public" link, while maintaining the conditional "Pro" link for development mode.

apps/masterbots.ai/components/routes/chat/chat-onboarding-chatbot-mobile.tsx (1)

6-6: Consider using dynamic height calculation.

The fixed height calculation h-[calc(100vh-196px)] might not work well across different mobile devices and screen sizes.

Consider using a more flexible approach like CSS Grid or Flexbox with min-height to ensure the content is always visible.

apps/masterbots.ai/components/routes/chat/chat-selected-chatbot-mobile.tsx (1)

20-20: Consider flexible height calculation.

Similar to the onboarding view, the fixed height calculation might cause issues on different devices.

Consider using a more flexible layout approach that adapts to different screen sizes.

apps/masterbots.ai/components/routes/chat/chat-options.tsx (1)

21-21: LGTM! UI simplification by removing font size selector.

The removal of the font size selector streamlines the chat options interface, focusing on essential features like thread visibility and sharing.

apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx (1)

217-221: LGTM! Improved UX by conditionally rendering search.

The search input is now only shown when threads exist, reducing visual clutter and providing a cleaner interface.

apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx (1)

158-159: LGTM! Well-structured route-based styling implementation.

The addition of data-route attributes enables consistent styling across different routes while maintaining clean separation of concerns between logic and styles.

Also applies to: 175-176, 251-257, 276-292

apps/masterbots.ai/app/globals.css (1)

53-58: LGTM! Well-structured gradient system for route-specific styling.

The implementation:

  • Uses CSS custom properties for maintainable theming
  • Provides consistent styling for both light and dark modes
  • Implements smooth transitions for hover states

Also applies to: 105-110, 325-345

apps/masterbots.ai/lib/utils.ts (2)

332-336: Well-documented function with clear JSDoc comments.

The documentation clearly describes the purpose, parameters, and return types of the function.


337-342: Verify the impact on route-based styling.

Since this function is crucial for UI/UX changes, let's verify its usage in the sidebar components.

✅ Verification successful

Route type function is correctly integrated with styling system.

The getRouteType function is properly used for route-based styling across sidebar components, with CSS classes correctly matching its return values. The implementation handles all route patterns consistently and is crucial for the UI/UX styling system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how getRouteType is used in sidebar components and verify potential edge cases

# Find all files that import or use getRouteType
echo "Files importing or using getRouteType:"
rg -l "getRouteType" --type ts --type tsx

# Check for all route patterns in the codebase to ensure we handle them correctly
echo -e "\nAll unique route patterns in the codebase:"
rg -o 'path(?:name)?=["\'`](.*?)["\'`]' --type ts --type tsx | sort -u

Length of output: 375


Script:

#!/bin/bash
# Search for getRouteType usage with context
echo "=== Files using getRouteType with context ==="
rg "getRouteType" -t typescript -t tsx -C 2

# Find route patterns with proper quote escaping
echo -e "\n=== Route patterns in the codebase ==="
rg "pathname\s*=\s*['\"].*?['\"]" -t typescript -t tsx

# Look specifically in sidebar-related files
echo -e "\n=== Sidebar-related files containing route logic ==="
rg -l "Sidebar|sidebar" -t typescript -t tsx | xargs rg "pathname|route" -C 2

Length of output: 76309

@@ -59,7 +60,7 @@ export default function ChatChatbotDetails() {
}

fetchData()
}, [activeCategory, activeChatbot, session?.user])
}, [activeCategory, activeChatbot])
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

The dependency array should include session?.user

The getThreadNum function called within fetchData directly depends on session?.user for:

  • Authentication check
  • JWT token access (session?.user.hasuraJwt)
  • User identification (session?.user.id)

Omitting session?.user from the dependency array could lead to stale data or authentication issues if the session changes.

🔗 Analysis chain

Verify the dependency array change.

The removal of session?.user from the dependency array might cause stale data issues if the session changes. The fetchData function depends on session?.user for getThreadNum.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of session?.user in useEffect dependencies
ast-grep --pattern 'useEffect(() => {
  $$$
}, [$$$session?.user$$$])'

Length of output: 72


Script:

#!/bin/bash
# Find the fetchData implementation and any usage of session?.user
ast-grep --pattern 'const fetchData = async () => {
  $$$
}'

# Also search for any direct usage of session?.user
rg "session\?\.user" "apps/masterbots.ai/components/routes/chat/chat-chatbot-details.tsx"

Length of output: 3294


Script:

#!/bin/bash
# Find getThreadNum implementation
ast-grep --pattern 'const getThreadNum = async () => {
  $$$
}'

# Also search for getThreadNum function declaration in other possible formats
rg "getThreadNum" "apps/masterbots.ai/components/routes/chat/chat-chatbot-details.tsx" -A 5

Length of output: 1793

Comment on lines +87 to +93
onSelect={currentValue => {
process.env.NEXT_PUBLIC_APP_ENV !== 'prod'
? (setValue(currentValue === value ? '' : currentValue), changeModel(currentValue as AIModels))
: ''
setOpen(false) // Closes the popover after selection.
? (setValue(currentValue === value ? '' : currentValue),
changeModel(currentValue as AIModels))
: ''
setOpen(false) // Closes the popover after selection.
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify the model selection logic.

The nested environment check is redundant since we're already within an isDevEnv conditional block.

-                    onSelect={currentValue => {
-                      process.env.NEXT_PUBLIC_APP_ENV !== 'prod'
-                        ? (setValue(currentValue === value ? '' : currentValue),
-                          changeModel(currentValue as AIModels))
-                        : ''
-                      setOpen(false) // Closes the popover after selection.
-                    }}
+                    onSelect={currentValue => {
+                      setValue(currentValue === value ? '' : currentValue)
+                      changeModel(currentValue as AIModels)
+                      setOpen(false)
+                    }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onSelect={currentValue => {
process.env.NEXT_PUBLIC_APP_ENV !== 'prod'
? (setValue(currentValue === value ? '' : currentValue), changeModel(currentValue as AIModels))
: ''
setOpen(false) // Closes the popover after selection.
? (setValue(currentValue === value ? '' : currentValue),
changeModel(currentValue as AIModels))
: ''
setOpen(false) // Closes the popover after selection.
}}
onSelect={currentValue => {
setValue(currentValue === value ? '' : currentValue)
changeModel(currentValue as AIModels)
setOpen(false)
}}

Comment on lines 67 to 75
const handleBotSelection = () => {
if (activeThread?.chatbot) {
setActiveChatbot(activeThread.chatbot)
// Focus textarea after bot selection
if (inputRef.current) {
inputRef.current.focus()
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding error handling for bot selection.

The handleBotSelection function should handle the case where activeThread is undefined.

 const handleBotSelection = () => {
+  if (!activeThread) {
+    console.warn('No active thread available for bot selection')
+    return
+  }
   if (activeThread?.chatbot) {
     setActiveChatbot(activeThread.chatbot)
     // Focus textarea after bot selection
     if (inputRef.current) {
       inputRef.current.focus()
     }
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleBotSelection = () => {
if (activeThread?.chatbot) {
setActiveChatbot(activeThread.chatbot)
// Focus textarea after bot selection
if (inputRef.current) {
inputRef.current.focus()
}
}
}
const handleBotSelection = () => {
if (!activeThread) {
console.warn('No active thread available for bot selection')
return
}
if (activeThread?.chatbot) {
setActiveChatbot(activeThread.chatbot)
// Focus textarea after bot selection
if (inputRef.current) {
inputRef.current.focus()
}
}
}

Comment on lines 147 to 155
// biome-ignore lint/a11y/useKeyWithClickEvents: <explanation>
<div onClick={handleBotSelection} className={cn(
'backdrop-blur-[1px] font-semibold border border-[#27272A] rounded-[6px] absolute size-full top-0 left-0',
'flex justify-center items-center dark:bg-[#27272A80] text-2xl',
'cursor-pointer transition-all',
'hover:border-[#82e46a] hover:text-[#82e46a]'
)}>
Select <span className="mx-2 text-[#82e46a]">{activeThread?.chatbot?.name}</span> to continue
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add keyboard accessibility to the selection overlay.

The overlay div should be keyboard accessible and follow ARIA best practices.

-        // biome-ignore lint/a11y/useKeyWithClickEvents: <explanation>
-        <div onClick={handleBotSelection} className={cn(
+        <div
+          role="button"
+          tabIndex={0}
+          onClick={handleBotSelection}
+          onKeyDown={(e) => e.key === 'Enter' && handleBotSelection()}
+          className={cn(
           'backdrop-blur-[1px] font-semibold border border-[#27272A] rounded-[6px] absolute size-full top-0 left-0',
           'flex justify-center items-center dark:bg-[#27272A80] text-2xl',
           'cursor-pointer transition-all',
           'hover:border-[#82e46a] hover:text-[#82e46a]'
-        )}>
+        )}
+          aria-label={`Select ${activeThread?.chatbot?.name} to continue`}
+        >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// biome-ignore lint/a11y/useKeyWithClickEvents: <explanation>
<div onClick={handleBotSelection} className={cn(
'backdrop-blur-[1px] font-semibold border border-[#27272A] rounded-[6px] absolute size-full top-0 left-0',
'flex justify-center items-center dark:bg-[#27272A80] text-2xl',
'cursor-pointer transition-all',
'hover:border-[#82e46a] hover:text-[#82e46a]'
)}>
Select <span className="mx-2 text-[#82e46a]">{activeThread?.chatbot?.name}</span> to continue
</div>
<div
role="button"
tabIndex={0}
onClick={handleBotSelection}
onKeyDown={(e) => e.key === 'Enter' && handleBotSelection()}
className={cn(
'backdrop-blur-[1px] font-semibold border border-[#27272A] rounded-[6px] absolute size-full top-0 left-0',
'flex justify-center items-center dark:bg-[#27272A80] text-2xl',
'cursor-pointer transition-all',
'hover:border-[#82e46a] hover:text-[#82e46a]'
)}
aria-label={`Select ${activeThread?.chatbot?.name} to continue`}
>
Select <span className="mx-2 text-[#82e46a]">{activeThread?.chatbot?.name}</span> to continue
</div>

@AndlerRL
Copy link
Member

@sheriffjimoh -- @Bran18 has some code conflicts, which some of them are related with your changes. Can you double-check? It should be the chat-chatbot-details component. Also it would be good to read the changes as well, most of the changes are key for the UI/UX upgrades.

@coderabbitai please help our collaborators to see if any of these conflicting files (or others that Bran18 has worked on this PR) was previously updated by sheriffjimoh.

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

Tip

For best results, initiate chat on the files or code changes.

@AndlerRL I've found several recent changes by @sheriffjimoh that could be causing conflicts:

  1. Most notably, PR User following  #319 (merged Dec 21) made significant changes to chat-chatbot-details.tsx (+68/-9 lines) along with changes to onboarding-chatbot-details.tsx and onboarding-chatbot-mobile-details.tsx.

  2. Additionally, PRs Fix browse category navigation #316 and Shallow routing for category & chatbots for chat & profile page  #313 also modified some of the same components, particularly in the sidebar and chat-related files.

I recommend @sheriffjimoh and @Bran18 to:

  1. Review the changes from PR User following  #319 specifically for the chat components
  2. Resolve any conflicts in chat-chatbot-details.tsx as it had the most substantial changes
  3. Ensure the new UI/UX changes align with the recently merged functionality
🔗 Analysis chain
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Get the list of files modified in this PR
gh pr view 336 --json files --jq '.files[].path'

# Check recent commits by sheriffjimoh in the chat-chatbot-details component
git log --author="sheriffjimoh" -p -- apps/masterbots.ai/components/routes/chat/chat-chatbot-details.tsx

# Get recent commits by sheriffjimoh in all files modified in this PR
for file in $(gh pr view 336 --json files --jq '.files[].path'); do
  echo "=== Checking $file ==="
  git log --author="sheriffjimoh" -p -- "$file"
done

Length of output: 6069


Script:

#!/bin/bash
# Check for recent commits by sheriffjimoh in relevant directories
echo "=== Recent commits in chat components ==="
git log --since="1 month ago" --author="sheriffjimoh" -p -- apps/masterbots.ai/components/routes/chat/

echo "=== Recent commits in layout components ==="
git log --since="1 month ago" --author="sheriffjimoh" -p -- apps/masterbots.ai/components/layout/

# Check for recent merged PRs by sheriffjimoh
echo "=== Recent merged PRs by sheriffjimoh ==="
gh pr list --state merged --author sheriffjimoh --json number,title,mergedAt,files --limit 5

Length of output: 11657

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