Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: server actions search with supabase text search #218

Merged
merged 9 commits into from
May 15, 2024

Conversation

gaboesquivel
Copy link
Member

@gaboesquivel gaboesquivel commented May 15, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new file for application configuration based on environment variables.
    • Added functionality for displaying bot threads and fetching user data.
  • Bug Fixes

    • Adjusted URL handling in SearchInput to update on change instead of form submission.
  • Refactor

    • Replaced Hasura service calls with Supabase in various components.
    • Refactored global store context and provider.
    • Updated thread handling logic to use new data structures.
  • Chores

    • Updated environment variable configurations for consistency.
    • Removed unused imports and components across multiple files.
  • Style

    • Reordered CSS classes in OssLayout for improved styling consistency.

Copy link
Contributor

coderabbitai bot commented May 15, 2024

Walkthrough

The updates to the masterbots.ai project primarily focus on refactoring the codebase to use Supabase instead of Hasura for data fetching and management. This includes changes in environment variables, updating configurations, and modifying components to handle static data or new data structures. Additionally, several components and layout files have been optimized for better performance and maintainability.

Changes

Files/Groups Change Summary
apps/masterbots.ai/.env.example, apps/masterbots.ai/.env.local Updated environment variables for DUB_API_KEY and NEXT_PUBLIC_APP_ENV.
.../app/(browse)/[category]/[threadId]/page.tsx, .../app/(browse)/[category]/page.tsx Modified to render static data and simplified fetching logic, removed async calls.
.../app/(browse)/page.tsx, .../app/actions.ts Replaced service calls, adjusted thread retrieval logic, modified query decoding, and updated data handling.
.../app/auth/callback/route.ts, .../app/b/[id]/page.tsx Refactored user data insertion process, introduced new utility functions, and updated rendering of components.
.../app/layout.tsx, .../app/og/route.tsx, .../app/oss/layout.tsx, .../app/settings/layout.tsx Fetching global data from Supabase, adjusted cookie setting process, updated imports, and reordered CSS classes.
.../app/u/[username]/page.tsx Introduced new file for displaying bot threads and fetching user data with associated threads.
.../components/layout/cmdk.tsx, .../components/layout/header.tsx, .../components/layout/providers.tsx Removed imports for various hooks and components, adjusted rendering logic, and removed SidebarProvider.
.../components/shared/category-tabs/category-link.tsx, .../components/shared/copy-shortlink.tsx Modified category parameter, updated toSlug and shorten function imports.
.../components/shared/search-input.tsx, .../components/shared/thread-accordion.tsx, .../components/shared/thread-dialog.tsx Refactored state management, updated imports, and modified component structure to handle new data structures.
.../components/shared/thread-heading.tsx, .../components/shared/thread-list-accordion.tsx, .../components/shared/thread-list-chat-item.tsx Updated imports, adjusted type declarations, refactored state management, and modified UI elements to use new data structures.
.../hooks/use-global-store.tsx Refactored context and provider for global store, removed unused variables, and updated state initialization.
.../lib/config.ts Introduced new file for setting up and exporting application configuration based on environment variables.
.../services/supabase/client.ts, .../services/supabase/middleware.ts, .../services/supabase/server.ts Replaced direct environment variable access with configuration object for Supabase URL and key.

🐇✨ In the land of code, where bytes do roam,

Supabase reigns, a new data home.

Variables dance, configs align,

Threads and categories, all redefined.

With each commit, the bots grow wise,

A digital world where efficiency lies.

Hooray for progress, in lines of code,

A rabbit's delight, on this winding road! 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@gaboesquivel
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented May 15, 2024

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.

@gaboesquivel gaboesquivel merged commit d96f57b into search May 15, 2024
5 of 8 checks passed
@gaboesquivel gaboesquivel deleted the full-ssr-search-supabase branch May 15, 2024 17:35
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: 13

Out of diff range and nitpick comments (12)
apps/masterbots.ai/hooks/use-chatbot.tsx (1)

Line range hint 7-12: Ensure proper handling of undefined chatbot.

Add a check to handle cases where the chatbot is not found to avoid potential runtime errors.

- const initialMessages = chatbot?.prompts?.map(prompt => ({
-   id: prompt.promptId.toString(),
-   role: 'system' as const,
-   content: prompt.content,
-   createdAt: new Date()
- }))
+ const initialMessages = chatbot?.prompts?.map(prompt => ({
+   id: prompt.promptId.toString(),
+   role: 'system' as const,
+   content: prompt.content,
+   createdAt: new Date()
+ })) || [];
apps/supabase/src/mb.types.ts (1)

6-6: Consider creating a GitHub issue to track the TODO for moving the types to packages/mb-types.

apps/masterbots.ai/app/(browse)/[category]/page.tsx (3)

4-6: Ensure all imports are necessary and used.

Consider removing unused imports to keep the code clean and maintainable.


17-22: Remove commented-out code.

Commented-out code can clutter the codebase. If these lines are no longer needed, consider removing them.


41-41: Remove commented-out code.

Commented-out code can clutter the codebase. If these lines are no longer needed, consider removing them.

apps/masterbots.ai/components/shared/thread-list-accordion.tsx (2)

12-12: Ensure all imports are necessary and used.

Consider removing unused imports to keep the code clean and maintainable.


22-22: Remove commented-out code.

Commented-out code can clutter the codebase. If these lines are no longer needed, consider removing them.

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

3-8: Ensure all imports are necessary and used.

Consider removing unused imports to keep the code clean and maintainable.


23-23: Remove console.log statement.

console.log statements should be removed in production code to avoid unnecessary logging.

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

8-8: Ensure all imports are necessary and used.

Consider removing unused imports to keep the code clean and maintainable.

apps/masterbots.ai/services/supabase/middleware.ts (1)

1-1: Ensure all imports are necessary and used.

Consider removing unused imports to keep the code clean and maintainable.

apps/masterbots.ai/app/settings/layout.tsx (1)

Line range hint 1-1: Ensure all imports are necessary and used.

Consider removing unused imports to keep the code clean and maintainable.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between c5eeabf and d55903f.
Files ignored due to path filters (1)
  • bun.lockb is excluded by !bun.lockb
Files selected for processing (51)
  • apps/masterbots.ai/.env.example (1 hunks)
  • apps/masterbots.ai/.env.local (1 hunks)
  • apps/masterbots.ai/app/(browse)/[category]/[threadId]/page.tsx (1 hunks)
  • apps/masterbots.ai/app/(browse)/[category]/page.tsx (3 hunks)
  • apps/masterbots.ai/app/(browse)/page.tsx (1 hunks)
  • apps/masterbots.ai/app/actions.ts (1 hunks)
  • apps/masterbots.ai/app/auth/callback/route.ts (2 hunks)
  • apps/masterbots.ai/app/b/[id]/page.tsx (1 hunks)
  • apps/masterbots.ai/app/layout.tsx (4 hunks)
  • apps/masterbots.ai/app/og/route.tsx (3 hunks)
  • apps/masterbots.ai/app/oss/layout.tsx (2 hunks)
  • apps/masterbots.ai/app/settings/layout.tsx (3 hunks)
  • apps/masterbots.ai/app/u/[username]/page.tsx (1 hunks)
  • apps/masterbots.ai/components/layout/cmdk.tsx (4 hunks)
  • apps/masterbots.ai/components/layout/header.tsx (1 hunks)
  • apps/masterbots.ai/components/layout/providers.tsx (2 hunks)
  • apps/masterbots.ai/components/shared/category-tabs/category-link.tsx (3 hunks)
  • apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx (1 hunks)
  • apps/masterbots.ai/components/shared/copy-shortlink.tsx (1 hunks)
  • apps/masterbots.ai/components/shared/search-input.tsx (1 hunks)
  • apps/masterbots.ai/components/shared/thread-accordion.tsx (6 hunks)
  • apps/masterbots.ai/components/shared/thread-dialog.tsx (2 hunks)
  • apps/masterbots.ai/components/shared/thread-heading.tsx (5 hunks)
  • apps/masterbots.ai/components/shared/thread-list-accordion.tsx (4 hunks)
  • apps/masterbots.ai/components/shared/thread-list-chat-item.tsx (2 hunks)
  • apps/masterbots.ai/components/shared/thread-list.tsx (2 hunks)
  • apps/masterbots.ai/components/shared/thread-message.tsx (2 hunks)
  • apps/masterbots.ai/hooks/use-chatbot.tsx (1 hunks)
  • apps/masterbots.ai/hooks/use-global-store.tsx (2 hunks)
  • apps/masterbots.ai/lib/config.ts (1 hunks)
  • apps/masterbots.ai/lib/metadata.ts (1 hunks)
  • apps/masterbots.ai/lib/threads.ts (3 hunks)
  • apps/masterbots.ai/package.json (2 hunks)
  • apps/masterbots.ai/services/dub/index.ts (1 hunks)
  • apps/masterbots.ai/services/supabase/client.ts (1 hunks)
  • apps/masterbots.ai/services/supabase/middleware.ts (2 hunks)
  • apps/masterbots.ai/services/supabase/server.ts (1 hunks)
  • apps/supabase/migrations/20240422204025_remote_schema.sql (1 hunks)
  • apps/supabase/migrations/20240422205728_remote_schema.sql (1 hunks)
  • apps/supabase/package.json (1 hunks)
  • apps/supabase/src/index.ts (1 hunks)
  • apps/supabase/src/mb.types.ts (1 hunks)
  • apps/supabase/src/supa.schemas.ts (1 hunks)
  • apps/supabase/src/supa.types.ts (2 hunks)
  • package.json (1 hunks)
  • packages/mb-env/src/env.type.ts (1 hunks)
  • packages/mb-env/src/index.ts (1 hunks)
  • packages/mb-env/src/supabase.env.ts (1 hunks)
  • packages/mb-lib/package.json (1 hunks)
  • packages/mb-lib/src/index.ts (1 hunks)
  • packages/mb-lib/src/platform/platform.ts (1 hunks)
Files skipped from review due to trivial changes (14)
  • apps/masterbots.ai/.env.example
  • apps/masterbots.ai/.env.local
  • apps/masterbots.ai/app/oss/layout.tsx
  • apps/masterbots.ai/components/layout/cmdk.tsx
  • apps/masterbots.ai/components/layout/providers.tsx
  • apps/masterbots.ai/package.json
  • apps/supabase/src/index.ts
  • package.json
  • packages/mb-env/src/env.type.ts
  • packages/mb-env/src/index.ts
  • packages/mb-env/src/supabase.env.ts
  • packages/mb-lib/package.json
  • packages/mb-lib/src/index.ts
  • packages/mb-lib/src/platform/platform.ts
Additional comments not posted (72)
apps/masterbots.ai/lib/config.ts (1)

5-8: LGTM! The configuration object is correctly structured.

apps/supabase/migrations/20240422205728_remote_schema.sql (2)

1-1: Ensure the impact of dropping the unique constraint.

Dropping the unique constraint on the slug column might affect data integrity. Verify that this change won't introduce duplicate slugs in the user table.


9-9: LGTM! Adding the avatar column is straightforward.

apps/masterbots.ai/services/supabase/client.ts (2)

4-4: Ensure the configuration object is correctly imported.

Verify that the appConfig object from @/lib/config contains the correct Supabase URL and key values.


8-9: LGTM! The Supabase client is correctly configured.

apps/masterbots.ai/hooks/use-chatbot.tsx (1)

Line range hint 7-12: LGTM! The hook correctly maps initial messages.

apps/supabase/package.json (2)

10-10: Ensure the Supabase project ID is correct.

Verify that the Supabase project ID bypmbisnogyndsqcztay is correct and matches the intended project.


16-16: LGTM! The dependency camelize-ts is correctly added.

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

18-21: LGTM! The component correctly maps categories to links.

apps/masterbots.ai/components/shared/thread-list-chat-item.tsx (2)

5-5: Import statement for MB looks good.


16-17: Changes in ThreadListChatItem component look good.

Also applies to: 25-25

apps/masterbots.ai/services/supabase/server.ts (1)

Line range hint 6-18: The createSupabaseServerClient function implementation looks good.

apps/supabase/migrations/20240422204025_remote_schema.sql (1)

1-19: The SQL commands for altering the message table look good.

apps/masterbots.ai/app/(browse)/[category]/[threadId]/page.tsx (2)

8-12: Verify if the commented-out async calls are intentional or if there is a plan to replace them.


16-21: Verify if the ThreadAccordion component being commented out is intentional or if there is a plan to replace it.

apps/masterbots.ai/app/b/[id]/page.tsx (2)

17-25: Verify if the AccountDetails component being commented out is intentional or if there is a plan to replace it.


15-27: Updates to the components look good.

apps/masterbots.ai/components/shared/category-tabs/category-link.tsx (1)

3-3: LGTM! The import statement and usage of toSlug are correct.

apps/supabase/src/mb.types.ts (1)

1-32: LGTM! The type definitions are correct and follow the project's conventions.

apps/masterbots.ai/hooks/use-global-store.tsx (1)

5-5: LGTM! The import statement and usage of MB types are correct.

apps/masterbots.ai/components/shared/thread-dialog.tsx (2)

9-9: Import statement for MB looks good.


46-46: The update to use MB.ThreadFull in ThreadDialogProps is appropriate.

apps/masterbots.ai/app/(browse)/page.tsx (2)

5-5: Import statement for decodeQuery looks good.


6-6: Import statement for getThreads and getThreadsLike looks good.

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

7-11: The logic for fetching user data using Supabase looks good.


24-27: The conditional rendering of UserMenu or login button based on the user's authentication status is correctly implemented.

apps/masterbots.ai/app/u/[username]/page.tsx (3)

1-7: Import statements for various components and functions look good.


9-23: The getUserWithThreads function is well-implemented and handles data fetching and conversion appropriately.


25-43: The BotThreadsPage function is well-implemented and correctly handles the rendering of page content based on user data.

apps/masterbots.ai/components/shared/thread-heading.tsx (2)

6-6: Import statement for MB looks good.


60-60: The update to use MB.ThreadFull in ThreadHeadingProps is appropriate.

apps/masterbots.ai/app/auth/callback/route.ts (2)

5-7: Import statements for various functions and libraries look good.


27-39: The GET function is well-implemented and correctly handles the auth code exchange, user data insertion, and cookie setting.

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

33-55: LGTM!

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

12-12: LGTM!

apps/masterbots.ai/services/supabase/middleware.ts (1)

17-18: LGTM!

apps/masterbots.ai/app/settings/layout.tsx (1)

Line range hint 28-63: LGTM!

apps/masterbots.ai/lib/threads.ts (4)

35-42: LGTM!


Line range hint 45-53: LGTM!


73-86: LGTM!


91-101: LGTM!

apps/masterbots.ai/app/layout.tsx (3)

16-23: LGTM!


Line range hint 30-65: LGTM!


67-74: LGTM!

apps/masterbots.ai/app/og/route.tsx (1)

Line range hint 9-75: LGTM!

apps/masterbots.ai/app/actions.ts (4)

21-34: LGTM!


37-46: LGTM!


64-97: LGTM!


99-131: LGTM!

apps/supabase/src/supa.schemas.ts (10)

5-15: LGTM!


17-20: LGTM!


32-37: LGTM!


53-63: LGTM!


89-92: LGTM!


128-134: LGTM!


164-173: LGTM!


197-201: LGTM!


260-267: LGTM!


311-320: LGTM!

apps/supabase/src/supa.types.ts (13)

186-186: Ensure id field is correctly typed as string.


193-193: Ensure id field is correctly typed as string and is optional in Insert type.


200-200: Ensure id field is correctly typed as string and is optional in Update type.


193-193: Ensure role field is correctly typed as string.


200-200: Ensure role field is correctly typed as string.


478-478: Ensure avatar field is correctly typed as string | null.


482-482: Ensure name field is correctly typed as string | null.


488-488: Ensure avatar field is correctly typed as string | null and is optional in Insert type.


492-492: Ensure name field is correctly typed as string | null and is optional in Insert type.


498-498: Ensure avatar field is correctly typed as string | null and is optional in Update type.


502-502: Ensure name field is correctly typed as string | null and is optional in Update type.


Line range hint 526-526: Ensure PublicTableNameOrOptions and TableName generic parameters are correctly typed.


Line range hint 546-546: Ensure PublicTableNameOrOptions and TableName generic parameters are correctly typed.

Comment on lines +10 to +34
export async function shorten(_prevState: any, formData: any) {
try {
const url = formData.get('url')
// Validate form data
if (!url || typeof url !== 'string') {
return {
shortLink: 'Invalid URL'
}
}

const resp = await dub.links.create({
url,
domain: 'mbots.to'
})

console.log('🤌🏻 dub response', resp)
return {
shortLink: ''
}
} catch (error) {
console.log('ERROR', error)

return {
shortLink: 'Invalid data provided'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the return value for a successful response in the shorten function.

-    return {
-      shortLink: ''
-    }
+    return {
+      shortLink: resp.shortLink
+    }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
export async function shorten(_prevState: any, formData: any) {
try {
const url = formData.get('url')
// Validate form data
if (!url || typeof url !== 'string') {
return {
shortLink: 'Invalid URL'
}
}
const resp = await dub.links.create({
url,
domain: 'mbots.to'
})
console.log('🤌🏻 dub response', resp)
return {
shortLink: ''
}
} catch (error) {
console.log('ERROR', error)
return {
shortLink: 'Invalid data provided'
}
export async function shorten(_prevState: any, formData: any) {
try {
const url = formData.get('url')
// Validate form data
if (!url || typeof url !== 'string') {
return {
shortLink: 'Invalid URL'
}
}
const resp = await dub.links.create({
url,
domain: 'mbots.to'
})
console.log('🤌🏻 dub response', resp)
return {
shortLink: resp.shortLink
}
} catch (error) {
console.log('ERROR', error)
return {
shortLink: 'Invalid data provided'
}

import { useAsyncFn } from 'react-use'
import { cn } from '@/lib/utils'
import { shorten } from '@/services/dub'
Copy link
Contributor

Choose a reason for hiding this comment

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

Add error handling for the asynchronous operation.

- const { shortLink } = await shorten({}, formData)
+ const { shortLink } = await shorten({}, formData).catch(error => {
+   console.error('Error shortening the URL:', error)
+   return { shortLink: '' }
+ })

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
import { shorten } from '@/services/dub'
import { shorten } from '@/services/dub'
const { shortLink } = await shorten({}, formData).catch(error => {
console.error('Error shortening the URL:', error)
return { shortLink: '' }
})

@@ -0,0 +1,8 @@
import { validateMbEnv, supabase } from '@repo/mb-env'
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling for environment validation.

Consider adding error handling for the validateMbEnv function to manage invalid environment values gracefully.

- const env = validateMbEnv(process.env.NEXT_PUBLIC_APP_ENV || 'test')
+ let env;
+ try {
+   env = validateMbEnv(process.env.NEXT_PUBLIC_APP_ENV || 'test');
+ } catch (error) {
+   console.error('Invalid environment configuration:', error);
+   env = 'test'; // Fallback to a default environment
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
import { validateMbEnv, supabase } from '@repo/mb-env'
import { validateMbEnv, supabase } from '@repo/mb-env'
let env;
try {
env = validateMbEnv(process.env.NEXT_PUBLIC_APP_ENV || 'test');
} catch (error) {
console.error('Invalid environment configuration:', error);
env = 'test'; // Fallback to a default environment
}

threads.map((thread: Thread) => (
<div className="flex flex-col w-full gap-8 py-5">
{!initialThreads.length ? (
<div>No threads founds</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the typo in the "No threads found" message.

- <div>No threads founds</div>
+ <div>No threads found</div>

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<div>No threads founds</div>
<div>No threads found</div>

}): Promise<Metadata | undefined> {
const thread = await getThread({threadId: params.threadId})
const thread = await getThread({ threadId: params.threadId })
Copy link
Contributor

Choose a reason for hiding this comment

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

Add error handling for the asynchronous operation.

- const thread = await getThread({ threadId: params.threadId })
+ const thread = await getThread({ threadId: params.threadId }).catch(error => {
+   console.error('Error fetching the thread:', error)
+   return null
+ })

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const thread = await getThread({ threadId: params.threadId })
const thread = await getThread({ threadId: params.threadId }).catch(error => {
console.error('Error fetching the thread:', error)
return null
})

query
})

console.log(' ============== THREADS ============== ')
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing the console.log statement for production code.

-  console.log(' ==============  THREADS  ==============  ')

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
console.log(' ============== THREADS ============== ')

Comment on lines +24 to +27
// messagePairs.push({
// userMessage,
// chatGptMessage: [] //chatGptMessages
// })
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented-out code or uncomment and fix it.

Commented-out code can lead to confusion and should be either removed or uncommented and fixed.

}) {
return chat
? `/c/${toSlug(thread.chatbot.name)}/${thread.threadId}`
: `/${toSlug(thread.chatbot.categories[0]?.category.name)}/${thread.threadId}}`
: `/${toSlug(thread.chatbot.categories[0].name)}/${thread.threadId}}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the typo in the URL generation.

- : `/${toSlug(thread.chatbot.categories[0].name)}/${thread.threadId}}`
+ : `/${toSlug(thread.chatbot.categories[0].name)}/${thread.threadId}`

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
: `/${toSlug(thread.chatbot.categories[0].name)}/${thread.threadId}}`
: `/${toSlug(thread.chatbot.categories[0].name)}/${thread.threadId}`

Comment on lines +128 to +134
{/* {p.chatGptMessage.map(message => (
<BrowseChatMessage
chatbot={thread.chatbot}
key={`message-${message.messageId}`}
message={convertMessage(message)}
/>
))}
))} */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented-out code or uncomment and fix it.

Commented-out code can lead to confusion and should be either removed or uncommented and fixed.

Comment on lines +134 to +137
export async function getMessagePairs(threadId: string) {
console.log('get message pairs for', threadId)
return [] as MB.MessagePair[]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement the getMessagePairs function or remove it if not needed.

Placeholder functions should be implemented or removed to avoid confusion.

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.

1 participant