Skip to content

Commit

Permalink
feat: thread dialog ui
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Apr 7, 2024
1 parent 82f91c6 commit d43596e
Show file tree
Hide file tree
Showing 24 changed files with 239 additions and 402 deletions.
4 changes: 2 additions & 2 deletions apps/masterbots.ai/app/(browse)/[category]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BrowseList from '@/components/browse/browse-list'
import BrowseList from '@/components/shared/thread-dialog/thread-list'
import { BrowseCategoryTabs } from '@/components/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/browse/browse-search-input'
import { getBrowseThreads, getCategories } from '@/services/hasura'
Expand All @@ -13,7 +13,7 @@ export default async function BrowseCategoryPage({
const categories = await getCategories()
const categoryId = categories.find(
c =>
c.name.toLowerCase().replace(/\s+/g, '_').replace(/\&/g, 'n') ===
c.name.toLowerCase().replace(/\s+/g, '_').replace(/\&/g, '_') ===
params.category
).categoryId
if (!categoryId) throw new Error('Category id not foud')
Expand Down
2 changes: 1 addition & 1 deletion apps/masterbots.ai/app/(browse)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BrowseList from '@/components/browse/browse-list'
import BrowseList from '@/components/shared/thread-dialog/thread-list'
import { BrowseCategoryTabs } from '@/components/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/browse/browse-search-input'
import { getBrowseThreads, getCategories } from '@/services/hasura'
Expand Down
14 changes: 2 additions & 12 deletions apps/masterbots.ai/app/b/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getChatbot, getBrowseThreads } from '@/services/hasura'
import { botNames } from '@/lib/bots-names'
import BrowseChatbotDetails from '@/components/browse/browse-chatbot-details'
import BrowseSpecificThreadList from '@/components/browse/browse-specific-thread-list'
import BotDetails from '@/components/b/bot-details'

const PAGE_SIZE = 50

Expand All @@ -19,23 +18,14 @@ export default async function BotThreadsPage({
})
if (!chatbot) throw new Error(`Chatbot ${botNames.get(params.id)} not found`)

// session will always be defined
threads = await getBrowseThreads({
chatbotName: botNames.get(params.id),
limit: PAGE_SIZE
})

return (
<div className="w-full py-5">
{chatbot ? <BrowseChatbotDetails chatbot={chatbot} /> : ''}
<BrowseSpecificThreadList
PAGE_SIZE={PAGE_SIZE}
initialThreads={threads}
pageType="bot"
query={{
chatbotName: botNames.get(params.id)
}}
/>
<BotDetails chatbot={chatbot} />
</div>
)
}
9 changes: 0 additions & 9 deletions apps/masterbots.ai/app/u/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getBrowseThreads, getUserInfoFromBrowse } from '@/services/hasura'
import BrowseUserDetails from '@/components/browse/browse-user-details'
import BrowseSpecificThreadList from '@/components/browse/browse-specific-thread-list'

const PAGE_SIZE = 50

Expand All @@ -18,14 +17,6 @@ export default async function BotThreadsPage({
return (
<div className="w-full py-5">
<BrowseUserDetails user={threads[0].user} />
<BrowseSpecificThreadList
PAGE_SIZE={PAGE_SIZE}
initialThreads={threads}
pageType="user"
query={{
slug: params.slug
}}
/>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function BrowseCategoryLink({
href={
category === 'all'
? '/'
: `/${category.name.toLowerCase().replace(/\s+/g, '_').replace(/\&/g, 'n')}`
: `/${category.name.toLowerCase().replace(/\s+/g, '_').replace(/\&/g, '_')}`
}
id={id}
onClick={onClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function BrowseCategoryTabs({
setActiveTab(
categories.filter(
c =>
c.name.toLowerCase().replace(/\s+/g, '_').replace(/\&/g, 'n') ===
c.name.toLowerCase().replace(/\s+/g, '_').replace(/\&/g, '_') ===
initialCategory
)[0]?.categoryId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Chatbot, Message, User } from '@repo/mb-genql'

import React from 'react'
import { cn, createMessagePairs } from '@/lib/utils'
import { ChatAccordion } from '../shared/chat-accordion'
import { ChatAccordion } from '../shared/thread-dialog/thread-accordion'
import type { MessagePair } from './browse-chat-messages'
import { convertMessage } from './browse-chat-messages'
import { BrowseChatMessage } from './browse-chat-message'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type * as AI from 'ai'
import type { Chatbot, Message, User } from '@repo/mb-genql'
import React from 'react'
import { getMessages } from '@/services/hasura'
import BrowseChatbotDetails from './browse-chatbot-details'
import BrowseChatbotDetails from '../b/bot-details'
import { BrowseChatMessageList } from './browse-chat-message-list'

export interface MessagePair {
Expand Down
46 changes: 0 additions & 46 deletions apps/masterbots.ai/components/browse/browse-list-item.tsx

This file was deleted.

77 changes: 0 additions & 77 deletions apps/masterbots.ai/components/browse/browse-list.tsx

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions apps/masterbots.ai/components/c/chat-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React from 'react'
import { ChatMessage } from '@/components/c/chat-message'
import { cn, createMessagePairs } from '@/lib/utils'
import { useThread } from '@/hooks/use-thread'
import { ShortMessage } from '../short-message'
import { ChatAccordion } from '../shared/chat-accordion'
import { ShortMessage } from '../shared/thread-dialog/thread-excerpt'
import { ChatAccordion } from '../shared/thread-dialog/thread-accordion'

export interface ChatList {
messages: Message[]
Expand Down
10 changes: 7 additions & 3 deletions apps/masterbots.ai/components/c/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type UseChatHelpers } from 'ai/react'
import { Chatbot } from '@repo/mb-genql'
import { Button } from '@/components/ui/button'
import { PromptForm } from '@/components/c/prompt-form'
import { ButtonScrollToBottom } from '@/components/button-scroll-to-bottom'
import { ButtonScrollToBottom } from '@/components/c/button-scroll-to-bottom'
import { IconRefresh, IconShare, IconStop } from '@/components/ui/icons'
import { FooterText } from '@/components/layout/footer'
import { ChatShareDialog } from '@/components/c/chat-share-dialog'
Expand Down Expand Up @@ -67,7 +67,9 @@ export function ChatPanel({
{isLoading ? (
<Button
className="bg-background"
onClick={() => { stop(); }}
onClick={() => {
stop()
}}
variant="outline"
>
<IconStop className="mr-2" />
Expand All @@ -83,7 +85,9 @@ export function ChatPanel({
{id && title ? (
<>
<Button
onClick={() => { setShareDialogOpen(true); }}
onClick={() => {
setShareDialogOpen(true)
}}
variant="outline"
>
<IconShare className="mr-2" />
Expand Down
4 changes: 2 additions & 2 deletions apps/masterbots.ai/components/c/thread-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React from 'react'
import { useThread } from '@/hooks/use-thread'
import { useSidebar } from '@/hooks/use-sidebar'
import { cn, sleep } from '@/lib/utils'
import { ShortMessage } from '../short-message'
import { ChatAccordion } from '../shared/chat-accordion'
import { ShortMessage } from '../shared/thread-dialog/thread-excerpt'
import { ChatAccordion } from '../shared/thread-dialog/thread-accordion'
import { ChatList } from './chat-list'

export default function ThreadList({
Expand Down
54 changes: 0 additions & 54 deletions apps/masterbots.ai/components/empty-screen.tsx

This file was deleted.

Loading

0 comments on commit d43596e

Please sign in to comment.