@@ -21,7 +21,9 @@ const { messages, status, error, sendMessage, regenerate, stop } = useChat({
2121 transport: new DefaultChatTransport ({ api: ' /api/assistant' }),
2222})
2323
24- const plugins = [highlight ()]
24+ const plugins = [
25+ highlight (),
26+ ]
2527
2628// Suggestions grouped by category, shown before the first message.
2729const questions = computed (() => assistant ?.faqQuestions ?? [])
@@ -58,7 +60,9 @@ async function copyConversation() {
5860 const text = messages .value
5961 .map ((message ) => {
6062 const content = message .parts .filter (isTextUIPart ).map (part => part .text ).join (' \n ' )
61- return ` ${message .role === ' user' ? ' User' : ' Assistant' }:\n ${content } `
63+ return ` ${message .role === ' user'
64+ ? ' User'
65+ : ' Assistant' }:\n ${content } `
6266 })
6367 .join (' \n\n ' )
6468 await navigator .clipboard .writeText (text )
@@ -76,12 +80,23 @@ function toolMeta(part: ToolUIPart | DynamicToolUIPart) {
7680 const streaming = isToolStreaming (part )
7781 const input = part .input as Record <string , string > | undefined
7882 if (name === ' search_docs' ) {
79- return { icon: ' i-lucide-text-search' , text: streaming ? ' Searching the docs' : ' Searched the docs' , suffix: input ?.query }
83+ return {
84+ icon: ' i-lucide-text-search' ,
85+ text: streaming ? ' Searching the docs' : ' Searched the docs' ,
86+ suffix: input ?.query ,
87+ }
8088 }
8189 if (name === ' get_page' ) {
82- return { icon: ' i-lucide-book-open' , text: streaming ? ' Reading a page' : ' Read a page' , suffix: input ?.path }
90+ return {
91+ icon: ' i-lucide-book-open' ,
92+ text: streaming ? ' Reading a page' : ' Read a page' ,
93+ suffix: input ?.path ,
94+ }
95+ }
96+ return {
97+ icon: ' i-lucide-wrench' ,
98+ text: name .replace (/ _/ g , ' ' ),
8399 }
84- return { icon: ' i-lucide-wrench' , text: name .replace (/ _/ g , ' ' ) }
85100}
86101
87102/** Live tool rows show while the answer streams; once done they collapse into one "Used N sources" row. */
@@ -100,8 +115,11 @@ function messageSources(message: UIMessage) {
100115 for (const part of message .parts ) {
101116 if (isToolUIPart (part ) && getToolName (part ) === ' get_page' ) {
102117 const path = (part .input as { path? : string } | undefined )?.path
103- if (path )
104- paths .add (path .startsWith (' /' ) ? path : ` /${path } ` )
118+ if (path ) {
119+ paths .add (path .startsWith (' /' )
120+ ? path
121+ : ` /${path } ` )
122+ }
105123 }
106124 }
107125 return [... paths ]
@@ -113,7 +131,9 @@ function messageToolCount(message: UIMessage) {
113131
114132function sourcesLabel(message : UIMessage ) {
115133 const count = messageSources (message ).length || messageToolCount (message )
116- return ` Used ${count } source${count === 1 ? ' ' : ' s' } `
134+ return ` Used ${count } source${count === 1
135+ ? ' '
136+ : ' s' } `
117137}
118138 </script >
119139
0 commit comments