File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -133,13 +133,29 @@ export async function fetchChatHistory(
133133 chatId : string ,
134134 signal ?: AbortSignal
135135) : Promise < TaskChatHistory > {
136- const response = await fetch ( `/api/mothership/chats/${ chatId } ` , { signal } )
136+ const mothershipRes = await fetch ( `/api/mothership/chats/${ chatId } ` , { signal } )
137+
138+ if ( mothershipRes . ok ) {
139+ const { chat } = await mothershipRes . json ( )
140+ return {
141+ id : chat . id ,
142+ title : chat . title ,
143+ messages : Array . isArray ( chat . messages ) ? chat . messages : [ ] ,
144+ activeStreamId : chat . conversationId || null ,
145+ resources : Array . isArray ( chat . resources ) ? chat . resources : [ ] ,
146+ streamSnapshot : chat . streamSnapshot || null ,
147+ }
148+ }
137149
138- if ( ! response . ok ) {
150+ const copilotRes = await fetch ( `/api/copilot/chat?chatId=${ encodeURIComponent ( chatId ) } ` , {
151+ signal,
152+ } )
153+
154+ if ( ! copilotRes . ok ) {
139155 throw new Error ( 'Failed to load chat' )
140156 }
141157
142- const { chat } = await response . json ( )
158+ const { chat } = await copilotRes . json ( )
143159 return {
144160 id : chat . id ,
145161 title : chat . title ,
You can’t perform that action at this time.
0 commit comments