Skip to content

An AI-powered search engine with a generative UI

refactor: rename handleStreamFinish to persistStreamResults for clarity

Yoshiki Miura17e276a4a65f
diff --git a/components/related-questions.tsx b/components/related-questions.tsx
index e4271055..48d328e3 100644
--- a/components/related-questions.tsx
+++ b/components/related-questions.tsx
@@ -6,10 +6,10 @@ import { ArrowRight } from 'lucide-react'
import type { RelatedQuestionsData } from '@/lib/types/ai'
-import { CollapsibleMessage } from './collapsible-message'
-import { Section } from './section'
import { Button } from './ui/button'
import { Skeleton } from './ui/skeleton'
+import { CollapsibleMessage } from './collapsible-message'
+import { Section } from './section'
interface RelatedQuestionsProps {
data: RelatedQuestionsData
diff --git a/lib/streaming/create-chat-stream-response.ts b/lib/streaming/create-chat-stream-response.ts
index 055b1bbe..a7504eef 100644
--- a/lib/streaming/create-chat-stream-response.ts
+++ b/lib/streaming/create-chat-stream-response.ts
@@ -23,7 +23,7 @@ import { getTextFromParts } from '../utils/message-utils'
import { perfLog, perfTime } from '../utils/perf-logging'
import { filterReasoningParts } from './helpers/filter-reasoning-parts'
-import { handleStreamFinish } from './helpers/handle-stream-finish'
+import { persistStreamResults } from './helpers/persist-stream-results'
import { prepareMessages } from './helpers/prepare-messages'
import { streamRelatedQuestions } from './helpers/stream-related-questions'
import type { StreamContext } from './helpers/types'
@@ -209,8 +209,8 @@ export async function createChatStreamResponse(
onFinish: async ({ responseMessage, isAborted }) => {
if (isAborted || !responseMessage) return
- // Handle stream finish tasks like saving message and updating title
- await handleStreamFinish(
+ // Persist stream results to database
+ await persistStreamResults(
responseMessage,
chatId,
userId,
diff --git a/lib/streaming/helpers/handle-stream-finish.ts b/lib/streaming/helpers/persist-stream-results.ts
similarity index 97%
rename from lib/streaming/helpers/handle-stream-finish.ts
rename to lib/streaming/helpers/persist-stream-results.ts
index 31f7d75a..59c1006d 100644
--- a/lib/streaming/helpers/handle-stream-finish.ts
+++ b/lib/streaming/helpers/persist-stream-results.ts
@@ -7,7 +7,7 @@ import { retryDatabaseOperation } from '@/lib/utils/retry'
const DEFAULT_CHAT_TITLE = 'Untitled'
-export async function handleStreamFinish(
+export async function persistStreamResults(
responseMessage: UIMessage,
chatId: string,
userId: string,