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: thread ui dialog with ssr #104

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions apps/masterbots.ai/app/(browse)/[category]/[threadId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { getThread } from '@/services/hasura'
import { BrowseThread } from '@/components/browse/browse-thread'
import { getMessagePairs, getThread } from '@/services/hasura'

import type { ChatPageProps } from '@/app/c/[chatbot]/[threadId]/page'
import Shortlink from '@/components/browse/shortlink-button'
import Shortlink from '@/components/routes/browse/shortlink-button'
import { ThreadAccordion } from '@/components/shared/thread-accordion'

export default async function ThreadLandingPage({ params }: ChatPageProps) {
const thread = await getThread({
threadId: params.threadId
})
return (
<>
<div>
<Shortlink />
</div>
const initialMessagePairs = await getMessagePairs(thread.threadId)

<BrowseThread thread={thread} />
</>
return (
<div className="container">
<Shortlink />
<ThreadAccordion
thread={thread}
initialMessagePairs={initialMessagePairs}
/>
</div>
)
}
8 changes: 4 additions & 4 deletions apps/masterbots.ai/app/(browse)/[category]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BrowseList from '@/components/browse/browse-list'
import { BrowseCategoryTabs } from '@/components/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/browse/browse-search-input'
import BrowseList from '@/components/shared/thread-list'
import { BrowseCategoryTabs } from '@/components/routes/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
import { getBrowseThreads, getCategories } from '@/services/hasura'

export const revalidate = 3600 // revalidate the data at most every hour
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
6 changes: 3 additions & 3 deletions apps/masterbots.ai/app/(browse)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BrowseList from '@/components/browse/browse-list'
import { BrowseCategoryTabs } from '@/components/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/browse/browse-search-input'
import BrowseList from '@/components/shared/thread-list'
import { BrowseCategoryTabs } from '@/components/routes/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
import { getBrowseThreads, getCategories } from '@/services/hasura'

export const revalidate = 3600 // revalidate the data at most every hour
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/routes/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>
)
}
2 changes: 1 addition & 1 deletion apps/masterbots.ai/app/c/[chatbot]/[threadId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { redirect } from 'next/navigation'
import type { Message } from 'ai/react'
import { isTokenExpired } from '@repo/mb-lib'
import { cookies } from 'next/headers'
import { Chat } from '@/components/c/chat'
import { Chat } from '@/components/routes/c/chat'
import { getThread } from '@/services/hasura'
import { getUserProfile } from '@/services/supabase'

Expand Down
4 changes: 2 additions & 2 deletions apps/masterbots.ai/app/c/[chatbot]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { isTokenExpired } from '@repo/mb-lib'
import { nanoid } from 'nanoid'
import { cookies } from 'next/headers'
import { redirect } from 'next/navigation'
import { ChatChatbot } from '@/components/c/chat-chatbot'
import ThreadPanel from '@/components/c/thread-panel'
import { ChatChatbot } from '@/components/routes/c/chat-chatbot'
import ThreadPanel from '@/components/routes/c/thread-panel'
import { botNames } from '@/lib/bots-names'
import { getChatbot, getThreads } from '@/services/hasura'
import { getUserProfile } from '@/services/supabase'
Expand Down
4 changes: 2 additions & 2 deletions apps/masterbots.ai/app/c/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChatLayoutSection } from '@/components/c/chat-layout-section'
import { ResponsiveSidebar } from '@/components/c/sidebar/sidebar-responsive'
import { ChatLayoutSection } from '@/components/routes/c/chat-layout-section'
import { ResponsiveSidebar } from '@/components/routes/c/sidebar/sidebar-responsive'
import FooterCT from '@/components/layout/footer-ct'

interface ChatLayoutProps {
Expand Down
4 changes: 2 additions & 2 deletions apps/masterbots.ai/app/c/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isTokenExpired } from '@repo/mb-lib'
import { redirect } from 'next/navigation'
import { cookies } from 'next/headers'
import ChatThreadListPanel from '@/components/c/chat-thread-list-panel'
import ThreadPanel from '@/components/c/thread-panel'
import ChatThreadListPanel from '@/components/routes/c/chat-thread-list-panel'
import ThreadPanel from '@/components/routes/c/thread-panel'
import { getThreads } from '@/services/hasura'
import { getUserProfile } from '@/services/supabase'

Expand Down
23 changes: 8 additions & 15 deletions apps/masterbots.ai/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,21 @@
}

.scrollbar {
overflow: auto;
overflow: auto;
}

.scrollbar::-webkit-scrollbar {
width: 4px;
height: 4px;
width: 1px;
height: 1px;
}
.scrollbar::-webkit-scrollbar-track,
.scrollbar::-webkit-scrollbar-corner {
background: var(--scrollbar-track) !important;
background: var(--scrollbar-track);
}
.scrollbar::-webkit-scrollbar-thumb {
background: var(--scrollbar-thumb);
border-radius: 2px;
}
/* .scrollbar::-webkit-scrollbar-thumb:hover {
background: var(--scrollbar-thumb-hover);
} */

@media screen and (min-width: 1024px) {
.scrollbar::-webkit-scrollbar {
width: 8px;
height: 8px;
}
}


.scrollbar.small-thumb::-webkit-scrollbar-thumb {
border-left: 300px solid #f9f9fa;
Expand All @@ -151,3 +140,7 @@
overflow: visible;
text-overflow: clip;
}

.hide-buttons > button {
display: none;
}
2 changes: 1 addition & 1 deletion apps/masterbots.ai/app/p/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Suspense } from 'react'
import { WorkEarlyAccessForm } from '@/components/p/early-access-from'
import { WorkEarlyAccessForm } from '@/components/routes/p/early-access-from'

export default function WorkPage() {
return (
Expand Down
11 changes: 1 addition & 10 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'
import BrowseUserDetails from '@/components/routes/browse/browse-user-details'

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>
)
}
79 changes: 0 additions & 79 deletions apps/masterbots.ai/components/browse/browse-chat-message-list.tsx

This file was deleted.

58 changes: 0 additions & 58 deletions apps/masterbots.ai/components/browse/browse-chat-messages.tsx

This file was deleted.

Loading
Loading