Skip to content

Commit a72bc88

Browse files
AndlerRLBran18sheriffjimoh
authored
fix: new chat + seo og img + share link track (#452)
* 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) * refactor: use chat and continue thread + continue conversation fallback (#432) * refactor: use chat and continue generation * fix: uniq slug and id gen (#433) * fix: uniq thread + msg slug gen * style: formatting * fix: thread user attachments state upt * perf: impr thread component at all pages + mobile tweaks * refactor: thread-component card * chore: restore continue generation v1 * feat(impr): thread component card * fix: admin panel n actions * fix: fetch getThreads * chore: continue conversation v1.2 * chore: continue and update thread content * chore: add ui control continue generation state * chore: fix infinity loop * chore(impr): enable upt msg table permission * fix: seo thread fetch * chore: style formating * fix(impr): continued thread title + thread component reusability * chore: refactor loadings + extending sonners --------- Co-authored-by: bran18 <andreyfdez18@gmail.com> --------- Co-authored-by: Roberto Lucas <andler@bitcash.org> * feat: add gemini provider (#437) * feat: add gemini provider * chore: update icons * feat: impr continuing thread tags + accordion first msg toggle (#435) * feat(wip): impr continuing thread tags + accordion first msg toggle * feat(impr): continuing thread tags + accordion at first message + header mobile tweak * style(impr): mobile thread-component x-axis space * perf(style): coderabbitai feedbacks * fix: css typo * perf: sendMessageFromResponse clicked guard + continued thread tags label tweak * chore: user thread panel clean up * fix: user-thread-panel infinite loader * perf: impr shared accordion animation and ux * style: defaultAccordionState comments loc * fix: record type warning, hasura updateMessage * fix: getThread user data, shared-accordion * fix: coderabbitai observations * fix: impr file management per llm, multimodel feat flag, chat tool labels, parent thread guard * fix: tunningUserContent parentThread condition * fix: feature flag typo * feat: profile page thread popup feature flag and tweaks (#434) * update * fix: update * update * update * update * update * refactor: profile page threads pop up * fix: update config * fix: update * fix: update * fix: make profile page scroll on hero * fix: bot make popup and scroll * fix: make profile page sidebar scroll independently * fix: make profile page sidebar scroll independently * fix: check the category along the chatbot when it's not checked * fix: check the category along the chatbot when it's not checked --------- Co-authored-by: Roberto Lucas <andler.dev@gmail.com> Co-authored-by: Roberto Lucas <andler@bitcash.org> * feat: add new llm models (#444) * feat-add-models * feat-add-models * feat-add-models * chore: add model * fix: typo * chore: add toggler color * perf(impr): thread llm context, last question & response + new models seeds (#447) * feat(wip): thread llm context, prev questions * fix: previousQuestionsString slice * fix: clickedContentId in followingQuestionsPrompt * feat: isContinued + model type in message table * fix: ts typo + sendMessageFromResponse callback call * fix: ts typo * fix: bot profile page view (#449) * fix(wip): bot profile thread list * style: formatting * fix: new chats and share + og img (#451) * fix: new chat state reset * fix: genql gen + share link check * fix: og img * fix: duplicate role permission in msg table --------- 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 b77dcd1 commit a72bc88

File tree

28 files changed

+4067
-3563
lines changed

28 files changed

+4067
-3563
lines changed

apps/hasura/metadata/databases/masterbots/tables/public_message.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ insert_permissions:
3737
- content
3838
- created_at
3939
- examples
40+
- isContinued
4041
- message_id
42+
- model
4143
- prompt
4244
- role
45+
- short_link
4346
- slug
4447
- thinking
4548
- thinking_traces
@@ -56,10 +59,12 @@ insert_permissions:
5659
- content
5760
- created_at
5861
- examples
62+
- isContinued
5963
- message_id
64+
- model
6065
- prompt
6166
- role
62-
- role
67+
- short_link
6368
- slug
6469
- thinking
6570
- thinking_traces
@@ -73,9 +78,12 @@ select_permissions:
7378
- content
7479
- created_at
7580
- examples
81+
- isContinued
7682
- message_id
83+
- model
7784
- prompt
7885
- role
86+
- short_link
7987
- slug
8088
- thinking
8189
- thinking_traces
@@ -90,9 +98,12 @@ select_permissions:
9098
- content
9199
- created_at
92100
- examples
101+
- isContinued
93102
- message_id
103+
- model
94104
- prompt
95105
- role
106+
- short_link
96107
- slug
97108
- thinking
98109
- thinking_traces
@@ -107,9 +118,12 @@ select_permissions:
107118
- content
108119
- created_at
109120
- examples
121+
- isContinued
110122
- message_id
123+
- model
111124
- prompt
112125
- role
126+
- short_link
113127
- slug
114128
- thinking
115129
- thinking_traces
@@ -122,13 +136,15 @@ update_permissions:
122136
permission:
123137
columns:
124138
- content
139+
- short_link
125140
filter: {}
126141
check: null
127142
comment: ""
128143
- role: user
129144
permission:
130145
columns:
131146
- content
147+
- short_link
132148
filter:
133149
thread:
134150
user_id:

apps/hasura/metadata/databases/masterbots/tables/public_thread.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ select_permissions:
7777
- is_public
7878
- model
7979
- parent_thread_id
80+
- short_link
8081
- slug
8182
- thread_id
8283
- updated_at
@@ -94,6 +95,7 @@ select_permissions:
9495
- is_public
9596
- model
9697
- parent_thread_id
98+
- short_link
9799
- slug
98100
- thread_id
99101
- updated_at
@@ -111,6 +113,7 @@ select_permissions:
111113
- is_public
112114
- model
113115
- parent_thread_id
116+
- short_link
114117
- slug
115118
- thread_id
116119
- updated_at
@@ -129,6 +132,7 @@ update_permissions:
129132
- is_public
130133
- model
131134
- parent_thread_id
135+
- short_link
132136
- thread_id
133137
- updated_at
134138
- user_id
@@ -144,6 +148,7 @@ update_permissions:
144148
- is_public
145149
- model
146150
- parent_thread_id
151+
- short_link
147152
- thread_id
148153
- updated_at
149154
- user_id
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Could not auto-generate a down migration.
2+
-- Please write an appropriate down migration for the SQL below:
3+
-- alter table "public"."thread" add column "short_link" text
4+
-- null unique;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table "public"."thread" add column "short_link" text
2+
null unique;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Could not auto-generate a down migration.
2+
-- Please write an appropriate down migration for the SQL below:
3+
-- alter table "public"."message" add column "short_link" text
4+
-- null unique;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table "public"."message" add column "short_link" text
2+
null unique;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:3b2a352f78269f5b5928e3b366d21e96c69c75e4c9e6e9829d5f088feb6dd4b2
2+
oid sha256:997b401bb13349616c6bd2c374727af2243438985d8c1ebe9deafc3664939dd9
33
size 210700
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:eb3ec6b88794c4214c7c06db4b58f1c4c9b6c6e7f1fb35fd2e66ba6162ab77e9
2+
oid sha256:4db7a9a17393d483cc52df6bb5d1d88806dda4053ff0409777ab9b2add17c33f
33
size 5653589

apps/masterbots.ai/app/actions/dub-co.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
'use server'
22

3-
import { getMessages, getThread } from '@/services/hasura'
3+
import {
4+
getMessages,
5+
getThread,
6+
updateMessageShortLink,
7+
updateThreadShortLink,
8+
} from '@/services/hasura'
49
import axios from 'axios'
510
import { cookies } from 'next/headers'
611

@@ -14,12 +19,16 @@ export async function generateShortLink(path: string) {
1419
pathParts[pathParts.length - 1]
1520
const thread = await getThread({ threadSlug })
1621
const messages = await getMessages({ threadQuestionSlug })
17-
// TODO: Create shortLink for thread and messages
18-
// const threadShortLink = thread?.shortLink
19-
// const messagesShortLink = messages?.shortLink
20-
// if (threadShortLink || messagesShortLink) {
21-
// return threadShortLink || messagesShortLink
22-
// }
22+
const threadShortLink = thread?.shortLink
23+
const messagesShortLink = messages[0]?.shortLink
24+
if (threadShortLink || messagesShortLink) {
25+
return {
26+
data: {
27+
shortLink: threadShortLink || messagesShortLink || '',
28+
},
29+
error: null,
30+
}
31+
}
2332
const resolved: DubShareLinkResponse = await axios
2433
.post(
2534
`https://api.dub.co/links?workspaceId=${process.env.DUB_WORKSPACE_ID}`,
@@ -37,6 +46,17 @@ export async function generateShortLink(path: string) {
3746
.then((res) => res.data)
3847

3948
if (!resolved) throw new Error('Failed to generate short link')
49+
if (threadQuestionSlug) {
50+
await updateMessageShortLink({
51+
slug: threadQuestionSlug,
52+
shortLink: resolved.shortLink,
53+
})
54+
} else {
55+
await updateThreadShortLink({
56+
slug: threadSlug,
57+
shortLink: resolved.shortLink,
58+
})
59+
}
4060

4161
return {
4262
data: {

apps/masterbots.ai/app/api/og/route.tsx

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import OGImage from '@/components/shared/og-image'
2+
import { getUserBySlug } from '@/services/hasura'
23
import type { UUID } from '@/types/types'
34
import type { Chatbot, Thread } from 'mb-genql'
45
import { ImageResponse } from 'next/og'
@@ -18,7 +19,7 @@ const defaultContent = {
1819
avatar: `${process.env.NEXT_PUBLIC_BASE_URL}/images/masterbots.png`,
1920
categories: [{ category: { name: 'AI' } }],
2021
},
21-
},
22+
} as Partial<Thread>,
2223
question: 'Masterbots AI',
2324
answer:
2425
'Deploy with our domain-specific Masterbots, dedicated experts in your field. Each Masterbot is purpose-built for its role, delivering focused knowledge and specialized interactions beyond what generic AI solutions can offer.',
@@ -32,6 +33,7 @@ export async function GET(req: NextRequest) {
3233
const { searchParams } = req.nextUrl
3334
const rawThreadId = searchParams.get('threadId')
3435
const rawChatbotId = searchParams.get('chatbotId')
36+
const rawUserSlug = searchParams.get('userSlug')
3537
const rawThreadQuestionSlug = searchParams.get('threadQuestionSlug')
3638
const threadId = rawThreadId?.match(
3739
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
@@ -43,12 +45,49 @@ export async function GET(req: NextRequest) {
4345
)
4446
? (rawChatbotId as UUID)
4547
: null
48+
const defaultOgImage = new ImageResponse(
49+
<OGImage {...defaultContent} />,
50+
IMAGE_DIMENSIONS,
51+
)
52+
53+
if (rawUserSlug) {
54+
const { user: userData } = await getUserBySlug({
55+
slug: rawUserSlug,
56+
isSameUser: false,
57+
})
58+
59+
if (!userData) {
60+
return defaultOgImage
61+
}
62+
63+
return new ImageResponse(
64+
<OGImage
65+
thread={defaultContent.thread}
66+
question={userData.username}
67+
answer={userData.bio || ''}
68+
username={`${userData.followers.length} followers`}
69+
user_avatar={userData.profilePicture || ''}
70+
isLightTheme={false}
71+
/>,
72+
IMAGE_DIMENSIONS,
73+
)
74+
}
75+
76+
if (!threadId && !chatbotId) {
77+
// Use metadata when thread not found
78+
return defaultOgImage
79+
}
4680

4781
// TODO: Update this to use mb-genql package
4882
const { thread }: { thread: Thread[] } = await getThreadForOG(
4983
threadId as UUID,
5084
)
5185

86+
if (!thread?.length && !chatbotId) {
87+
// Use metadata when thread not found
88+
return defaultOgImage
89+
}
90+
5291
// Initialize chatbot data
5392
let chatbotData: { chatbot: Chatbot[] } = { chatbot: [] }
5493

@@ -72,14 +111,6 @@ export async function GET(req: NextRequest) {
72111
)
73112
}
74113

75-
if (!thread?.length) {
76-
// Use metadata when thread not found
77-
return new ImageResponse(
78-
<OGImage {...defaultContent} />,
79-
IMAGE_DIMENSIONS,
80-
)
81-
}
82-
83114
const threadData = thread[0]
84115
const question =
85116
threadData?.messages?.find(

0 commit comments

Comments
 (0)