Skip to content

Commit 84f9588

Browse files
AndlerRLBran18sheriffjimoh
authored
[masterbots.ai] chore(impr): rm unused imports, upt ui/auth, memoize md (#428)
* fix: change toggler wording + util hook (#424) * impr: makes threads open on profile page and profile tweaks (#421) * update * fix: update * update * update * update * update * fix: opening threads * fix: rm threads dropdwon & added back link to bot page thread view page * fix: rm threads dropdwon & added back link to bot page thread view page * fix: update * fix: added back to profile page * fix: added sticky and color * fix: codeblock ctas refactor markdown rendering, sidebar nav, code block & clipboard hook (#425) * fix: codeblock ctas * fix: ts build * fix: continue thread + allMessages sequence + mobile chat css tweak (#426) * fix: css handleCLick condition * fix: get latest search params, continuous thread * fix(impr): all messages sorting * perf(impr): sign in & up redirection tweak * perf(impr): mobile chat css * chore: next + react security ver upt (#427) --------- Co-authored-by: Brandon Fernández <31634868+Bran18@users.noreply.github.com> Co-authored-by: Jimoh sherifdeen <63134009+sheriffjimoh@users.noreply.github.com>
1 parent f965f73 commit 84f9588

File tree

24 files changed

+485
-663
lines changed

24 files changed

+485
-663
lines changed

apps/masterbots.ai/app/b/[botSlug]/[threadSlug]/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { ErrorComponent } from '@/components/shared/error'
77
import { botNames } from '@/lib/constants/bots-names'
88
import { generateMbMetadata } from '@/lib/metadata'
99
import { getCanonicalDomain, urlBuilders } from '@/lib/url'
10-
import Image from 'next/image'
11-
import Link from 'next/link'
1210

1311
export async function generateMetadata(props: PageProps): Promise<Metadata> {
1412
// Get base metadata from the shared function

apps/masterbots.ai/app/u/[userSlug]/t/[category]/[domain]/[chatbot]/[threadSlug]/page.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { botNames } from '@/lib/constants/bots-names'
44
import { generateMbMetadata } from '@/lib/metadata'
55
import { getCanonicalDomain, urlBuilders } from '@/lib/url'
66
import { getCategory, getThread } from '@/services/hasura'
7+
import { ChevronLeft } from 'lucide-react'
78
import type { User } from 'mb-genql'
89
import type { Metadata } from 'next'
910
import { getServerSession } from 'next-auth'
11+
import Link from 'next/link'
1012

1113
interface ThreadPageProps {
1214
params: Promise<{
@@ -20,6 +22,7 @@ interface ThreadPageProps {
2022

2123
export default async function ThreadPage(props: ThreadPageProps) {
2224
const params = await props.params
25+
const { chatbot: chatBotName, category, chatbot } = params
2326
const thread = await getThread({
2427
threadSlug: params.threadSlug,
2528
jwt: '',
@@ -33,12 +36,24 @@ export default async function ThreadPage(props: ThreadPageProps) {
3336
}
3437

3538
const { threadId } = thread
39+
const profileUrl = `/u/${params.userSlug}/t/${category}/${getCanonicalDomain(chatBotName)}/${chatbot}`
3640

3741
return (
38-
<BrowseThreadBlog
39-
threadId={threadId}
40-
user={session?.user as unknown as User}
41-
/>
42+
<div className="w-full">
43+
<div className="sticky top-0 lg:p-10 mt-4 ml-2 lg:mt-0 pb-0 mx-auto bg-gray-50 dark:bg-zinc-900 z-10">
44+
<Link
45+
href={profileUrl}
46+
className="flex items-center leading-none gap-2 dark:text-white/80 text-[#09090BC3] dark:hover:text-white hover:text-[#09090B]"
47+
>
48+
<ChevronLeft className="size-4" />
49+
<span>Back </span>
50+
</Link>
51+
</div>
52+
<BrowseThreadBlog
53+
threadId={threadId}
54+
user={session?.user as unknown as User}
55+
/>
56+
</div>
4257
)
4358
}
4459

apps/masterbots.ai/components/auth/signin-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function SignInForm() {
3232
if (result?.error) {
3333
setErrorMessage('Invalid email or password. Please try again')
3434
} else {
35-
router.push('/')
35+
router.push('/c')
3636
}
3737
}
3838

apps/masterbots.ai/components/auth/signup-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default function SignUpForm() {
9494
}
9595

9696
customSonner({ type: 'success', text: 'You are now logged in!' })
97-
router.push('/')
97+
router.push('/c')
9898
} catch (error) {
9999
console.error(error)
100100
customSonner({ type: 'error', text: (error as Error).message })

apps/masterbots.ai/components/layout/profile/profile-page-sidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const ProfileSidebar = ({ children }: { children: React.ReactNode }) => {
6969
<div className="flex flex-col space-y-1 font-Geist">
7070
{/* Threads Accordion */}
7171
<div className="rounded-lg">
72-
<Link
72+
{/* <Link
7373
href={urlBuilders.profilesUrl({
7474
type: 'user',
7575
usernameSlug: userSlug as string,
@@ -102,7 +102,7 @@ export const ProfileSidebar = ({ children }: { children: React.ReactNode }) => {
102102
isThreadsOpen ? 'rotate-90' : 'rotate-0',
103103
)}
104104
/>
105-
</Link>
105+
</Link> */}
106106
<div
107107
className={cn(
108108
'overflow-y-auto w-full scrollbar transition-all duration-300 max-w-[300px]',

apps/masterbots.ai/components/layout/sidebar/sidebar-link.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ const ChatbotComponent: React.FC<ChatbotComponentProps> = React.memo(
241241
const { userSlug, domain } = useParams()
242242
const { setIsOpenPopup, setActiveThread } = useThread()
243243

244+
const isPro = routeType === 'pro'
244245
const canonicalDomain = getCanonicalDomain(chatbot.name)
245246
// * Default to prompt when no metadata found... Special case for BlankBot
246247
const chatbotDomain = canonicalDomain || (domain as string) || 'prompt'
@@ -274,7 +275,7 @@ const ChatbotComponent: React.FC<ChatbotComponentProps> = React.memo(
274275
return navigateTo({
275276
urlType: 'chatbotThreadListUrl',
276277
navigationParams: {
277-
type: isPublic ? 'public' : 'personal',
278+
type: isPro ? 'pro' : isPublic ? 'public' : 'personal',
278279
category: category.name,
279280
domain: chatbotDomain,
280281
chatbot: chatbot.name,
@@ -303,7 +304,7 @@ const ChatbotComponent: React.FC<ChatbotComponentProps> = React.memo(
303304
chatbot: chatbot?.name,
304305
})
305306
: urlBuilders.chatbotThreadListUrl({
306-
type: isPublic ? 'public' : 'personal',
307+
type: isPro ? 'pro' : isPublic ? 'public' : 'personal',
307308
category: category.name,
308309
domain: chatbotDomain,
309310
chatbot: chatbot?.name,

apps/masterbots.ai/components/routes/browse/browse-chat-message.tsx

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525

2626
import { MemoizedReactMarkdown } from '@/components/shared/markdown'
27-
import { CodeBlock } from '@/components/ui/codeblock'
2827
import { cleanPrompt } from '@/lib/helpers/ai-helpers'
28+
import { memoizedMarkdownComponents } from '@/lib/memoized-markdown-components'
2929
import { cn } from '@/lib/utils'
3030
import type { Message } from 'ai'
3131
import type { Chatbot } from 'mb-genql'
@@ -51,65 +51,7 @@ export function BrowseChatMessage({
5151
<MemoizedReactMarkdown
5252
className="min-w-full prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 !max-w-5xl"
5353
remarkPlugins={[remarkGfm, rehypeMathJax, remarkRehype]}
54-
components={{
55-
// @ts-ignore
56-
p({ children }) {
57-
return (
58-
<p className="mb-2 whitespace-pre-line last:mb-0">{children}</p>
59-
)
60-
},
61-
// @ts-ignore
62-
ol({ children }) {
63-
return (
64-
<ol className="text-left list-decimal list-inside">
65-
{children}
66-
</ol>
67-
)
68-
},
69-
// @ts-ignore
70-
ul({ children }) {
71-
return (
72-
<ul className="text-left list-disc list-inside">{children}</ul>
73-
)
74-
},
75-
// @ts-ignore
76-
code({
77-
node,
78-
inline = false,
79-
className,
80-
children,
81-
...props
82-
}: React.HTMLAttributes<HTMLElement> & {
83-
node: unknown
84-
inline?: boolean
85-
}) {
86-
const childrenText = String(children)
87-
if (childrenText?.startsWith('▍')) {
88-
return (
89-
<span className="mt-1 cursor-default animate-pulse"></span>
90-
)
91-
}
92-
93-
const match = /language-(\w+)/.exec(className || '')
94-
95-
if (inline) {
96-
return (
97-
<code className={className} {...props}>
98-
{children}
99-
</code>
100-
)
101-
}
102-
103-
return (
104-
<CodeBlock
105-
key={Math.random()}
106-
language={match?.[1] || ''}
107-
value={String(children).replace(/\n$/, '')}
108-
{...props}
109-
/>
110-
)
111-
},
112-
}}
54+
components={memoizedMarkdownComponents()}
11355
>
11456
{cleanMessage.content}
11557
</MemoizedReactMarkdown>

apps/masterbots.ai/components/routes/browse/browse-chat-messages.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
import BrowseChatbotDetails from '@/components/routes/browse/browse-chatbot-details'
1717
import { BrowseThreadBlog } from '@/components/routes/browse/browse-thread-blog'
1818
import { ExternalLink } from '@/components/shared/external-link'
19-
import { buttonVariants } from '@/components/ui/button'
19+
import { Button, buttonVariants } from '@/components/ui/button'
2020
import { urlBuilders } from '@/lib/url'
2121
import { cn } from '@/lib/utils'
2222
import { getMessages } from '@/services/hasura'
2323
import type * as AI from 'ai'
24+
import { ChevronLeft } from 'lucide-react'
2425
import type { Chatbot, Message, User } from 'mb-genql'
2526
import Link from 'next/link'
2627
import React from 'react'
@@ -108,6 +109,15 @@ export function BrowseChatMessages({
108109
) : (
109110
''
110111
)}
112+
<div className="sticky top-0 lg:p-10 mt-4 ml-2 lg:mt-0 pb-0 mx-auto bg-gray-50 dark:bg-zinc-900 z-10">
113+
<Link
114+
href={`/b/${chatBotName?.toLowerCase()}`}
115+
className="flex items-center leading-none gap-2 dark:text-white/80 text-[#09090BC3] dark:hover:text-white hover:text-[#09090B]"
116+
>
117+
<ChevronLeft className="size-4" />
118+
<span>Back </span>
119+
</Link>
120+
</div>
111121
<div className="flex flex-col max-w-screen-lg px-4 mx-auto mt-8 gap-y-4">
112122
{parentThreadTitle && (
113123
<p>

0 commit comments

Comments
 (0)