Skip to content

Refactor profile sidebar UI, update model handling, and improve auth flow#474

Merged
AndlerRL merged 45 commits intomainfrom
develop
Apr 30, 2025
Merged

Refactor profile sidebar UI, update model handling, and improve auth flow#474
AndlerRL merged 45 commits intomainfrom
develop

Conversation

@AndlerRL
Copy link
Member

@AndlerRL AndlerRL commented Apr 30, 2025

Summary by Sourcery

Refactor and enhance the model selection and user experience across multiple components, introducing dynamic model loading, improved model grouping, and better user interaction flows.

New Features:

  • Dynamically load models from the backend
  • Implement model grouping by type and availability
  • Add support for pro and free model selection

Bug Fixes:

  • Fix model selection and deep thinking logic
  • Resolve issues with thread loading and pagination

Enhancements:

  • Improve model selection UI in chat combobox
  • Enhance user authentication and profile handling
  • Optimize sidebar and thread panel interactions

Documentation:

  • Update model-related type definitions
  • Clarify model selection behavior

Tests:

  • Add type checking for model selection
  • Improve error handling in model fetching

Summary by CodeRabbit

  • New Features

    • Introduced an accordion UI for the Threads section in the profile sidebar for improved navigation and accessibility.
    • Added a Google icon to the login button for enhanced visual clarity.
  • Improvements

    • Unified sidebar and button styles between public and profile routes.
    • Enhanced loading indicators with skeleton placeholders in user login.
    • Updated search input placeholders to use "topic" instead of "category" for clearer guidance.
    • Improved error handling and state management in user menu and thread panel.
    • Refined model name formatting and display for better readability.
    • Updated button styles and sign-in redirect for login.
    • Disabled link prefetching in several components to optimize performance.
    • Reduced thread pagination sizes for more efficient data loading.
    • Updated logic for file attachment acceptance and AI model selection.
  • Bug Fixes

    • Corrected conditional checks and logic in thread loading, search, and sidebar category selection.
    • Improved no-results messaging and icon display for thread lists.
  • Chores

    • Minor code refactoring and comment updates for maintainability.

Bran18 and others added 30 commits March 26, 2025 18:06
* update

* fix: update

* update

* update

* update

* update

* fix: opening threads

* fix: rm threads dropdwon  & added back link to bot page thread view page

* fix: rm threads dropdwon  & added back link to bot page thread view page

* fix: update

* fix: added back to profile page

* fix: added sticky and color
…ock & clipboard hook (#425)

* fix: codeblock ctas

* fix: ts build
…426)

* fix: css handleCLick condition

* fix: get latest search params, continuous thread

* fix(impr): all messages sorting

* perf(impr): sign in & up redirection tweak

* perf(impr): mobile chat css
…ck (#432)

* refactor: use chat and continue generation

* fix: uniq slug and id gen (#433)

* fix: uniq thread + msg slug gen

* style: formatting

* fix: thread user attachments state upt

* perf: impr thread component at all pages + mobile tweaks

* refactor: thread-component card

* chore: restore continue generation v1

* feat(impr): thread component card

* fix: admin panel n actions

* fix: fetch getThreads

* chore: continue conversation v1.2

* chore: continue and update thread content

* chore: add ui control continue generation state

* chore: fix infinity loop

* chore(impr): enable upt msg table permission

* fix: seo thread fetch

* chore: style formating

* fix(impr): continued thread title + thread component reusability

* chore: refactor loadings + extending sonners

---------

Co-authored-by: bran18 <andreyfdez18@gmail.com>

---------

Co-authored-by: Roberto Lucas <andler@bitcash.org>
* feat: add gemini provider

* chore: update icons
* feat(wip): impr continuing thread tags + accordion first msg toggle

* feat(impr): continuing thread tags + accordion at first message + header mobile tweak

* style(impr): mobile thread-component x-axis space

* perf(style): coderabbitai feedbacks

* fix: css typo

* perf: sendMessageFromResponse clicked guard + continued thread tags label tweak

* chore: user thread panel clean up

* fix: user-thread-panel infinite loader

* perf: impr shared accordion animation and ux

* style: defaultAccordionState comments loc

* fix: record type warning, hasura updateMessage

* fix: getThread user data, shared-accordion
* update

* fix: update

* update

* update

* update

* update

* refactor: profile page threads pop up

* fix: update config

* fix: update

* fix: update

* fix: make profile page scroll on hero

* fix: bot make popup and scroll

* fix: make profile page sidebar scroll independently

* fix: make profile page sidebar scroll independently

* fix: check the category along the chatbot when it's not checked

* fix: check the category along the chatbot when it's not checked

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>
Co-authored-by: Roberto Lucas <andler@bitcash.org>
* feat-add-models

* feat-add-models

* feat-add-models

* chore: add model

* fix: typo

* chore: add toggler color
… seeds (#447)

* feat(wip): thread llm context, prev questions

* fix: previousQuestionsString slice

* fix: clickedContentId in followingQuestionsPrompt

* feat: isContinued + model type in message table

* fix: ts typo + sendMessageFromResponse callback call

* fix: ts typo
* fix(wip): bot profile thread list

* style: formatting
* fix: new chat state reset

* fix: genql gen + share link check

* fix: og img

* fix: duplicate role permission in msg table
* chore: restore base version

* chore: add new logic and hooks

* chore: fix providers file

* chore: improve continuation prompt

* chore: add exlucision flag

* chore: add better handler

* chore: updated flow + experimental delay

* chore: extended time

* chore(impr): streamDelayMs experimental feat flag

* style: formatting

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>
* fix: profile sidebar cat opt render

* chore: clean-up
…ess and type support (#456)

* fix: slugify fn

* chore: devMode logs
* fix: slugify first request delay incr + genql ts, seeds & model migration upt

* fix: create thread & msg ts
* update

* fix: update

* update

* update

* update

* update

* fix: use the user avatar or robohash

* fix: added avater to user menu

* fix: user avatar

* fix: reset search input when filter by category or chatbot

* fix: personal chat browse provider + username chk in sign up

* chore: clean duplicated if condition signup

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>
* impr: continuation logic flow

* impr: continuation logic flow

* chore: update createImprovementPrompt

* chore: upt logs

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>
…gic (#462)

* feat: models table

* style: formatting

* fix: continuation accordion content

* fix: sql + metadata typo
AndlerRL and others added 12 commits April 25, 2025 16:24
* fix: mob prof sidebar + sign-up pw verif + username chk

* chore: upt genql gen
* wip: model selector query

* wip: model selector query

* chore: improve funtions

* chore: add coderabbit suggestion

* chore: add hasura permissions, models table

* style: formatting

* chore: fix get model client type

* chore: add model

---------

Co-authored-by: Roberto Romero Lucas <contact@andler.dev>
* chore: remove prefetch on sidebar & profile navigation

* perf: impr profile sidebar

* fix: infinite scroll load more fetch

* perf(impr): google sign-in

* perf(impr): session loaders tweak

* perf: impr categoriesId obtention

* fix: tailwind typo
@AndlerRL AndlerRL requested a review from Copilot April 30, 2025 09:37
@AndlerRL AndlerRL self-assigned this Apr 30, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Apr 30, 2025

Reviewer's Guide

This pull request refactors the AI model selection to fetch models dynamically from the backend instead of using a hardcoded list. It introduces a new Hasura service and updates the useModel hook and ChatCombobox component accordingly. Additionally, it refactors the profile sidebar's thread list using an Accordion, improves thread fetching and pagination in the user thread panel, and includes various UI/UX enhancements.

File-Level Changes

Change Details Files
Implemented dynamic AI model loading and selection.
  • Created a new Hasura service (getModels) to fetch model configurations.
  • Granted database permissions to the models table.
  • Refactored useModel hook to fetch models dynamically, manage loading/error states, and handle model selection using string identifiers.
  • Updated ChatCombobox to use the new hook, display models grouped by type (free/paid) via ModelGroup, show loading state, and disable paid models based on user subscription.
  • Added utility functions (getModelIcon, groupModels, etc.) and ModelGroup component for model display.
  • Replaced hardcoded model enum/list with dynamic data and string identifiers throughout the codebase.
  • Updated helper functions (getModelClientType) and dependent hooks/components (useDeepThinking, useChatAttachments, PromptForm, useMBChat) to use model strings.
  • Added proUserSubscriptionId to user data query.
apps/masterbots.ai/lib/hooks/use-model.tsx
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx
apps/masterbots.ai/services/hasura/hasura.service.ts
apps/hasura/metadata/databases/masterbots/tables/public_models.yaml
apps/masterbots.ai/lib/models.tsx
apps/masterbots.ai/components/routes/chat/chat-model-group.tsx
apps/masterbots.ai/app/api/chat/models/models.ts
apps/masterbots.ai/lib/helpers/ai-helpers.ts
apps/masterbots.ai/lib/hooks/use-deep-thinking.tsx
apps/masterbots.ai/lib/hooks/use-chat-attachments.ts
apps/masterbots.ai/components/routes/chat/prompt-form/index.tsx
apps/masterbots.ai/lib/hooks/use-mb-chat.tsx
apps/hasura/metadata/databases/masterbots/tables/public_models_enum.yaml
apps/masterbots.ai/types/types.ts
Refactored the profile page sidebar.
  • Replaced custom thread list toggle with Shadcn Accordion component.
  • Adjusted sidebar layout, height constraints, and styling.
  • Updated path parsing in useSidebar hook for profile routes.
apps/masterbots.ai/components/layout/profile/profile-page-sidebar.tsx
apps/masterbots.ai/lib/hooks/use-sidebar.tsx
apps/masterbots.ai/globals.css
Improved user thread panel functionality and display.
  • Updated thread fetching to use selected categories when no specific category is active.
  • Improved 'load more' logic to prevent fetching beyond the total count.
  • Enhanced 'No Results' card with specific icon/message for end-of-list state.
  • Reduced pagination page size.
apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx
apps/masterbots.ai/components/shared/no-results-card.tsx
apps/masterbots.ai/lib/constants/hasura.ts
Made various UI/UX adjustments and minor fixes.
  • Added Google icon and updated login button style and callback URL.
  • Replaced loading text with Skeleton component in user login.
  • Updated search placeholder text.
  • Disabled prefetching on several Link components.
  • Improved user creation logic on first sign-in (username, profile picture fallback).
  • Added error handling for user data fetching in header menu.
apps/masterbots.ai/components/ui/icons.tsx
apps/masterbots.ai/components/shared/login-button.tsx
apps/masterbots.ai/components/auth/user-login.tsx
apps/masterbots.ai/components/shared/shared-search.tsx
apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx
apps/masterbots.ai/components/routes/thread/profile-avatar.tsx
apps/masterbots.ai/components/shared/chatbot-avatar.tsx
apps/masterbots.ai/auth.ts
apps/masterbots.ai/components/layout/header/user-menu.tsx
apps/masterbots.ai/lib/sentry.ts
bun.lock

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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

@vercel
Copy link

vercel bot commented Apr 30, 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 Apr 30, 2025 9:43am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 30, 2025

Walkthrough

This update introduces several UI and backend improvements across the application. The profile sidebar is refactored to use an accordion UI for threads, with improved toggle state management and accessibility. CSS selectors are broadened to unify styling between the public and profile routes. Model handling is updated, including renaming "DeepSeekGroq" to "GroqDeepSeek" and refining model selection, formatting, and icon logic. User authentication is streamlined for Google sign-in, and the login button receives a visual update with a new Google icon. Pagination constants are reduced, and thread fetching logic is optimized. Several components now explicitly disable Next.js link prefetching.

Changes

File(s) Change Summary
app/globals.css Expanded CSS selectors to apply public route styles to profile route for sidebar, buttons, and avatar elements.
auth.ts Refactored Google sign-in user creation: username and profile picture generation streamlined, avoids redundant calls.
components/auth/user-login.tsx Replaced loading text with a styled <Skeleton> component for loading state.
components/layout/header/user-menu.tsx Added guard clause and error handling to user fetch logic in UserMenu.
components/layout/profile/profile-page-sidebar.tsx Refactored sidebar to use Accordion UI for threads, improved toggle state, updated layout and accessibility.
components/layout/sidebar/sidebar-link.tsx,
components/routes/thread/profile-avatar.tsx,
components/shared/chatbot-avatar.tsx
Set prefetch={false} on Next.js Link components to disable prefetching.
components/routes/chat/chat-combobox.tsx Integrated user subscription status for premium models, removed model search input, updated async user fetch.
components/routes/chat/chat-model-group.tsx Used formatModelName for model display, added conditional debug log, increased check icon size.
components/routes/chat/prompt-form/index.tsx,
lib/hooks/use-chat-attachments.ts
Adjusted model name checks for file acceptance logic: replaced "DeepSeekGroq" with "GroqDeepSeek".
components/routes/thread/user-thread-panel.tsx Refactored thread fetching: improved parameter construction, early exit on load, adjusted state updates, enhanced no-results messaging.
components/shared/login-button.tsx Changed button style and size, updated callback URL, added Google icon, removed unused icon logic.
components/shared/no-results-card.tsx Changed icon rendering logic based on message content, added margin, cleaned imports.
components/shared/shared-search.tsx Updated search input placeholder text from "category" to "topic".
components/ui/icons.tsx Added IconGoogle SVG component, set explicit size on IconDeepSeek, updated exports.
lib/constants/hasura.ts Reduced PAGE_SIZE from 50 to 20 and PAGE_SM_SIZE from 20 to 10.
lib/helpers/ai-helpers.ts Updated model client type logic: renamed/removed model checks, commented out Perplexity/DeepSeek branches.
lib/hooks/use-deep-thinking.tsx Replaced all references to DeepSeekGroq with GroqDeepSeek in deep thinking logic.
lib/hooks/use-sidebar.tsx Expanded pathname destructuring and matching logic for chatbot/category selection.
lib/models.tsx Updated getModelIcon to use startsWith, added and exported formatModelName function.
lib/sentry.ts Added lint-ignore comment for any type in LogErrorOptions.
services/hasura/hasura.service.ts Reduced thread fetch limit, added proUserSubscriptionId to user query.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Auth
    participant HasuraService

    User->>UI: Clicks "Sign in with Google"
    UI->>Auth: Triggers Google sign-in
    Auth->>Auth: Generate username and profile picture
    Auth->>HasuraService: Create user with generated info
    HasuraService-->>Auth: Return user data
    Auth-->>UI: Complete sign-in flow
    UI-->>User: Display authenticated UI
Loading
sequenceDiagram
    participant User
    participant Sidebar
    participant Accordion

    User->>Sidebar: Loads profile page
    Sidebar->>Accordion: Render threads section as accordion
    User->>Accordion: Toggles threads section
    Accordion-->>Sidebar: Update open/close state
    Sidebar-->>User: Show/hide threads content
Loading

Possibly related PRs

  • bitcashorg/masterbots#260: Refactors Google sign-in and JWT callback logic in auth.ts, directly related to authentication changes.
  • bitcashorg/masterbots#473: Updates model name references from "DeepSeekGroq" to "GroqDeepSeek" in multiple files, matching model handling changes here.
  • bitcashorg/masterbots#364: Modifies sidebar CSS and layout for responsiveness; both PRs target the profile sidebar component and layout.

Suggested labels

enhancement, bug, frontend, backend

Poem

A bunny hops through code so neat,
Accordion threads now fold and greet.
Models renamed, icons shine anew,
The sidebar’s style gets a fresh debut!
Prefetch off, the links relax,
With Google’s button leading the packs.
🐰✨—another leap, another feat!

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/app/globals.css

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.

apps/masterbots.ai/components/auth/user-login.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.

apps/masterbots.ai/auth.ts

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.

  • 21 others
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a series of updates across the application including adjustments to pagination constants, UI and icon improvements, and enhancements to thread fetching and model selection logic. Key changes include reducing page size constants and updating icon properties, refining thread pagination and search placeholder logic, and introducing a new model grouping component with updated model enum definitions.

Reviewed Changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/masterbots.ai/lib/constants/hasura.ts Reduced page size constants to support finer pagination control.
apps/masterbots.ai/components/ui/icons.tsx Added size props to SVG icons and introduced a new IconGoogle component.
apps/masterbots.ai/components/shared/shared-search.tsx Updated placeholder text from “category” to “topic” for consistency.
apps/masterbots.ai/components/shared/no-results-card.tsx Improved no-results icon logic and adjusted layout for clarity.
apps/masterbots.ai/components/shared/login-button.tsx Changed button variant and updated signIn callback URL along with Google icon integration.
apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx Refactored pagination logic and state updates; removed PAGE_SM_SIZE usage in favor of PAGE_SIZE.
apps/masterbots.ai/components/routes/chat/prompt-form/index.tsx Updated model matching regex to reflect new naming conventions.
apps/masterbots.ai/components/routes/chat/chat-model-group.tsx Introduced a new component to group models based on type and availability.
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx Revised model selection logic and integrated multi-model feature flag.
Other files Minor adjustments including disabling prefetch on links, API updates in auth, and metadata improvements in Hasura YAML.
Files not reviewed (1)
  • apps/masterbots.ai/app/globals.css: Language not supported
Comments suppressed due to low confidence (4)

apps/masterbots.ai/lib/constants/hasura.ts:1

  • [nitpick] Ensure that the updated PAGE_SIZE and PAGE_SM_SIZE values are reflected in the related pagination documentation and tested across the application for consistent behavior.
export const PAGE_SIZE = 20

apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx:172

  • [nitpick] Review the updated pagination logic here—using PAGE_SIZE for the loadMore function—to ensure that merging new threads into state works as intended without unexpected omissions.
if (totalThreads === count) return

apps/masterbots.ai/components/routes/chat/prompt-form/index.tsx:257

  • [nitpick] Verify that the updated regex pattern correctly matches the intended model naming conventions after the recent enum changes; adjust if the order or casing needs further refinement.
selectedModel.match(/(DeepSeekR1|GroqDeepSeek)/)

apps/masterbots.ai/app/api/chat/models/models.ts:14

  • [nitpick] Double-check that the updated enum values and ordering are consistent with the rest of the codebase and that no deprecated keys remain in use; update references as needed.
Default = 'gpt-4.1-mini-2025-04-14', //!  OpenAI_4_1_mini

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 @AndlerRL - I've reviewed your changes - here's some feedback:

  • The getModelClientType function relies on string matching for model names; consider using a dedicated field from the database model data for more robust client type determination.
  • The CSS changes introduce duplicated styles for [data-route="profile"] and [data-route="public"]; explore consolidating these rules for better maintainability.
  • Several links now have prefetch={false}; ensure this change doesn't negatively impact perceived navigation performance where prefetching might be beneficial.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: 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.

@AndlerRL
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 30, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai bot changed the title @coderabbitai Refactor profile sidebar UI, update model handling, and improve auth flow Apr 30, 2025
@AndlerRL AndlerRL merged commit af7e9ee into main Apr 30, 2025
2 checks passed
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 (1)
apps/masterbots.ai/lib/helpers/ai-helpers.ts (1)

25-46: 💡 Verification agent

🧩 Analysis chain

TODO comment should be addressed

There's a TODO comment at line 25 indicating that this function needs to be refactored to use an enum from Hasura instead of the AiClientType.


🏁 Script executed:

#!/bin/bash
# Check if there's a model enum type in the Hasura schema files
fd -g "*schema*.{graphql,ts,js}" | xargs grep -l "enum.*model" 2>/dev/null

Length of output: 102


🏁 Script executed:

#!/bin/bash
# Display the model enum block from the Hasura-generated schema
grep -R -n "enum.*model" packages/mb-genql/generated/schema.ts | sed -n '1p' | cut -d: -f1 | xargs -I{} sed -n "{},+10p" packages/mb-genql/generated/schema.ts

Length of output: 436


Refactor getModelClientType to use Hasura’s ModelsEnumEnum

The TODO at line 25 should be addressed by importing and using the generated enum from packages/mb-genql/generated/schema.ts rather than working off a plain string. Specifically:

• Update the function signature to

import { ModelsEnumEnum } from 'packages/mb-genql/generated/schema';
export function getModelClientType(model: ModelsEnumEnum): AiClientType {  }

• Replace the lowercase‐string checks with a switch (or a lookup object) on the enum values:

-export function getModelClientType(model: string): AiClientType {
-  const modelLower = model.toLowerCase()
-  if (modelLower.includes('gpt') || modelLower.includes('o4-mini')) {
-    return 'OpenAI'
-  }
-  if (modelLower.includes('claude')) {
-    return 'Anthropic'
-  }
-  if (modelLower.startsWith('deepseek')) {
-    return 'GroqDeepSeek'
-  }
-  if (modelLower.startsWith('gemini')) {
-    return 'Gemini'
-  }
-  console.error(`Unsupported model specified: ${model}`)
-  throw new Error('Unsupported model specified')
-}
+export function getModelClientType(model: ModelsEnumEnum): AiClientType {
+  switch (model) {
+    case 'OPENAI':
+    case 'OPENAI__4_1':
+      return 'OpenAI'
+
+    case 'CLAUDE__3_7__SONNET':
+      return 'Anthropic'
+
+    case 'DEEPSEEK':
+    case 'GROQDEEPSEEK':
+      return 'GroqDeepSeek'
+
+    case 'GEMINI__2_5__FLASH':
+    case 'GEMINI__2_5__PRO':
+    case 'GEMINI__FLASH__LITE':
+      return 'Gemini'
+
+    default:
+      console.error(`Unsupported model specified: ${model}`)
+      throw new Error('Unsupported model specified')
+  }
+}

• Remove the old string‐based TODO once refactored.

♻️ Duplicate comments (3)
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (1)

43-43: Add braces to conditional

This single-line if statement should follow best practices by using braces.

-		if (!session?.user?.hasuraJwt) return null
+		if (!session?.user?.hasuraJwt) {
+			return null
+		}
apps/masterbots.ai/components/layout/profile/profile-page-sidebar.tsx (1)

44-49: Use braces for conditional statements

The if statement should use block braces even for single-line statements to prevent potential bugs when additional statements are added later.

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

172-172: Use braces for conditional statements

The if statement should use block braces even for single-line statements to prevent potential bugs when additional statements are added later.

🧹 Nitpick comments (8)
apps/masterbots.ai/app/globals.css (1)

457-465: Duplicated CSS selectors

There appears to be a duplication of the same selectors and rules that were defined earlier in the file (lines 397-400, 402-405). This redundancy should be removed to improve maintainability.

Consider removing these duplicate selectors to avoid potential maintenance issues where one set might be updated while the other is forgotten:

-/* Public route styles */
-[data-route="public"] .sidebar-gradient:hover:not(.selected),
-[data-route="profile"] .sidebar-gradient:hover:not(.selected) {
-	background-image: var(--background-public-hover-gradient);
-}
-
-[data-route="public"] .sidebar-gradient.selected,
-[data-route="profile"] .sidebar-gradient.selected {
-	background-image: var(--background-public-gradient);
-}
apps/masterbots.ai/components/shared/shared-search.tsx (1)

166-166: Updated fallback placeholder text for consistency.

The fallback search placeholder text has been updated from "any category" to "any topic", maintaining consistent terminology throughout the user interface.

Consider simplifying this ternary expression:

-							`Search all messages in ${searchPlaceholder ? searchPlaceholder : 'any topic'}...`
+							`Search all messages in ${searchPlaceholder || 'any topic'}...`
apps/masterbots.ai/components/routes/chat/chat-model-group.tsx (1)

32-34: Added conditional debug logging.

Good practice using a feature flag for debug logs to prevent them from appearing in production.

Consider removing these debug logs before deploying to production or adding a more descriptive message to help troubleshoot specific issues.

apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (2)

37-54: Enhance error handling for user data fetching

The user data fetching logic correctly handles authentication state, but could benefit from improved error handling.

Consider adding a notification or visual feedback when the user data fetch fails:

 	} = useAsync(async () => {
 		if (!session?.user?.hasuraJwt) return null
 		const userResults = await getUserBySlug({
 			slug: session?.user.slug || '',
 			isSameUser: true,
 		})
 
 		if (userResults.error) {
+			console.error('Failed to fetch user data:', userResults.error)
 			throw new Error(userResults.error)
 		}
 
 		return userResults.user
 	}, [session?.user?.hasuraJwt])
+
+	React.useEffect(() => {
+		if (errorUserData) {
+			// Add toast or notification here
+			console.error('Error fetching user data:', errorUserData)
+		}
+	}, [errorUserData])

81-104: Consider refactoring complex model selection logic

The model selection logic remains complex and would benefit from extraction into helper functions for improved readability.

Consider refactoring the handleModelSelect function to improve readability:

 	const handleModelSelect = (modelValue: string) => {
 		if (!appConfig.features.devMode || processingSelectionRef.current) return
 
 		processingSelectionRef.current = true
 		setOpen(false)
 
 		setTimeout(() => {
 			try {
-				if (modelValue.includes('deepseek-r1-distill-llama-70b')) {
-					if (!isDeepThinking) {
-						toggleDeepThinking()
-					}
-				} else if (modelValue.includes('deepseek') && isDeepThinking) {
-					toggleDeepThinking()
-				} else if (!modelValue.includes('deepseek') && !isDeepThinking) {
-					changeModel(modelValue)
-				}
+				handleDeepThinkingToggle(modelValue)
 			} finally {
 				setTimeout(() => {
 					processingSelectionRef.current = false
 				}, 150)
 			}
 		}, 100)
 	}
+
+	// Helper function to handle deep thinking toggle logic
+	const handleDeepThinkingToggle = (modelValue: string) => {
+		const isDeepSeekDistill = modelValue.includes('deepseek-r1-distill-llama-70b')
+		const isDeepSeekModel = modelValue.includes('deepseek')
+		
+		if (isDeepSeekDistill && !isDeepThinking) {
+			toggleDeepThinking()
+		} else if (isDeepSeekModel && isDeepThinking) {
+			toggleDeepThinking()
+		} else if (!isDeepSeekModel && !isDeepThinking) {
+			changeModel(modelValue)
+		}
+	}
apps/masterbots.ai/lib/helpers/ai-helpers.ts (2)

35-37: Code cleanup - commented out code should be removed

Rather than commenting out the Perplexity model client type detection, consider removing it entirely if it's no longer needed.

-	// if (modelLower.includes('llama') || modelLower.includes('sonar')) {
-	// 	return 'Perplexity'
-	// }

89-106: Code cleanup needed - commented case and duplicate logic

The commented out DeepSeek case and duplicate streamer payload logic should be cleaned up.

-		// case 'DeepSeek':
 		case 'GroqDeepSeek':
 			return payload.map((message) => {
 				if (message.role === 'assistant') {
 					const content = message.content as string
 					const reasoningMatch = content.match(/<think>(.*?)<\/think>/s)
 					const answerMatch = content.match(/<answer>(.*?)<\/answer>/s)
 
 					return {
 						...message,
 						content: answerMatch ? content : `<answer>${content}</answer>`,
 						reasoning: reasoningMatch
 							? reasoningMatch[1]
 							: '<think>Analyzing the context and formulating a response...</think>',
 					}
 				}
 				return message
 			})
apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx (1)

137-162: Refactored fetchBrowseThreads function for better parameter handling

The function now uses a typed parameter object and more clearly handles conditional logic for category selection and chatbot name resolution.

However, there's a console.log statement on line 159 that should be removed before production deployment:

-			console.log('browseThreadGetParams', browseThreadGetParams)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e44b579 and 2c2e4d1.

📒 Files selected for processing (24)
  • apps/masterbots.ai/app/globals.css (3 hunks)
  • apps/masterbots.ai/auth.ts (1 hunks)
  • apps/masterbots.ai/components/auth/user-login.tsx (2 hunks)
  • apps/masterbots.ai/components/layout/header/user-menu.tsx (1 hunks)
  • apps/masterbots.ai/components/layout/profile/profile-page-sidebar.tsx (4 hunks)
  • apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx (1 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (4 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-model-group.tsx (4 hunks)
  • apps/masterbots.ai/components/routes/chat/prompt-form/index.tsx (2 hunks)
  • apps/masterbots.ai/components/routes/thread/profile-avatar.tsx (1 hunks)
  • apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx (9 hunks)
  • apps/masterbots.ai/components/shared/chatbot-avatar.tsx (1 hunks)
  • apps/masterbots.ai/components/shared/login-button.tsx (3 hunks)
  • apps/masterbots.ai/components/shared/no-results-card.tsx (2 hunks)
  • apps/masterbots.ai/components/shared/shared-search.tsx (2 hunks)
  • apps/masterbots.ai/components/ui/icons.tsx (3 hunks)
  • apps/masterbots.ai/lib/constants/hasura.ts (1 hunks)
  • apps/masterbots.ai/lib/helpers/ai-helpers.ts (2 hunks)
  • apps/masterbots.ai/lib/hooks/use-chat-attachments.ts (1 hunks)
  • apps/masterbots.ai/lib/hooks/use-deep-thinking.tsx (2 hunks)
  • apps/masterbots.ai/lib/hooks/use-sidebar.tsx (1 hunks)
  • apps/masterbots.ai/lib/models.tsx (1 hunks)
  • apps/masterbots.ai/lib/sentry.ts (1 hunks)
  • apps/masterbots.ai/services/hasura/hasura.service.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx (1)
Learnt from: AndlerRL
PR: bitcashorg/masterbots#287
File: apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx:39-45
Timestamp: 2024-10-23T19:11:47.520Z
Learning: In the `UserThreadPanel` component (`apps/masterbots.ai/components/routes/thread/user-thread-panel.tsx`), the `count` state variable is used in the `loadMore` function and depends on `finalThreads.length`, so updating `count` in the `useEffect` is necessary.
🧬 Code Graph Analysis (5)
apps/masterbots.ai/lib/models.tsx (1)
apps/masterbots.ai/components/ui/icons.tsx (6)
  • IconOpenAI (904-904)
  • IconClaude (886-886)
  • IconLlama (900-900)
  • IconDeepSeek (890-890)
  • IconGemini (896-896)
  • IconWordware (918-918)
apps/masterbots.ai/auth.ts (1)
apps/masterbots.ai/lib/username.ts (1)
  • generateUsername (21-35)
apps/masterbots.ai/components/routes/chat/chat-model-group.tsx (2)
packages/mb-env/src/config.env.ts (1)
  • appConfig (2-38)
apps/masterbots.ai/lib/models.tsx (1)
  • formatModelName (37-42)
apps/masterbots.ai/components/shared/login-button.tsx (2)
apps/masterbots.ai/auth.ts (1)
  • signIn (191-246)
apps/masterbots.ai/components/ui/icons.tsx (1)
  • IconGoogle (898-898)
apps/masterbots.ai/lib/hooks/use-sidebar.tsx (1)
packages/mb-lib/src/text/text.lib.ts (1)
  • toSlug (12-44)
🔇 Additional comments (55)
apps/masterbots.ai/components/shared/chatbot-avatar.tsx (1)

29-29: Performance optimization: Disabled link prefetching

Explicitly setting prefetch={false} prevents Next.js from automatically prefetching the linked page when it appears in the viewport, which can reduce unnecessary network requests and improve overall application performance.

apps/masterbots.ai/components/routes/thread/profile-avatar.tsx (1)

51-51: Performance optimization: Disabled link prefetching

Explicitly setting prefetch={false} prevents Next.js from automatically prefetching the linked page, which helps reduce unnecessary network requests and improve performance, especially important for profile links that may not always be visited.

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

216-216: Performance optimization: Disabled link prefetching for category links

Setting prefetch={false} prevents automatic prefetching of linked pages, reducing unnecessary network requests.


356-356: Inconsistent prefetching behavior in sidebar links

There's an inconsistency in the prefetching behavior within the same component. The category link has prefetch={false} (line 216) while the chatbot link explicitly uses prefetch without a value (which defaults to true).

Consider making the prefetching behavior consistent across all navigation links in the sidebar for predictable performance:

- prefetch
+ prefetch={false}
apps/masterbots.ai/lib/constants/hasura.ts (1)

1-2: Reduced pagination sizes for improved performance

Decreasing the page sizes (from 50 to 20 for PAGE_SIZE and from 20 to 10 for PAGE_SM_SIZE) will reduce the amount of data fetched per request, which can improve initial load times and reduce memory usage.

While this change improves performance, it may impact user experience by requiring more frequent pagination. Consider monitoring user behavior after this change to ensure it doesn't negatively affect users who frequently browse through large sets of data.

apps/masterbots.ai/lib/models.tsx (2)

26-33: Improved model name detection logic

Changing from includes() to startsWith() for model name detection is a good improvement. This makes the matching more precise and prevents false positives where a model name might contain a substring that matches multiple model types.


37-42: Well-implemented model name formatting utility

The new formatModelName function provides a consistent way to transform model identifiers into user-friendly display names. This is a good abstraction that can be reused across the application.

The function correctly handles:

  • Double underscores converting to spaces
  • Single underscores converting to dots
  • Trimming any excess whitespace
apps/masterbots.ai/components/ui/icons.tsx (3)

846-848: Fixed DeepSeek icon sizing

Adding explicit height="1em" and width="1em" attributes ensures the icon will scale properly with the surrounding text size. This is good for accessibility and consistent UI rendering.


858-873: Well-structured Google icon implementation

The new IconGoogle component follows the same pattern as other icon components in this file. It properly includes accessibility attributes and maintains consistent styling with the icon system.


897-898: Proper export of new icon component

The export list has been correctly updated to include the new IconGoogle component while maintaining alphabetical order.

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

397-400: Unified styling for public and profile routes

Extending the selectors to include both [data-route="public"] and [data-route="profile"] ensures consistent styling between these routes. This is a good approach for maintaining visual consistency across different parts of the application.

Also applies to: 402-405, 407-410


418-421: Consistent component styling across routes

The styling for avatar rings, text colors, and icon fills is now unified between public and profile routes. This maintains visual cohesion throughout the application.

Also applies to: 427-430, 436-439

apps/masterbots.ai/components/auth/user-login.tsx (2)

6-6: Added Skeleton component import

Good addition of the Skeleton component import to support the UI enhancement for loading states.


17-17: Improved loading state UI

Replacing the plain text "Loading..." with a styled Skeleton component enhances the visual feedback during loading states. This creates a more polished user experience and aligns with modern UI patterns.

apps/masterbots.ai/components/shared/shared-search.tsx (1)

92-92: Terminology updated from "category" to "topic".

The search placeholder text has been changed from "category" to "topic", aligning with the application's broader terminology update.

apps/masterbots.ai/components/routes/chat/chat-model-group.tsx (3)

8-11: Added formatModelName and appConfig imports.

The new imports support model name formatting and conditional debug logging features.


52-52: Improved model name formatting.

Using the formatModelName function standardizes how model names are displayed throughout the application, improving consistency.


61-61: Increased CheckIcon size.

Changed from size-4 to size-5 for better visibility and UI balance.

apps/masterbots.ai/services/hasura/hasura.service.ts (1)

895-895:

Details

✅ Verification successful

Reduced thread fetch limit.

The number of threads fetched per request has been halved from (limit || 30) * 2 to limit || 30, which should improve performance but may affect pagination behavior.

Verify that this reduction in fetch limit doesn't negatively impact the user experience, especially with pagination or infinite scroll implementations:


🏁 Script executed:

#!/bin/bash
# Check if there are any pagination or infinite scroll components relying on specific batch sizes
rg -A 3 -B 3 "(PAGE_SIZE|limit.*30|ThreadPagination|useInfiniteScroll)"

Length of output: 67172


Reduced thread fetch limit — no impact on pagination/infinite‐scroll

All front-end callers explicitly pass the PAGE_SIZE constant (20) into your getThreads/getBrowseThreads functions, so the new fallback of limit || 30 is never actually exercised. Pagination and infinite-scroll components always rely on PAGE_SIZE, not the service default.

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

45-54: Improved error handling for user data fetching.

The user data fetching logic has been refactored with proper error handling using try-catch, making the component more robust against API failures.

The addition of early return when user slug is missing and proper error handling with try-catch improves reliability. Good defensive programming practice!

apps/masterbots.ai/lib/hooks/use-chat-attachments.ts (1)

190-190: Consistent model naming update.

The code correctly updates the model name pattern from "DeepSeekGroq" to "GroqDeepSeek", maintaining the same file filtering behavior while aligning with the renamed model across the application.

apps/masterbots.ai/components/shared/login-button.tsx (4)

4-4: Good addition of Google icon.

Adding the IconGoogle import supports the UI enhancement for the login button.


24-25: Enhanced button styling.

The button styling changes from "outline" to "secondary" variant and size to "xl" improve the visual prominence of the login action.


29-29: Improved post-login navigation.

Changing the callback URL from '/' to '/chat' provides a better user experience by directing users straight to the chat interface after login.


40-40: Better visual identity with Google icon.

Adding the Google icon provides clear visual indication of the authentication method while replacing the previously commented-out icons.

apps/masterbots.ai/components/routes/chat/prompt-form/index.tsx (2)

257-257: Consistent model naming update.

The model name has been updated from "DeepSeekGroq" to "GroqDeepSeek" in the regex pattern, maintaining consistency with the same change in other files.


270-270: Minor CSS class reordering.

The order of CSS classes changed from "overflow-hidden w-full p-0" to "w-full p-0 overflow-hidden", which is a cosmetic change that doesn't affect functionality.

apps/masterbots.ai/auth.ts (1)

211-215: Optimized user creation logic.

Good refactoring of the Google sign-in flow:

  1. Username is now generated once and stored in a variable.
  2. Profile picture assignment is optimized with conditional logic to use the user's Google image if available, or generate a default RoboHash image based on the username.

This improves code efficiency and ensures consistent user profile creation.

apps/masterbots.ai/lib/hooks/use-deep-thinking.tsx (1)

29-29: Model name change looks consistent

The model identifier has been updated from DeepSeekGroq to GroqDeepSeek consistently across the deep thinking component. This naming convention change aligns with other files in the codebase.

Also applies to: 34-34, 47-47

apps/masterbots.ai/components/shared/no-results-card.tsx (4)

7-7: Import addition looks good

Added MessageSquareXIcon to support the new "no more threads" state.


27-39: Good UX improvement with context-aware icons

The addition of conditional logic to display a thread-specific icon when "no more threads" is detected improves the user experience by providing visual context.


42-42: Appropriate spacing added

The added top margin (mt-10) improves the visual layout when no results are displayed.


44-44: Icon selection logic looks good

Updated to use the context-aware icon variable.

apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (4)

24-24: Imports added correctly for new user data fetching functionality

Added necessary imports to support user subscription status checking.

Also applies to: 28-30


106-108: Good implementation of pro model access control

The logic for determining if pro models should be disabled is well implemented, considering both the loading state and presence of subscription ID.


138-138: UI enhancement with scrollbar class

Added scrollbar styling to the command list for better usability.


154-154: Improved premium model access control

Updated the disabled state to respect user subscription status, which enhances the user experience by clearly indicating which models are available based on subscription.

apps/masterbots.ai/lib/helpers/ai-helpers.ts (2)

38-40: Improved model detection with startsWith

Using startsWith instead of includes for model detection is more precise and helps avoid potential false matches.


41-43: Consistent model detection pattern applied

Using startsWith for Gemini model detection matches the pattern used for other models, improving consistency.

apps/masterbots.ai/lib/hooks/use-sidebar.tsx (4)

165-169: Added new path variables to support profile routes

These new variables improve the pathname destructuring to better handle profile-related routes by explicitly naming path segments that were previously ignored or handled generically. This change provides better support for the new accordion UI in the profile sidebar.


174-176: Enhanced category matching logic

The additional condition to check for personalChatbotSlugProfileTopicOrThreadSlug allows the sidebar to correctly identify categories when navigating through profile-specific routes.


182-186: Improved conditional logic for chatbot finding

The extended conditional now checks for the presence of additional path variables, ensuring the correct chatbot is found regardless of whether the user is navigating through profile or public routes.


189-192: Updated chatbot matching logic

Added new conditions to match chatbots against profile-specific path variables, which ensures consistent chatbot selection across different routing patterns.

apps/masterbots.ai/components/layout/profile/profile-page-sidebar.tsx (5)

4-9: Added Accordion components for improved UI structure

The addition of these accordion components allows for a more standardized and accessible UI pattern for the threads section.


32-35: Enhanced state management for thread toggle

Added state management for thread accordion with proper integration with the sidebar context, which allows for better control of the accordion state.


72-73: Improved sidebar positioning and height calculation

Changed to fixed positioning with a viewport-relative height calculation, which ensures consistent sidebar appearance regardless of content size.


84-127: Implemented accordion UI for threads section

Replaced the previous custom toggle implementation with a standardized accordion component that provides better accessibility and user experience. The implementation includes proper ARIA attributes and keyboard navigation support.


128-161: Enhanced conditional rendering of preference links

Improved the conditional rendering logic for preference and subscription links with better styling and consistent spacing.

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

36-36: Updated pagination constant import

Replaced PAGE_SM_SIZE with PAGE_SIZE for more consistent pagination handling across the application.


49-49: Added type import for better type safety

Including the GetBrowseThreadsParams type improves type safety when constructing parameters for the fetchBrowseThreads function.


80-85: Enhanced useSidebar hook usage

Added selectedCategories to the destructured values from useSidebar, which supports the new functionality for fetching threads based on multiple categories.


197-204: Simplified state update logic

Improved state management by directly updating threads and totalThreads without redundant properties, making the code cleaner and easier to understand.


356-356: Optimized effect dependencies

Removed 'threads' from the effect dependencies to prevent unnecessary re-renders, focusing instead on the critical dependencies: isOpenPopup, pathname, and shouldRefreshThreads.


363-366: Enhanced no-results messaging

Added a more specific message for when all threads have been loaded versus when no threads are available, improving the user experience with clearer feedback.


439-445: Improved NoResults component rendering condition

Updated the condition to show the NoResults component when either no search results are found or all threads have been loaded, providing better feedback to users in different scenarios.

error: Error | unknown // The error object or value
message?: string // Optional descriptive message
level?: Sentry.SeverityLevel // Severity level (e.g., 'error', 'warning', 'info', 'debug')
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
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

Replace placeholder <explanation> and avoid suppressing the rule.

The biome-ignore comment includes a placeholder <explanation>, which should be replaced with a concrete justification. Even better, consider changing the type from Record<string, any> to Record<string, unknown> or a more specific interface for extra so that you don’t need to suppress noExplicitAny.

slug: true,
bio: true,
favouriteTopic: true,
proUserSubscriptionId: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Added proUserSubscriptionId to user query.

This field has been added to the getUserBySlug function to support subscription-aware features throughout the application.

Verify where this subscription ID is used to understand the impact of this change:


🏁 Script executed:

#!/bin/bash
# Find where proUserSubscriptionId is being used in the codebase
rg "proUserSubscriptionId" -l

Length of output: 384


Ensure Dependent Code Is Updated for proUserSubscriptionId

We’ve added proUserSubscriptionId to getUserBySlug, but this field now surfaces across several parts of the codebase:

  • Drizzle schema: packages/mb-drizzle/src/schema/auth.ts
  • Generated GraphQL schema & types: packages/mb-genql/generated/schema.graphql, schema.ts, types.ts
  • Admin service: apps/masterbots.ai/services/admin/admin.service.ts
  • Chat UI component: apps/masterbots.ai/components/routes/chat/chat-combobox.tsx
  • Shared TS types: apps/masterbots.ai/types/types.ts

Please address the following before merging:

  • Add/migrate the corresponding DB column and update the Drizzle schema
  • Rerun GraphQL codegen to regenerate schema and types
  • Verify all consumers handle proUserSubscriptionId (e.g., nullability, optional chaining) appropriately

@AndlerRL
Copy link
Member Author

AndlerRL commented May 1, 2025

sheriffjimoh added a commit that referenced this pull request Sep 9, 2025
…ow (#474)

* fix: change toggler wording + util hook (#424)

* impr: makes threads open on profile page and profile tweaks (#421)

* update

* fix: update

* update

* update

* update

* update

* fix: opening threads

* fix: rm threads dropdwon  & added back link to bot page thread view page

* fix: rm threads dropdwon  & added back link to bot page thread view page

* fix: update

* fix: added back to profile page

* fix: added sticky and color

* fix: codeblock ctas refactor markdown rendering, sidebar nav, code block & clipboard hook (#425)

* fix: codeblock ctas

* fix: ts build

* fix: continue thread + allMessages sequence + mobile chat css tweak (#426)

* fix: css handleCLick condition

* fix: get latest search params, continuous thread

* fix(impr): all messages sorting

* perf(impr): sign in & up redirection tweak

* perf(impr): mobile chat css

* chore: next + react security ver upt (#427)

* refactor: use chat and continue thread + continue conversation fallback (#432)

* refactor: use chat and continue generation

* fix: uniq slug and id gen (#433)

* fix: uniq thread + msg slug gen

* style: formatting

* fix: thread user attachments state upt

* perf: impr thread component at all pages + mobile tweaks

* refactor: thread-component card

* chore: restore continue generation v1

* feat(impr): thread component card

* fix: admin panel n actions

* fix: fetch getThreads

* chore: continue conversation v1.2

* chore: continue and update thread content

* chore: add ui control continue generation state

* chore: fix infinity loop

* chore(impr): enable upt msg table permission

* fix: seo thread fetch

* chore: style formating

* fix(impr): continued thread title + thread component reusability

* chore: refactor loadings + extending sonners

---------

Co-authored-by: bran18 <andreyfdez18@gmail.com>

---------

Co-authored-by: Roberto Lucas <andler@bitcash.org>

* feat: add gemini provider (#437)

* feat: add gemini provider

* chore: update icons

* feat: impr continuing thread tags + accordion first msg toggle (#435)

* feat(wip): impr continuing thread tags + accordion first msg toggle

* feat(impr): continuing thread tags + accordion at first message + header mobile tweak

* style(impr): mobile thread-component x-axis space

* perf(style): coderabbitai feedbacks

* fix: css typo

* perf: sendMessageFromResponse clicked guard + continued thread tags label tweak

* chore: user thread panel clean up

* fix: user-thread-panel infinite loader

* perf: impr shared accordion animation and ux

* style: defaultAccordionState comments loc

* fix: record type warning, hasura updateMessage

* fix: getThread user data, shared-accordion

* fix: coderabbitai observations

* fix: impr file management per llm, multimodel feat flag, chat tool labels, parent thread guard

* fix: tunningUserContent parentThread condition

* fix: feature flag typo

* feat: profile page thread popup feature flag and tweaks  (#434)

* update

* fix: update

* update

* update

* update

* update

* refactor: profile page threads pop up

* fix: update config

* fix: update

* fix: update

* fix: make profile page scroll on hero

* fix: bot make popup and scroll

* fix: make profile page sidebar scroll independently

* fix: make profile page sidebar scroll independently

* fix: check the category along the chatbot when it's not checked

* fix: check the category along the chatbot when it's not checked

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>
Co-authored-by: Roberto Lucas <andler@bitcash.org>

* feat: add new llm models (#444)

* feat-add-models

* feat-add-models

* feat-add-models

* chore: add model

* fix: typo

* chore: add toggler color

* perf(impr): thread llm context, last question & response + new models seeds (#447)

* feat(wip): thread llm context, prev questions

* fix: previousQuestionsString slice

* fix: clickedContentId in followingQuestionsPrompt

* feat: isContinued + model type in message table

* fix: ts typo + sendMessageFromResponse callback call

* fix: ts typo

* fix: bot profile page view (#449)

* fix(wip): bot profile thread list

* style: formatting

* fix: new chats and share + og img (#451)

* fix: new chat state reset

* fix: genql gen + share link check

* fix: og img

* fix: duplicate role permission in msg table

* feat: initial continuation logic flow (#450)

* chore: restore base version

* chore: add new logic and hooks

* chore: fix providers file

* chore: improve continuation prompt

* chore: add exlucision flag

* chore: add better handler

* chore: updated flow + experimental delay

* chore: extended time

* chore(impr): streamDelayMs experimental feat flag

* style: formatting

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>

* fix: profile sidebar cat opt render (#453)

* fix: profile sidebar cat opt render

* chore: clean-up

* [masterbots.ai] refactor: slug generation logic with improved uniqueness and type support (#456)

* fix: slugify fn

* chore: devMode logs

* fix: uniq slug gen fn nanoid flag typo

* feat: sentry logs in webapp (#457)

* fix(impr): llm enum data, thread creation, ts, and log behavior (#458)

* fix: slugify first request delay incr + genql ts, seeds & model migration upt

* fix: create thread & msg ts

* fix(impr): profile page bugs & tweaks v1 4/15/25 (#455)

* update

* fix: update

* update

* update

* update

* update

* fix: use the user avatar or robohash

* fix: added avater to user menu

* fix: user avatar

* fix: reset search input when filter by category or chatbot

* fix: personal chat browse provider + username chk in sign up

* chore: clean duplicated if condition signup

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>

* refactor: continuation flow (#460)

* impr: continuation logic flow

* impr: continuation logic flow

* chore: update createImprovementPrompt

* chore: upt logs

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>

* feat: models table, enum type, and refactor chat msg deduplication logic (#462)

* feat: models table

* style: formatting

* fix: continuation accordion content

* fix: sql + metadata typo

* fix: db migrations and messages uniqby condition (#463)

* fix: db migrations + messages uniqby condition

* fix: typo

* perf(impr): verify duplicate message return condition

* chore: upt default available models

* perf(impr): reassign continued prompt

* chore: incr fn stream max duration

* fix: mob prof sidebar + sign-up pw verif + username chk (#464)

* fix: mob prof sidebar + sign-up pw verif + username chk

* chore: upt genql gen

* perf(impr): profile navigation

* feat: model selector (#466)

* wip: model selector query

* wip: model selector query

* chore: improve funtions

* chore: add coderabbit suggestion

* chore: add hasura permissions, models table

* style: formatting

* chore: fix get model client type

* chore: add model

---------

Co-authored-by: Roberto Romero Lucas <contact@andler.dev>

* chore: impr models (#472)

* chore: fix model name and condition (#473)

* refactor: user fetching code (#471)

* refactor: profile sidebar ui, upt styling, and disable prefetch (#470)

* chore: remove prefetch on sidebar & profile navigation

* perf: impr profile sidebar

* fix: infinite scroll load more fetch

* perf(impr): google sign-in

* perf(impr): session loaders tweak

* perf: impr categoriesId obtention

* fix: tailwind typo

* chore(impr): pro user guard in model selector

* chore: category label upt to topic

---------

Co-authored-by: Brandon Fernández <31634868+Bran18@users.noreply.github.com>
Co-authored-by: Jimoh sherifdeen <63134009+sheriffjimoh@users.noreply.github.com>
sheriffjimoh added a commit that referenced this pull request Sep 10, 2025
…ow (#474)

* fix: change toggler wording + util hook (#424)

* impr: makes threads open on profile page and profile tweaks (#421)

* update

* fix: update

* update

* update

* update

* update

* fix: opening threads

* fix: rm threads dropdwon  & added back link to bot page thread view page

* fix: rm threads dropdwon  & added back link to bot page thread view page

* fix: update

* fix: added back to profile page

* fix: added sticky and color

* fix: codeblock ctas refactor markdown rendering, sidebar nav, code block & clipboard hook (#425)

* fix: codeblock ctas

* fix: ts build

* fix: continue thread + allMessages sequence + mobile chat css tweak (#426)

* fix: css handleCLick condition

* fix: get latest search params, continuous thread

* fix(impr): all messages sorting

* perf(impr): sign in & up redirection tweak

* perf(impr): mobile chat css

* chore: next + react security ver upt (#427)

* refactor: use chat and continue thread + continue conversation fallback (#432)

* refactor: use chat and continue generation

* fix: uniq slug and id gen (#433)

* fix: uniq thread + msg slug gen

* style: formatting

* fix: thread user attachments state upt

* perf: impr thread component at all pages + mobile tweaks

* refactor: thread-component card

* chore: restore continue generation v1

* feat(impr): thread component card

* fix: admin panel n actions

* fix: fetch getThreads

* chore: continue conversation v1.2

* chore: continue and update thread content

* chore: add ui control continue generation state

* chore: fix infinity loop

* chore(impr): enable upt msg table permission

* fix: seo thread fetch

* chore: style formating

* fix(impr): continued thread title + thread component reusability

* chore: refactor loadings + extending sonners

---------

Co-authored-by: bran18 <andreyfdez18@gmail.com>

---------

Co-authored-by: Roberto Lucas <andler@bitcash.org>

* feat: add gemini provider (#437)

* feat: add gemini provider

* chore: update icons

* feat: impr continuing thread tags + accordion first msg toggle (#435)

* feat(wip): impr continuing thread tags + accordion first msg toggle

* feat(impr): continuing thread tags + accordion at first message + header mobile tweak

* style(impr): mobile thread-component x-axis space

* perf(style): coderabbitai feedbacks

* fix: css typo

* perf: sendMessageFromResponse clicked guard + continued thread tags label tweak

* chore: user thread panel clean up

* fix: user-thread-panel infinite loader

* perf: impr shared accordion animation and ux

* style: defaultAccordionState comments loc

* fix: record type warning, hasura updateMessage

* fix: getThread user data, shared-accordion

* fix: coderabbitai observations

* fix: impr file management per llm, multimodel feat flag, chat tool labels, parent thread guard

* fix: tunningUserContent parentThread condition

* fix: feature flag typo

* feat: profile page thread popup feature flag and tweaks  (#434)

* update

* fix: update

* update

* update

* update

* update

* refactor: profile page threads pop up

* fix: update config

* fix: update

* fix: update

* fix: make profile page scroll on hero

* fix: bot make popup and scroll

* fix: make profile page sidebar scroll independently

* fix: make profile page sidebar scroll independently

* fix: check the category along the chatbot when it's not checked

* fix: check the category along the chatbot when it's not checked

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>
Co-authored-by: Roberto Lucas <andler@bitcash.org>

* feat: add new llm models (#444)

* feat-add-models

* feat-add-models

* feat-add-models

* chore: add model

* fix: typo

* chore: add toggler color

* perf(impr): thread llm context, last question & response + new models seeds (#447)

* feat(wip): thread llm context, prev questions

* fix: previousQuestionsString slice

* fix: clickedContentId in followingQuestionsPrompt

* feat: isContinued + model type in message table

* fix: ts typo + sendMessageFromResponse callback call

* fix: ts typo

* fix: bot profile page view (#449)

* fix(wip): bot profile thread list

* style: formatting

* fix: new chats and share + og img (#451)

* fix: new chat state reset

* fix: genql gen + share link check

* fix: og img

* fix: duplicate role permission in msg table

* feat: initial continuation logic flow (#450)

* chore: restore base version

* chore: add new logic and hooks

* chore: fix providers file

* chore: improve continuation prompt

* chore: add exlucision flag

* chore: add better handler

* chore: updated flow + experimental delay

* chore: extended time

* chore(impr): streamDelayMs experimental feat flag

* style: formatting

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>

* fix: profile sidebar cat opt render (#453)

* fix: profile sidebar cat opt render

* chore: clean-up

* [masterbots.ai] refactor: slug generation logic with improved uniqueness and type support (#456)

* fix: slugify fn

* chore: devMode logs

* fix: uniq slug gen fn nanoid flag typo

* feat: sentry logs in webapp (#457)

* fix(impr): llm enum data, thread creation, ts, and log behavior (#458)

* fix: slugify first request delay incr + genql ts, seeds & model migration upt

* fix: create thread & msg ts

* fix(impr): profile page bugs & tweaks v1 4/15/25 (#455)

* update

* fix: update

* update

* update

* update

* update

* fix: use the user avatar or robohash

* fix: added avater to user menu

* fix: user avatar

* fix: reset search input when filter by category or chatbot

* fix: personal chat browse provider + username chk in sign up

* chore: clean duplicated if condition signup

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>

* refactor: continuation flow (#460)

* impr: continuation logic flow

* impr: continuation logic flow

* chore: update createImprovementPrompt

* chore: upt logs

---------

Co-authored-by: Roberto Lucas <andler.dev@gmail.com>

* feat: models table, enum type, and refactor chat msg deduplication logic (#462)

* feat: models table

* style: formatting

* fix: continuation accordion content

* fix: sql + metadata typo

* fix: db migrations and messages uniqby condition (#463)

* fix: db migrations + messages uniqby condition

* fix: typo

* perf(impr): verify duplicate message return condition

* chore: upt default available models

* perf(impr): reassign continued prompt

* chore: incr fn stream max duration

* fix: mob prof sidebar + sign-up pw verif + username chk (#464)

* fix: mob prof sidebar + sign-up pw verif + username chk

* chore: upt genql gen

* perf(impr): profile navigation

* feat: model selector (#466)

* wip: model selector query

* wip: model selector query

* chore: improve funtions

* chore: add coderabbit suggestion

* chore: add hasura permissions, models table

* style: formatting

* chore: fix get model client type

* chore: add model

---------

Co-authored-by: Roberto Romero Lucas <contact@andler.dev>

* chore: impr models (#472)

* chore: fix model name and condition (#473)

* refactor: user fetching code (#471)

* refactor: profile sidebar ui, upt styling, and disable prefetch (#470)

* chore: remove prefetch on sidebar & profile navigation

* perf: impr profile sidebar

* fix: infinite scroll load more fetch

* perf(impr): google sign-in

* perf(impr): session loaders tweak

* perf: impr categoriesId obtention

* fix: tailwind typo

* chore(impr): pro user guard in model selector

* chore: category label upt to topic

---------

Co-authored-by: Brandon Fernández <31634868+Bran18@users.noreply.github.com>
Co-authored-by: Jimoh sherifdeen <63134009+sheriffjimoh@users.noreply.github.com>
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.

4 participants