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

chore: january 1st release #345

Merged
merged 131 commits into from
Jan 22, 2025
Merged

chore: january 1st release #345

merged 131 commits into from
Jan 22, 2025

Conversation

AndlerRL
Copy link
Member

@AndlerRL AndlerRL commented Jan 22, 2025

gaboesquivel and others added 30 commits April 9, 2024 06:37
* ✨ Added back button to thread details page

* ⚡️  changed char to svg
* ⚡️ added custom  error page

* ⚡️  clean up
…adata (#215)

* feat: added og api endpoint

* feat: design og image for dark mode

* fix: file formated

* fix: amend  og image to pick current theme color and adapt

* feat: added custom metadata to thread page

* feat: added custom metadata to bot page

* fix: clean up

* fix: move bg to a component

* fix: move og-image design  to a component

* fix: use variable for URL

* fix: to slug func

* ⚡️ Move and clean up UrlToSlug

* fix(masterbots.ai): zod dependecy

* fix: type error

* fix: type error for metadata

* fix: clean and build fix

---------

Co-authored-by: Roberto Lucas <[email protected]>
* fix: og to render first letter of username if there's no avatar

* fix: clean up

* fix: clean up
* feat: create action.ts

* fix: upt share button

* fix: add axios module

* fix: add resend module

* fix: update vercel env config

* fix: split share function

* fix: update share component

* [coderabbitai] style: upt thread-user-actions condition

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Roberto Lucas <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* feat: add get_free_month column to user table

* feat: create referral table

* feat: add is_blocked column to user table

* feat: add pro_user_subscription_id  column to user table

* fix: upt metadata

* fix: update relationship name
* feat: create 'models' table AI models

* fix: add 'model' column to 'thread' table with foreign key constraint

* feat: add model_value into models
* [masterbots.ai]feat:(multimodels-integration)add actions - helpers - routes

* [masterbots.ai]feat:(multimodels-integration)add NextTopLoader

* [masterbots.ai]feat:(multimodels-integration)add NextTopLoaders

* [masterbots.ai]feat:(multimodels-integration)add new chat components

* [masterbots.ai]chore:next version

* [masterbots.ai]feat:(multimodels-integration)update use context

* [masterbots.ai]feat:(multimodels-integration)icons update

* [masterbots.ai]chore:command ui

* [masterbots.ai]refactor:moving chat componets to folder

* [masterbots.ai]feat:env checker

* [masterbots.ai]feat:env guard
* fix-guards + dom warning

* fix-rename env var - vercel name
* fix: update terms

* fix:  building error

* fix: update terms content

* fix: rm the older part at the bottom
* feat: added free card

* feat: added animation to the plan card

* feat: added more plan card and referral code link

* fix: clean up

* wip: wizard

* feat: wizard & modal

* feat: plan Design theme and modal Header and Footer

* feat: plan clean up

* update

* clean up

* fix: rm plan comp on browse page

* fix: wizard clean up

* feat: succes & error modal

* feat: loading comp

* feat: added checkout comp

* feat: set up stripe and context

* wip: implementing subscription

* feat: implementing subscription

* feat: payment reciept

* fix: clean up receipt

* fix: modal not showing & shallow routing

* fix: small fix

* fix: receipt comp

* fix: clean up

* fix: shallow rerouting

* feat: check if user has an active subscription

* fix: coderabbit ob

* fix: coderabbit ob

* fix: coderabbit clean up update

* fix: coderabbit clean up update

* fix: coderabbit clean up update

* fix: clean up

* fix: clean up

* fix: page restructuring and status on the receipt

* fix: revamp receipt and structure

* fix: rm unused file

* fix: clean up

* fix: update & clean up

* fix: update

* fix: rm the svg

* fix: revamp formatSystemPrompts

* fix: revamp msg to formatSystemPrompts

* fix:  update

* fix:  refactor the receipt page

* fix: rm public key

* fix: update

* fix: update

* fix: update

* fix: code refactor for error and loading rendering

* ref: calling  secret keys from server

* ref: receipt page and small fix

* fix: rm file

* fix(impr): subs & flow ux + cleanup

* fix(masterbots.ai): OG not redering   (#224)

* fix: og to render first letter of username if there's no avatar

* fix: clean up

* fix: clean up

* fix(masterbots.ai): share function (#225)

* feat: create action.ts

* fix: upt share button

* fix: add axios module

* fix: add resend module

* fix: update vercel env config

* fix: split share function

* fix: update share component

* [coderabbitai] style: upt thread-user-actions condition

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Roberto Lucas <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* feat(hasura): update user db schema for pro users (#227)

* feat: add get_free_month column to user table

* feat: create referral table

* feat: add is_blocked column to user table

* feat: add pro_user_subscription_id  column to user table

* fix: upt metadata

* fix: update relationship name

* feat(hasura): add Ai Model Tracker To Threads (#229)

* feat: create 'models' table AI models

* fix: add 'model' column to 'thread' table with foreign key constraint

* feat: add model_value into models

* [masterbots.ai] feat: multi AI models integration (#228)

* [masterbots.ai]feat:(multimodels-integration)add actions - helpers - routes

* [masterbots.ai]feat:(multimodels-integration)add NextTopLoader

* [masterbots.ai]feat:(multimodels-integration)add NextTopLoaders

* [masterbots.ai]feat:(multimodels-integration)add new chat components

* [masterbots.ai]chore:next version

* [masterbots.ai]feat:(multimodels-integration)update use context

* [masterbots.ai]feat:(multimodels-integration)icons update

* [masterbots.ai]chore:command ui

* [masterbots.ai]refactor:moving chat componets to folder

* [masterbots.ai]feat:env checker

* [masterbots.ai]feat:env guard

* docs: site map diagram

* feat: set up stripe and context

* wip: implementing subscription

* fix: rm the svg

* fix: replace secret with variable

* fix: chat restructure

* fix(update): chat restructure

* fix(deployment error): can't find an  icon or not exported

* fix: deployment issues

* fix: deployment issues

* fix: deployment issues

* fix: adjust design

* fix: clean up

* fix: clean up

* fix: color var updaye

* [coderabbitai] impr: update apps/masterbots.ai/components/stripe-element.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* [coderabitai] impr: update apps/masterbots.ai/components/succes-content.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: success close button

* fix: bg image for yearly card

* fix: move func to util

* ref: receipt page function to use reac-use

* fix: move depencies to the app

* fix: clean up

* ref: wizard to use radix dialog components

* update

* fix: coderabitai update

---------

Co-authored-by: Roberto Lucas <[email protected]>
Co-authored-by: Nathanael Liu <[email protected]>
Co-authored-by: Roberto Lucas <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Brandon Fernández <[email protected]>
* fix-guards + dom warning

* fix-rename env var - vercel name

* fix-changed PERPLEXITY-LLama model
* fix(UI):varius UI fixes

* fix(UI):varius UI fixes

* fix(UI): Tailwind class corrections, conflict resolution, text alignent to the left

* fix(UI):update
* fix: make the dialog content responsive

* fix: free plan card adjusted

* fix: update

* fix: update receipt styles

* fix: build error

* fix: build error

* fix: build error update

* fix: update

* fix: observation
* feat: add redirection rules

* fix: update all links with new shorten urls

* fix: update all links with new shorten urls

* feat: make folder structure according to sitemap

* [coderabbitai] impr(masterbots.ai): update app/c/page.tsx error handling

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* [coderabbitai] impr(masterbots.ai): update app/c/[category]/[chatbot]/page.tsx error handling

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: build error

* [coderabbitai] impr(masterbots.ai): update app/c/[category]/[chatbot]/page.tsx error handling

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* feat: add sitemap and metagraph

* fix: use original generateMetadata

* fix: update page links

* fix: show only filtered threads on page reload

* fix: build error

---------

Co-authored-by: Roberto Lucas <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* feat: add 'disabled' state to ChatAccordion

* fix: show default question's answer in thread list

* fix: use braces and create explicit statement blocks
* update

* fix: update

* fix: responsiveness

* fix: update

* fix: few clean up

* fix: rm unused image

* fix: rm unused image
* impr(hasura): db tables

* impr(hasura): db tables

* fix(hasura): user permissions

* impr(hasura): sql models enum migration
Bran18 and others added 21 commits December 6, 2024 03:48
* feat: create mb-drizzle package initial structure

* feat:(masterbots.ai) add drizzle endpoint + service

* chore: include database url

* chore: upt mb-drizzle

* feat: refactor drizzle config + generations

* chore: impr migrate

* chore: add working drizzle connection + migrations

* feat: add centralized actions

* chore: add ai review recomendations
* update

* fix: rm category

* update

* fix: pop up on the user threads

* update

* update clean up

* update

* fix: clean up

* fix:  clean up and update

* fix: update

* fix: popup on navigation

* fix: update

* update

* update

* update

* clean up

* update

* merge
* add chatbot-details and browse-details variants

* feat: add bio generation

* feat: chat profile bg

* chore: update bot profile designs

* chore: remove internal padding from cardHeader component

* impr: iconography + border thickness

* fix: numberShortener util fn

---------

Co-authored-by: Roberto Lucas <[email protected]>
* update

* added follow user

* update

* fix: upt hasura metadata databases, public_social_following.yaml

coderabbitai code suggestion.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: upt masterbots.ai lib, utils.ts

coderabbitai suggestion.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: user card

* update

* fix: permission

* update

* fix: added more column for chatbot followee

* fix:foloow chatbot implementation

* update

* threads by following user/bots

* update

* update

* update

* update

* update

* update

* update

* update

---------

Co-authored-by: Roberto Lucas <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* chore: add new icons

* feat: Sonner custom hooks and setup

* feat: use useSonner hook throughout the app

* fix: overflow of the width of the sonner

* chore: add new icons

* feat: Sonner custom hooks and setup

* feat: use useSonner hook throughout the app

* chore: use hook sonner

* refactor: changes according to coderabbitai

* refactor: update use of sonner

* chore:remove icons and use lucide icons

* chore: Using Lucide Icons
* fix: update url

* fix: url update

* update
…d ID (#335)

* update

* fix: make OG image use default

* fix: update

* fix: update

* fix: obs

* fix: update

* fix: added og to browse and chat

* update

* update

* update

* fix: provider types error

* fix: updfate UUID

* fix: update UUID
* chore: document hook useSonner

* refactor: document hook useSonner, according coderabbit
* impr: web search response

* refactor: extracting clickable generation logic

* refactor: extracting clickable generation logic

* fix: webSearch clickable text + reference links

* chore: fix build

* feat:(impr) stable version link to references format step 1

* feat:(impr) stable version link to references format step 2

---------

Co-authored-by: Bran18 <[email protected]>
* refactor: replicate tooltip effect in desktop bot chatbot details

* fix: add guard and removed re-render

* fix: refactor mobile bot chatbot details

* refactor: make chatPannel bigger

* chore:add new bot card design + sidebar hover color

* chore: delete public and private sw + icons

* chore: include public + delete extra actions

* chore: add sidebar bg

* add sidebar new styles + lib fn

* feat: add select bot

* chore: cleaning

* fix: build - removing BotMessageSquareIcon

* fix: types/node version + node min ver req

---------

Co-authored-by: sheriffjimoh <[email protected]>
Co-authored-by: Roberto Lucas <[email protected]>
@AndlerRL AndlerRL self-assigned this Jan 22, 2025
Copy link

sourcery-ai bot commented Jan 22, 2025

Reviewer's Guide by Sourcery

This pull request includes changes to the hasura service to support new features and bug fixes. It also includes changes to the user card component to support following and unfollowing users.

Sequence diagram for user follow/unfollow flow

sequenceDiagram
    participant User
    participant UI
    participant HasuraService
    participant DB

    User->>UI: Click Follow/Unfollow button
    UI->>HasuraService: userFollowOrUnfollow(followerId, followeeId, jwt)
    HasuraService->>DB: Check follow status
    DB-->>HasuraService: Return follow status
    alt Not Following
        HasuraService->>DB: Insert follow relationship
        DB-->>HasuraService: Confirm follow
        HasuraService-->>UI: Return {success: true, follow: true}
    else Already Following
        HasuraService->>DB: Delete follow relationship
        DB-->>HasuraService: Confirm unfollow
        HasuraService-->>UI: Return {success: true, follow: false}
    end
    UI-->>User: Update UI state
Loading

Entity relationship diagram for social following feature

erDiagram
    User ||--o{ SocialFollowing : "has"
    SocialFollowing }o--|| User : "follows"
    SocialFollowing }o--|| Chatbot : "follows"

    User {
        string userId PK
        string username
        string email
        string profilePicture
    }

    SocialFollowing {
        string followerId FK
        string followeeId FK
        number followeeIdChatbot FK
        string createdAt
    }

    Chatbot {
        number chatbotId PK
        string name
        string avatar
    }
Loading

Class diagram for updated Hasura service types

classDiagram
    class HasuraService {
        +getHasuraClient(params: GetHasuraClientParams)
        +getCategories()
        +getCategory(categoryId: number)
        +getChatbots(params: GetChatbotsParams)
        +getThreads(params: GetThreadsParams)
        +getThread(params: GetThreadParams)
        +saveNewMessage(params: SaveNewMessageParams)
        +upsertUser(params: UpsertUserParams)
        +userFollowOrUnfollow(params: FollowParams)
        +chatbotFollowOrUnfollow(params: FollowParams)
    }

    class SocialFollowing {
        +followerId: string
        +followeeId: string
        +followeeIdChatbot: number
        +createdAt: string
    }

    class User {
        +userId: string
        +username: string
        +email: string
        +profilePicture: string
        +followers: SocialFollowing[]
        +following: SocialFollowing[]
    }

    User -- SocialFollowing
    HasuraService -- User
Loading

File-Level Changes

Change Details Files
Added support for following and unfollowing users and chatbots.
  • Added userFollowOrUnfollow function to handle following and unfollowing users.
  • Added chatbotFollowOrUnfollow function to handle following and unfollowing chatbots.
  • Added getFollowStatus function to check if a user is following another user.
  • Added getChatbotFollowStatus function to check if a user is following a chatbot.
  • Added followUser function to follow a user.
  • Added unfollowUser function to unfollow a user.
  • Added followChatbot function to follow a chatbot.
  • Added unfollowChatbot function to unfollow a chatbot.
apps/masterbots.ai/services/hasura/hasura.service.ts
Updated the getBrowseThreads function to support filtering by followed users and chatbots.
  • Added followedUserId parameter to getBrowseThreads function.
  • Modified the query to filter threads based on whether they are from followed users or chatbots.
  • Added logic to interweave followed and organic threads.
apps/masterbots.ai/services/hasura/hasura.service.ts
Updated the getUserBySlug function to include follower and following information.
  • Added followers and following fields to the getUserBySlug query.
apps/masterbots.ai/services/hasura/hasura.service.ts
Updated the getCategories function to include chatbot followers.
  • Added followers field to the chatbot query in getCategories function.
apps/masterbots.ai/services/hasura/hasura.service.ts
Updated the user card component to support following and unfollowing users.
  • Added a follow/unfollow button to the user card.
  • Added logic to handle following and unfollowing users.
  • Added logic to display the number of followers and following.
  • Added logic to update the user card when a user is followed or unfollowed.
apps/masterbots.ai/components/routes/profile/user-card.tsx
Updated the sidebar link component to support different route types.
  • Added logic to determine the route type based on the pathname.
  • Added logic to apply different styles based on the route type.
apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx

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

vercel bot commented Jan 22, 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 22, 2025 1:53am

Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

Overall Comments:

  • Consider adding documentation for the new social features and database schema changes to help other developers understand the system
  • Standardize the styling approach across components - either use direct Tailwind classes or the cn() utility consistently, but not both
Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.


const client = getHasuraClient({ jwt })
try {
const isFollowing = await getFollowStatus(client, followerId, followeeId)
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Consider using a database transaction to prevent race conditions in follow/unfollow operations

The current implementation could lead to inconsistencies if multiple follow/unfollow requests are made simultaneously. Consider wrapping the status check and follow/unfollow operation in a single database transaction.

Suggested implementation:

  const client = getHasuraClient({ jwt })
  try {
    // Start a transaction
    const result = await client.transaction(async (tx) => {
      const isFollowing = await getFollowStatus(tx, followerId, followeeId)
      if (!isFollowing) {
        await followUser(tx, followerId, followeeId)
        return { success: true, follow: true }
      }
      await unfollowUser(tx, followerId, followeeId)
      return { success: true, follow: false }
    })
    return result

This change assumes that:

  1. The Hasura client supports transactions (most GraphQL clients do)
  2. The getFollowStatus, followUser, and unfollowUser functions need to be updated to accept a transaction object instead of the client
  3. You may need to adjust the transaction API syntax based on your specific Hasura client implementation

// eslint-disable-next-line react-hooks/rules-of-hooks

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Add cleanup for loading states in useEffect

Consider adding cleanup in the useEffect to reset loading states if the component unmounts during data fetching.

Suggested implementation:

  // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
  useEffect(() => {
    const abortController = new AbortController();
    let isSubscribed = true;

    const fetchData = async () => {
      setIsLoading(true)
      try {
        if (!activeCategory) {
          await getThreadNum()
        } else {
          await getCategoryName()
        }
        if (isSubscribed) {
          setIsLoading(false)
        }
      } catch (error) {
        if (error.name === 'AbortError') {
          return;
        }
        console.error('Error fetching data:', error)
        if (isSubscribed) {
          setIsLoading(false)
        }
      }
    }

    fetchData()

    return () => {
      isSubscribed = false;
      abortController.abort();
      setIsLoading(false);
    }

The getThreadNum and getCategoryName functions should be updated to accept and use the AbortController's signal in their fetch operations. For example:

const getThreadNum = async (signal?: AbortSignal) => {
  const response = await fetch(url, { signal });
  // ... rest of the function
}

The same should be done for getCategoryName function.

const endIndex = endMarker
? str.indexOf(endMarker, startIndex + startMarker.length)
: str.length
const endIndex = endMarker ? str.indexOf(endMarker, startIndex + startMarker.length) : str.length
Copy link

Choose a reason for hiding this comment

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

issue: Add validation for startIndex before calculating endIndex

When startIndex is -1, the endIndex calculation could lead to incorrect substring extraction. Consider adding a guard clause to handle this case explicitly.

Comment on lines +53 to +54
} catch (error: any) {
throw new Error('Unknown error occurred while fetching thread')
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Consider preserving original error details instead of using a generic message

The generic error message makes debugging harder. Consider including the original error details in the thrown error message: throw new Error(Failed to fetch thread: ${error.message})

Suggested change
} catch (error: any) {
throw new Error('Unknown error occurred while fetching thread')
} catch (error: any) {
throw new Error(`Failed to fetch thread: ${error.message}`)

cancelButton:
'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground'
},
duration: 900000
Copy link

Choose a reason for hiding this comment

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

issue (performance): Toast duration of 15 minutes seems excessive for notifications

Consider using a more standard duration like 3000-5000ms for notifications to avoid them staying on screen too long

import { userFollowOrUnfollow } from '@/services/hasura/hasura.service'
import type { SocialFollowing } from 'mb-genql'
import router from 'next/router'
import { useSonner } from '@/lib/hooks/useSonner'

interface UserCardProps {
user: User | null
loading?: boolean
}
export function UserCard({ user, loading }: UserCardProps) {
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider extracting the profile picture upload and bio generation logic into custom hooks to improve maintainability and testability.

The component has grown complex with multiple responsibilities. Consider extracting the profile picture upload and bio generation logic into custom hooks:

// useProfilePicture.ts
export function useProfilePicture(user: User | null) {
  const [picture, setPicture] = useState(user?.profilePicture)
  const [isUploading, setIsUploading] = useState(false)
  const { uploadFilesCloudinary } = useUploadImagesCloudinary()
  const { updateUserInfo } = useProfile()

  const handleUpload = async (file: File) => {
    setIsUploading(true)
    try {
      const { data, success } = await uploadFilesCloudinary(file)
      if (success) {
        const imageUrl = data?.secure_url as string
        await updateUserInfo(null, null, imageUrl)
        setPicture(imageUrl)
      }
    } finally {
      setIsUploading(false) 
    }
  }

  return { picture, isUploading, handleUpload }
}

// useBioGeneration.ts
export function useBioGeneration(user: User | null) {
  const [bio, setBio] = useState(user?.bio)
  const [isLoading, setIsLoading] = useState(false)
  const { append } = useChat(/* chat config */)

  const generateBio = async () => {
    setIsLoading(true)
    try {
      // Bio generation logic
    } finally {
      setIsLoading(false)
    }
  }

  return { bio, isLoading, generateBio }
}

This separates concerns while maintaining functionality, making the component easier to maintain and test.

@AndlerRL
Copy link
Member Author

@AnoukRImola -- we need to test all these changes to ensure the integrity of this ASAP. Review the recent merged PRs (listed in the changelog) to test them 👀 we need the report to account the progress with the MB development. Merging!

cc - @merivercap

@AndlerRL
Copy link
Member Author

@coderabbitai please elaborate a product update document for the recent changes going to production.

Product Update Example:

What’s shipping 🌟


Tip: Use this space to announce features and releases that impact cross-functional stakeholders in your organization like sales or customer support. Avoid listing out every single bug or feature the team worked on.

For team members who want to learn more about a specific release, you can link inline to existing Notion pages by typing @[page title]. Sharing those additional details like project timelines, statuses, and DRIs helps build transparency and create an environment that encourages knowledge sharing.

Announcements 📣


Tip: This is a good place to announce upcoming large features, status updates, or even significant delays are good ones to call out. Reference other Notion pages to provide more context on these announcements like the examples below.

FYI’s 📌


Tip: The space below should be used for highlighting important team processes or org changes that may have been missed. Don’t forget to link to relevant docs that help drive clarity around why those decisions were made.

Launch calendar

** Tip:** Embed a calendar view of the product roadmap directly in your weekly product update so cross-functional teams can see for themselves when a feature is shipping. Link your launch calendar by typing /linked learn more about linked databases [here](https://www.notion.so/help/guides/using-linked-databases).

↓ Click Launch calendar to create and see other views. Filter by project status, team and more!

[Untitled](https://www.notion.so/14b9d1881dc18198887cfb419549ac8b?pvs=21)

Archive 🗂️


Tip: Save all your previous updates by storing them in a toggle. Type /toggle, add the date as the toggle header and click it to expand. Finally, drag old updates inside the toggle.

  • April 4, 2022

    Add your previous weekly product updates here...

  • March 28, 2022

    Add your previous weekly product updates here...

  • March 21, 2022

    Add your previous weekly product updates here...

⚠️ **Warning:** Deleting this callout block will delete all references of the pages in the toggle below. ****We use the toggle to store placeholder docs that are used in this template. The placeholder docs don’t contain any valuable content and are used to show the templates functionality.

Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Tip

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

@AndlerRL Here's the product update document for the January 1st release:

What's shipping 🌟

  • Enhanced User Onboarding Experience! We've introduced new bot profile variants with an improved onboarding flow, making it easier for new users to discover and interact with chatbots. The new system includes mobile-optimized views and responsive layouts for a seamless experience across all devices.

  • Improved Notification System We've upgraded our notification system to Sonner, providing a more polished and consistent way to display system messages, alerts, and feedback to users. This enhancement brings better visibility and improved user interaction feedback throughout the platform.

  • Dynamic Open Graph Image Generation Our sharing capabilities have been enhanced with a new dynamic OG image generation system. This improvement means better social media previews when sharing content from the platform, with or without specific thread contexts.

Announcements 📣

  • Pre-launch UI/UX Refinements We've implemented significant improvements to the platform's interface, including:

    • Enhanced mobile responsiveness for chat and browse sections
    • Refined navigation experience in header and sidebar
    • Improved route-based UI customization for better context awareness
  • Backend Stability Improvements We've resolved several backend issues related to thread management and user permissions, ensuring a more reliable platform experience.

FYI's 📌

  • URL Structure Standardization We've implemented a standardized URL building system across the platform, ensuring consistent and reliable navigation patterns.

  • Documentation Updates Our development documentation has been enhanced with detailed JSDoc comments for key components, improving maintainability and developer experience.

Launch calendar

  • January 1st, 2025: Platform-wide release including all mentioned features and improvements
🔗 Analysis chain
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Fetch details for each PR in the changelog
for pr in 324 330 331 334 335 336 341 343; do
  echo "=== PR #$pr ==="
  gh pr view $pr --repo bitcashorg/masterbots
  echo
done

Length of output: 14405

@AndlerRL AndlerRL merged commit 7a3ca51 into main Jan 22, 2025
2 checks passed
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.

10 participants