An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
Update isShareable to isSharePage
Yoshiki Miuraea5ee30598df
diff --git a/app/actions.tsx b/app/actions.tsxindex 28e8525d..16fde3ba 100644--- a/app/actions.tsx+++ b/app/actions.tsx@@ -229,7 +229,7 @@ async function submit(formData?: FormData, skip?: boolean) {export type AIState = {messages: AIMessage[]chatId: string- isShareable?: boolean+ isSharePage?: boolean}export type UIState = {@@ -306,7 +306,7 @@ export const AI = createAI<AIState, UIState>({export const getUIStateFromAIState = (aiState: Chat) => {const chatId = aiState.chatId- const isShareable = aiState.isShareable+ const isSharePage = aiState.isSharePagereturn aiState.messages.map((message, index) => {const { role, content, id, type, name } = message@@ -314,8 +314,8 @@ export const getUIStateFromAIState = (aiState: Chat) => {if (!type ||type === 'end' ||- (!isShareable && type === 'related') ||- (!isShareable && type === 'followup')+ (isSharePage && type === 'related') ||+ (isSharePage && type === 'followup'))return null@@ -332,7 +332,7 @@ export const getUIStateFromAIState = (aiState: Chat) => {<UserMessagemessage={value}chatId={chatId}- showShare={index === 0 && isShareable}+ showShare={index === 0 && !isSharePage}/>)}diff --git a/app/page.tsx b/app/page.tsxindex a6ed82d0..9d1edd25 100644--- a/app/page.tsx+++ b/app/page.tsx@@ -7,7 +7,7 @@ export const maxDuration = 60export default function Page() {const id = nanoid()return (- <AI initialAIState={{ chatId: id, messages: [], isShareable: true }}>+ <AI initialAIState={{ chatId: id, messages: [] }}><Chat id={id} /></AI>)diff --git a/app/search/[id]/page.tsx b/app/search/[id]/page.tsxindex bbe0632a..d32179ad 100644--- a/app/search/[id]/page.tsx+++ b/app/search/[id]/page.tsx@@ -34,8 +34,7 @@ export default async function SearchPage({ params }: SearchPageProps) {<AIinitialAIState={{chatId: chat.id,- messages: chat.messages,- isShareable: true+ messages: chat.messages}}><Chat id={params.id} />diff --git a/app/share/[id]/page.tsx b/app/share/[id]/page.tsxindex f1df9681..246868af 100644--- a/app/share/[id]/page.tsx+++ b/app/share/[id]/page.tsx@@ -31,7 +31,13 @@ export default async function SharePage({ params }: SharePageProps) {}return (- <AI initialAIState={{ chatId: chat.id, messages: chat.messages }}>+ <AI+ initialAIState={{+ chatId: chat.id,+ messages: chat.messages,+ isSharePage: true+ }}+ ><Chat id={params.id} /></AI>)