File tree Expand file tree Collapse file tree
app/api/copilot/chat/update-messages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,8 +87,14 @@ export const POST = withRouteHandler(async (req: NextRequest) => {
8787 updateData . config = config
8888 }
8989
90- await db . update ( copilotChats ) . set ( updateData ) . where ( eq ( copilotChats . id , chatId ) )
91- await replaceCopilotChatMessages ( chatId , normalizedMessages )
90+ const [ updated ] = await db
91+ . update ( copilotChats )
92+ . set ( updateData )
93+ . where ( eq ( copilotChats . id , chatId ) )
94+ . returning ( { model : copilotChats . model } )
95+ await replaceCopilotChatMessages ( chatId , normalizedMessages , {
96+ chatModel : updated ?. model ?? null ,
97+ } )
9298
9399 logger . info ( `[${ tracker . requestId } ] Successfully updated chat` , {
94100 chatId,
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ export async function appendCopilotChatMessages(
4646 content : sql `excluded.content` ,
4747 role : sql `excluded.role` ,
4848 model : sql `COALESCE(excluded.model, ${ copilotChatMessages . model } )` ,
49+ streamId : sql `COALESCE(excluded.stream_id, ${ copilotChatMessages . streamId } )` ,
4950 updatedAt : sql `now()` ,
5051 } ,
5152 } )
You can’t perform that action at this time.
0 commit comments