-
Notifications
You must be signed in to change notification settings - Fork 1
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 #217
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis update primarily refactors the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai review |
Actions PerformedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 15
Out of diff range and nitpick comments (13)
apps/masterbots.ai/services/supabase/middleware.ts (2)
1-1
: Consider adding a comment to explain the purpose of theappConfig
import for better code clarity.
Line range hint
35-42
: The functionfindNextAssistantMessage
could be simplified by directly returning the cleaned message if the role is 'assistant'.const findNextAssistantMessage = ( messages: AI.Message[], startIndex: number ) => { if (messages[startIndex].role === 'assistant') { return { ...messages[startIndex], content: cleanPrompt(messages[startIndex].content) } as AI.Message } return null }apps/masterbots.ai/lib/threads.ts (1)
Line range hint
47-54
: Add a comment explaining the purpose of thecleanPrompt
function for better code clarity.+ // Extracts the part of the string after the specified marker. export function cleanPrompt(str: string) { const marker = ']. Then answer this question:' const index = str.indexOf(marker) let extracted = '' if (index !== -1) { extracted = str.substring(index + marker.length) } // console.log('cleanPrompt', str, extracted, index) return extracted || str }
apps/masterbots.ai/app/og/route.tsx (1)
Line range hint
7-16
: Add error handling for the case wherethreadId
is not provided orgetThread
fails to fetch the thread.export async function GET(req: NextRequest) { try { const { searchParams } = req.nextUrl const threadId = searchParams.get('threadId') if (!threadId) { throw new Error('Missing threadId') } const thread = await getThread({ threadId }) if (!thread) { throw new Error('Thread not found') }apps/masterbots.ai/app/actions.ts (9)
29-29
: Removeconsole.log
statement.Replace
console.log('🤌🏻', count);
with a proper logging mechanism or remove it before deploying to production.
44-44
: Removeconsole.log
statement.Replace
console.log('🤌🏻', error, count, data?.length);
with a proper logging mechanism or remove it before deploying to production.
65-65
: Removeconsole.log
statement.Replace
console.log('🧑🏻💻 get threads like', query);
with a proper logging mechanism or remove it before deploying to production.
81-81
: Removeconsole.log
statement.Replace
console.log('🙌🏻 threadIds', threadIds.length);
with a proper logging mechanism or remove it before deploying to production.
92-92
: Removeconsole.log
statement.Replace
console.log('🤌🏻', error, count, data?.length);
with a proper logging mechanism or remove it before deploying to production.
100-100
: Removeconsole.log
statement.Replace
console.log('🧑🏻💻 search threads for', query);
with a proper logging mechanism or remove it before deploying to production.
113-113
: Removeconsole.log
statement.Replace
console.log(threadIds.data?.length, threadIds?.data);
with a proper logging mechanism or remove it before deploying to production.
127-127
: Removeconsole.log
statement.Replace
console.log('🤌🏻', error, count, data?.length);
with a proper logging mechanism or remove it before deploying to production.
135-135
: Removeconsole.log
statement.Replace
console.log('get message pairs for', threadId);
with a proper logging mechanism or remove it before deploying to production.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
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 (12)
- apps/masterbots.ai/.env.example
- apps/masterbots.ai/.env.local
- apps/masterbots.ai/app/b/[id]/page.tsx
- apps/masterbots.ai/app/settings/layout.tsx
- apps/supabase/package.json
- apps/supabase/src/index.ts
- package.json
- 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 (92)
apps/masterbots.ai/lib/config.ts (2)
1-1
: Imports look good.
3-8
: Environment validation and configuration setup look good.apps/supabase/migrations/20240422205728_remote_schema.sql (3)
1-1
: Dropping the unique constraint on theslug
column might affect data integrity. Ensure this change is intentional and that the application logic accounts for non-unique slugs.
3-3
: Dropping the index on theslug
column might impact query performance. Ensure this change is intentional and that the application logic accounts for the potential performance impact.
5-9
: Schema update commands look good. Ensure that the application logic is updated to reflect these changes.packages/mb-env/src/env.type.ts (2)
1-1
: Definition of valid environments looks good.
Line range hint
3-10
: ThevalidateMbEnv
function looks good and correctly validates the environment.apps/masterbots.ai/services/supabase/client.ts (3)
1-4
: Imports look good.
6-9
: ThegetSupabaseBrowserClient
function looks good and correctly sets up the Supabase client for the browser.
Line range hint
11-13
: TheuseSupabaseClient
hook looks good and correctly memoizes the Supabase client.apps/masterbots.ai/hooks/use-chatbot.tsx (2)
Line range hint
1-1
: Import looks good.
Line range hint
3-14
: TheuseChatbot
hook looks good and correctly retrieves the chatbot data and initial messages.apps/masterbots.ai/components/layout/providers.tsx (2)
Line range hint
3-10
: Imports look good.
12-18
: TheProviders
component looks good and correctly sets up the providers.apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx (2)
3-3
: Import statement looks good.
10-18
: Changes to theCategoryTabs
component look good.apps/masterbots.ai/components/shared/thread-list-chat-item.tsx (2)
5-5
: Import statement looks good.
16-25
: Changes to theThreadListChatItem
component look good.apps/masterbots.ai/services/dub/index.ts (1)
1-4
: Import statement looks good.apps/masterbots.ai/services/supabase/server.ts (2)
6-6
: Import statement looks good.
Line range hint
12-23
: Function implementation looks good.apps/supabase/migrations/20240422204025_remote_schema.sql (1)
1-21
: SQL commands look good.apps/masterbots.ai/app/(browse)/[category]/[threadId]/page.tsx (1)
8-21
: Verify if the commented-out code is intentional.Is the commented-out data fetching logic intentional, or should it be removed or replaced with new logic?
apps/masterbots.ai/components/shared/copy-shortlink.tsx (1)
6-6
: Ensure that theshorten
function from@/services/dub
is correctly implemented and handles errors appropriately.Verification successful
The
shorten
function from@/services/dub
is correctly implemented and handles errors appropriately.
- The function validates the URL from the form data.
- It attempts to create a short link using
dub.links.create
.- It handles errors by logging them and returning an appropriate message.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the `shorten` function. # Test: Search for the function implementation. Expect: Correct implementation with error handling. rg --type ts --pattern 'export async function shorten'Length of output: 468
Script:
#!/bin/bash # Description: Verify the implementation of the `shorten` function. # Test: Search for the function implementation. Expect: Correct implementation with error handling. rg 'export async function shorten' --type tsLength of output: 151
Script:
#!/bin/bash # Description: Extract the full implementation of the `shorten` function. # Test: Extract the function implementation. Expect: Full function code for review. rg -A 20 'export async function shorten' apps/masterbots.ai/services/dub/index.tsLength of output: 543
Script:
#!/bin/bash # Description: Extract the full implementation of the `shorten` function. # Test: Extract the function implementation. Expect: Full function code for review. rg -A 40 'export async function shorten' apps/masterbots.ai/services/dub/index.tsLength of output: 610
apps/masterbots.ai/components/shared/category-tabs/category-link.tsx (2)
3-3
: Ensure that thetoSlug
function from@/lib/url-params
is correctly implemented and handles edge cases appropriately.
9-9
: The change in thecategory
prop type tostring | 'all'
is appropriate and simplifies the component logic.apps/masterbots.ai/components/shared/thread-list.tsx (2)
1-1
: Ensure that theMB
namespace from@repo/supabase
is correctly implemented and includes theThreadFull
type.Verification successful
Verification of
MB
Namespace andThreadFull
TypeThe
MB
namespace is correctly implemented inapps/supabase/src/mb.types.ts
, and theThreadFull
type is used extensively across multiple files in the codebase.
apps/supabase/src/mb.types.ts
:export namespace MB
apps/masterbots.ai/lib/threads.ts
:thread: MB.ThreadFull
apps/masterbots.ai/components/shared/thread-accordion.tsx
:thread: MB.ThreadFull
apps/masterbots.ai/components/shared/thread-list-chat-item.tsx
:thread: MB.ThreadFull
apps/masterbots.ai/components/shared/thread-list-accordion.tsx
:thread: MB.ThreadFull
apps/masterbots.ai/components/shared/thread-dialog.tsx
:thread: MB.ThreadFull
apps/masterbots.ai/components/shared/thread-heading.tsx
:thread: MB.ThreadFull
apps/masterbots.ai/components/shared/thread-list.tsx
:initialThreads: MB.ThreadFull[]
apps/masterbots.ai/app/actions.ts
:Promise<MB.ThreadFull[]>
,Promise<MB.ThreadFull | null>
,as unknown as MB.ThreadFull
The import statement and the prop type change in
thread-list.tsx
are appropriate and correctly implemented.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the `MB` namespace. # Test: Search for the `MB` namespace implementation. Expect: Correct implementation with `ThreadFull` type. rg --type ts --pattern 'export namespace MB'Length of output: 458
Script:
#!/bin/bash # Description: Verify the implementation of the `MB` namespace and the `ThreadFull` type. # Test: Search for the `MB` namespace implementation. rg 'export namespace MB' # Test: Search for the `ThreadFull` type within the `MB` namespace. rg 'MB.ThreadFull'Length of output: 1022
40-43
: The change in theThreadListProps
interface to useMB.ThreadFull[]
forinitialThreads
is appropriate and aligns with the updated data structure.apps/supabase/src/mb.types.ts (1)
8-31
: The new and updated type definitions in theMB
namespace are well-structured and align with the overall data structure.apps/masterbots.ai/lib/metadata.ts (2)
3-3
: Ensure that thegetThread
function from@/app/actions
is correctly implemented and handles errors appropriately.
6-43
: The metadata generation logic in thegenerateMbMetadata
function is well-structured and correctly uses properties from thethread
object.apps/masterbots.ai/hooks/use-global-store.tsx (3)
5-5
: Ensure that theMB
namespace from@repo/supabase
is correctly implemented and includes theChatbotWithPrompts
andCategory
types.Verification successful
Verification of
MB
Namespace and TypesThe
MB
namespace is correctly implemented inapps/supabase/src/mb.types.ts
. Additionally, theChatbotWithPrompts
andCategory
types are used in theapps/masterbots.ai/hooks/use-global-store.tsx
file, confirming their presence and usage.
MB
namespace found in:apps/supabase/src/mb.types.ts
MB.ChatbotWithPrompts
type used in:apps/masterbots.ai/hooks/use-global-store.tsx
MB.Category
type used in:apps/masterbots.ai/hooks/use-global-store.tsx
,apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the `MB` namespace. # Test: Search for the `MB` namespace implementation. Expect: Correct implementation with `ChatbotWithPrompts` and `Category` types. rg --type ts --pattern 'export namespace MB'Length of output: 458
Script:
#!/bin/bash # Description: Verify the implementation of the `MB` namespace. # Test: Search for the `MB` namespace implementation. Expect: Correct implementation with `ChatbotWithPrompts` and `Category` types. rg 'export namespace MB' --type ts # Test: Search for the `ChatbotWithPrompts` type within the `MB` namespace. rg 'MB\.ChatbotWithPrompts' --type ts # Test: Search for the `Category` type within the `MB` namespace. rg 'MB\.Category' --type tsLength of output: 567
21-27
: TheGlobalStoreProvider
component correctly initializes the state with the provideduser
,chatbots
, andcategories
props.
40-41
: The change in theGlobalStoreProviderProps
andGlobalStoreContextValue
types to useMB.ChatbotWithPrompts[]
andMB.Category[]
is appropriate and aligns with the updated data structure.apps/masterbots.ai/components/shared/thread-dialog.tsx (3)
9-10
: Import statement forMB
namespace.The import statement for the
MB
namespace from@repo/supabase
is correctly added.
22-23
: EnsurefirstUserMessage
andfirstAssistantMessage
are defined.Please verify that
thread.firstUserMessage
andthread.firstAssistantMessage
are always defined in theMB.ThreadFull
type to avoid potential runtime errors.
46-48
: ThreadDialogProps interface definition.The
ThreadDialogProps
interface correctly extendsDialogProps
and includes thethread
prop of typeMB.ThreadFull
.apps/masterbots.ai/app/(browse)/page.tsx (2)
5-6
: Import statements fordecodeQuery
,getThreads
, andgetThreadsLike
.The import statements for
decodeQuery
from@/lib/url-params
andgetThreads
,getThreadsLike
from../actions
are correctly added.
28-30
: Thread rendering logic.The logic for rendering threads using the
ThreadList
component and displaying aCard
component when no threads are found is correct.apps/masterbots.ai/app/oss/layout.tsx (1)
5-6
: Layout structure.The layout structure for the
OssLayout
component is correctly defined, with a sidebar for navigation links and a main content area for children components.apps/masterbots.ai/components/layout/header.tsx (2)
24-27
: User authentication logic.The user authentication logic correctly checks if the user is authenticated and renders the
UserMenu
component if authenticated, or a login button if not.
Line range hint
38-42
: HeaderLink component.The
HeaderLink
component is correctly defined and used to render navigation links in the header.apps/masterbots.ai/components/layout/cmdk.tsx (2)
3-3
: Import statement foruseState
.The import statement for
useState
is correctly added.
45-48
: Command items.The command items for
Search
,Profile
,Billing
, andSettings
are correctly defined and used within theCommandGroup
.apps/masterbots.ai/app/u/[username]/page.tsx (4)
1-8
: Import statements.The import statements for various components and utilities are correctly added.
9-23
: getUserWithThreads function.The
getUserWithThreads
function is correctly defined, fetching user data and threads from Supabase and converting the data to camel case.
25-43
: BotThreadsPage component.The
BotThreadsPage
component is correctly defined, fetching user data and threads based on the username and rendering them using various components.
46-48
: BotPageParams type.The
BotPageParams
type correctly defines the structure for theparams
prop.apps/masterbots.ai/components/shared/thread-heading.tsx (3)
5-6
: Imports look good and are necessary for the new functionality.
22-22
: The changes to theThreadHeading
component are consistent with the new type definitions and maintain the component structure.
60-60
: TheThreadHeadingProps
interface changes align with the new type definitions and ensure type safety.apps/masterbots.ai/app/auth/callback/route.ts (4)
5-7
: Imports look good and are necessary for the new functionality.
27-35
: The changes to the user data insertion logic ensure that user data is correctly inserted into the database.
39-40
: The error handling for database insertion is appropriate and ensures that any errors are correctly managed.
46-52
: The changes to cookie handling ensure that user profile information is correctly set in cookies.apps/masterbots.ai/app/(browse)/[category]/page.tsx (4)
4-6
: Imports look good and are necessary for the new functionality.
28-28
: The data fetching logic for threads is correctly implemented.
41-43
: The changes to component props ensure that the correct data is passed to theThreadList
component.
Line range hint
53-53
: The changes to theCategoryPageProps
interface ensure that thesearchParams
property is correctly typed.apps/masterbots.ai/components/shared/thread-list-accordion.tsx (4)
12-12
: Imports look good and are necessary for the new functionality.
18-18
: The changes to theThreadListAccordion
component are consistent with the new type definitions and maintain the component structure.
49-49
: TheinitialMessagePairs
prop is correctly set to an empty array.
59-59
: TheThreadListAccordionProps
interface changes align with the new type definitions and ensure type safety.apps/masterbots.ai/components/shared/search-input.tsx (4)
3-8
: Imports look good and are necessary for the new functionality.
17-30
: TheupdateUrl
function correctly handles URL updates and debouncing.
46-47
: The event handling for the search input is correctly implemented.
51-51
: The input field properties are correctly set.apps/masterbots.ai/components/shared/thread-message.tsx (3)
8-8
: Imports look good and are necessary for the new functionality.
12-12
: TheChatMessageProps
interface changes align with the new type definitions and ensure type safety.
24-24
: The changes to theBrowseChatMessage
component are consistent with the new type definitions and maintain the component structure.apps/masterbots.ai/lib/threads.ts (1)
35-42
: Duplicate review comment forfindNextAssistantMessage
.apps/masterbots.ai/package.json (2)
Line range hint
42-72
: Ensure that the new dependenciescamelize-ts
,ts-case-convert
,use-debounce
, and@repo/supabase
are necessary and correctly versioned.
Line range hint
5-15
: The scripts section looks good and follows best practices.apps/masterbots.ai/app/layout.tsx (1)
Line range hint
30-65
: TheRootLayout
component is well-structured and follows best practices.apps/supabase/src/supa.schemas.ts (12)
5-15
: LGTM!
17-20
: LGTM!
22-25
: LGTM!
27-30
: LGTM!
32-37
: LGTM!
39-44
: LGTM!
46-51
: LGTM!
53-63
: LGTM!
65-75
: LGTM!
77-87
: LGTM!
89-92
: LGTM!
94-97
: LGTM!apps/supabase/src/supa.types.ts (6)
Line range hint
1-5
: LGTM!
Line range hint
7-10
: LGTM!
Line range hint
12-14
: LGTM!
Line range hint
16-18
: LGTM!
Line range hint
20-22
: LGTM!
Line range hint
24-26
: LGTM!
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' | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the short link to the return value for successful creation.
- 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.
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' | |
} | |
} |
// console.log({ query, limit, page }) | ||
const threads = await (query? getThreadsLike({ query }) : getThreads()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out console log.
Consider removing the commented-out console log statement to keep the code clean.
- // console.log({ query, limit, page })
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.
// console.log({ query, limit, page }) | |
const threads = await (query? getThreadsLike({ query }) : getThreads()) | |
const threads = await (query? getThreadsLike({ query }) : getThreads()) |
query | ||
}) | ||
|
||
console.log(' ============== THREADS ============== ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console log statement.
Consider removing the console log statement to avoid unnecessary logging in production.
- 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.
console.log(' ============== THREADS ============== ') |
// const categories = await getCategories() | ||
// console.log(params.category) | ||
// const categoryId = categories.find( | ||
// c => toSlug(c.name) === params.category | ||
// )?.categoryId | ||
// if (!categoryId) throw new Error('Category not foud') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commented-out code should be removed if it is no longer needed to keep the codebase clean.
- // const categories = await getCategories()
- // console.log(params.category)
- // const categoryId = categories.find(
- // c => toSlug(c.name) === params.category
- // )?.categoryId
- // if (!categoryId) throw new Error('Category not foud')
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.
// const categories = await getCategories() | |
// console.log(params.category) | |
// const categoryId = categories.find( | |
// c => toSlug(c.name) === params.category | |
// )?.categoryId | |
// if (!categoryId) throw new Error('Category not foud') |
...getFirstMessages(threadData.message), | ||
chatbot: { | ||
...omit(threadData.chatbot, 'chatbot_category'), | ||
catogories: threadData.chatbot.chatbot_category.category |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in property name.
- catogories: threadData.chatbot.chatbot_category.category
+ categories: threadData.chatbot.chatbot_category.category
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.
catogories: threadData.chatbot.chatbot_category.category | |
categories: threadData.chatbot.chatbot_category.category |
@@ -33,7 +33,7 @@ export function ThreadAccordion({ | |||
const { data: pairs, error } = useQuery({ | |||
queryKey: [`messages-${thread.threadId}`], | |||
queryFn: () => getMessagePairs(thread.threadId), | |||
initialData: initialMessagePairs, | |||
initialData: [], //initialMessagePairs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using initialMessagePairs
instead of an empty array for initialData
to leverage server-side fetched data.
const { data: pairs, error } = useQuery({
queryKey: [`messages-${thread.threadId}`],
queryFn: () => getMessagePairs(thread.threadId),
- initialData: [], //initialMessagePairs,
+ initialData: initialMessagePairs,
networkMode: 'always',
refetchOnMount: true,
enabled: clientFetch
})
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.
initialData: [], //initialMessagePairs, | |
const { data: pairs, error } = useQuery({ | |
queryKey: [`messages-${thread.threadId}`], | |
queryFn: () => getMessagePairs(thread.threadId), | |
initialData: initialMessagePairs, | |
networkMode: 'always', | |
refetchOnMount: true, | |
enabled: clientFetch | |
}) |
<div className="pl-12 md:text-lg"> | ||
{p.userMessage.content} | ||
</div> | ||
<div className="pl-12 md:text-lg">{p.question.content}</div> |
There was a problem hiding this comment.
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 class name pl-12
to pl-2
for better alignment.
<div className="pl-2 md:text-lg">{p.question.content}</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.
<div className="pl-12 md:text-lg">{p.question.content}</div> | |
<div className="pl-2 md:text-lg">{p.question.content}</div> |
<div>content</div> | ||
{/* {p.chatGptMessage.map(message => ( | ||
<BrowseChatMessage | ||
chatbot={thread.chatbot} | ||
key={`message-${message.messageId}`} | ||
message={convertMessage(message)} | ||
/> | ||
))} | ||
))} */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncomment the code to display the chat messages if it is intended to be used.
Do you want me to uncomment the code to display the chat messages or open a GitHub issue to track this task?
<div className="flex flex-col w-full gap-8 py-5"> | ||
{!initialThreads.length ? ( | ||
<div>No threads founds</div> | ||
) : ( | ||
initialThreads.map(thread => ( | ||
<ThreadComponent | ||
chat={chat} | ||
defaultOpen={false} // we can have one open by default | ||
key={thread.threadId} | ||
thread={thread} | ||
/> | ||
))} | ||
<div ref={loadMoreRef}> | ||
{isFetchingNextPage ? 'loading more results ...' : ''} | ||
</div> | ||
)) | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ThreadList
component correctly handles the display of threads based on the context. However, there is a minor typo in the message displayed when no threads are found.
- <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.
<div className="flex flex-col w-full gap-8 py-5"> | |
{!initialThreads.length ? ( | |
<div>No threads founds</div> | |
) : ( | |
initialThreads.map(thread => ( | |
<ThreadComponent | |
chat={chat} | |
defaultOpen={false} // we can have one open by default | |
key={thread.threadId} | |
thread={thread} | |
/> | |
))} | |
<div ref={loadMoreRef}> | |
{isFetchingNextPage ? 'loading more results ...' : ''} | |
</div> | |
)) | |
)} | |
<div className="flex flex-col w-full gap-8 py-5"> | |
{!initialThreads.length ? ( | |
<div>No threads found</div> | |
) : ( | |
initialThreads.map(thread => ( | |
<ThreadComponent | |
chat={chat} | |
defaultOpen={false} // we can have one open by default | |
key={thread.threadId} | |
thread={thread} | |
/> | |
)) | |
)} |
import { Tables } from './supa.types'; | ||
import type * as AI from 'ai' | ||
|
||
// TODO: move this to packages/mb-types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the type definitions to packages/mb-types
as indicated by the TODO comment for better modularity and maintainability.
Summary by CodeRabbit
New Features
DUB_API_KEY
for enhanced API integrations.BotThreadsPage
for displaying user-specific threads.Bug Fixes
SearchInput
component with debouncing.Refactor
Chores
Style
thread-heading.tsx
andsettings/layout.tsx
.Documentation
supabase
directory.