@@ -42,6 +42,7 @@ import { RememberDebugClientTool } from '@/lib/copilot/tools/client/other/rememb
4242import { ResearchClientTool } from '@/lib/copilot/tools/client/other/research'
4343import { SearchDocumentationClientTool } from '@/lib/copilot/tools/client/other/search-documentation'
4444import { SearchErrorsClientTool } from '@/lib/copilot/tools/client/other/search-errors'
45+ import { SearchLibraryDocsClientTool } from '@/lib/copilot/tools/client/other/search-library-docs'
4546import { SearchOnlineClientTool } from '@/lib/copilot/tools/client/other/search-online'
4647import { SearchPatternsClientTool } from '@/lib/copilot/tools/client/other/search-patterns'
4748import { SleepClientTool } from '@/lib/copilot/tools/client/other/sleep'
@@ -116,6 +117,7 @@ const CLIENT_TOOL_INSTANTIATORS: Record<string, (id: string) => any> = {
116117 get_trigger_blocks : ( id ) => new GetTriggerBlocksClientTool ( id ) ,
117118 search_online : ( id ) => new SearchOnlineClientTool ( id ) ,
118119 search_documentation : ( id ) => new SearchDocumentationClientTool ( id ) ,
120+ search_library_docs : ( id ) => new SearchLibraryDocsClientTool ( id ) ,
119121 search_patterns : ( id ) => new SearchPatternsClientTool ( id ) ,
120122 search_errors : ( id ) => new SearchErrorsClientTool ( id ) ,
121123 remember_debug : ( id ) => new RememberDebugClientTool ( id ) ,
@@ -174,6 +176,7 @@ export const CLASS_TOOL_METADATA: Record<string, BaseClientToolMetadata | undefi
174176 get_trigger_blocks : ( GetTriggerBlocksClientTool as any ) ?. metadata ,
175177 search_online : ( SearchOnlineClientTool as any ) ?. metadata ,
176178 search_documentation : ( SearchDocumentationClientTool as any ) ?. metadata ,
179+ search_library_docs : ( SearchLibraryDocsClientTool as any ) ?. metadata ,
177180 search_patterns : ( SearchPatternsClientTool as any ) ?. metadata ,
178181 search_errors : ( SearchErrorsClientTool as any ) ?. metadata ,
179182 remember_debug : ( RememberDebugClientTool as any ) ?. metadata ,
@@ -2433,9 +2436,10 @@ export const useCopilotStore = create<CopilotStore>()(
24332436
24342437 // If already sending a message, queue this one instead
24352438 if ( isSendingMessage ) {
2436- get ( ) . addToQueue ( message , { fileAttachments, contexts } )
2439+ get ( ) . addToQueue ( message , { fileAttachments, contexts, messageId } )
24372440 logger . info ( '[Copilot] Message queued (already sending)' , {
24382441 queueLength : get ( ) . messageQueue . length + 1 ,
2442+ originalMessageId : messageId ,
24392443 } )
24402444 return
24412445 }
@@ -3161,8 +3165,12 @@ export const useCopilotStore = create<CopilotStore>()(
31613165 // Process next message in queue if any
31623166 const nextInQueue = get ( ) . messageQueue [ 0 ]
31633167 if ( nextInQueue ) {
3168+ // Use originalMessageId if available (from edit/resend), otherwise use queue entry id
3169+ const messageIdToUse = nextInQueue . originalMessageId || nextInQueue . id
31643170 logger . info ( '[Queue] Processing next queued message' , {
31653171 id : nextInQueue . id ,
3172+ originalMessageId : nextInQueue . originalMessageId ,
3173+ messageIdToUse,
31663174 queueLength : get ( ) . messageQueue . length ,
31673175 } )
31683176 // Remove from queue and send
@@ -3173,7 +3181,7 @@ export const useCopilotStore = create<CopilotStore>()(
31733181 stream : true ,
31743182 fileAttachments : nextInQueue . fileAttachments ,
31753183 contexts : nextInQueue . contexts ,
3176- messageId : nextInQueue . id ,
3184+ messageId : messageIdToUse ,
31773185 } )
31783186 } , 100 )
31793187 }
@@ -3615,10 +3623,12 @@ export const useCopilotStore = create<CopilotStore>()(
36153623 fileAttachments : options ?. fileAttachments ,
36163624 contexts : options ?. contexts ,
36173625 queuedAt : Date . now ( ) ,
3626+ originalMessageId : options ?. messageId ,
36183627 }
36193628 set ( { messageQueue : [ ...get ( ) . messageQueue , queuedMessage ] } )
36203629 logger . info ( '[Queue] Message added to queue' , {
36213630 id : queuedMessage . id ,
3631+ originalMessageId : options ?. messageId ,
36223632 queueLength : get ( ) . messageQueue . length ,
36233633 } )
36243634 } ,
@@ -3659,12 +3669,15 @@ export const useCopilotStore = create<CopilotStore>()(
36593669 await new Promise ( ( resolve ) => setTimeout ( resolve , 50 ) )
36603670 }
36613671
3672+ // Use originalMessageId if available (from edit/resend), otherwise use queue entry id
3673+ const messageIdToUse = message . originalMessageId || message . id
3674+
36623675 // Send the message
36633676 await get ( ) . sendMessage ( message . content , {
36643677 stream : true ,
36653678 fileAttachments : message . fileAttachments ,
36663679 contexts : message . contexts ,
3667- messageId : message . id ,
3680+ messageId : messageIdToUse ,
36683681 } )
36693682 } ,
36703683
0 commit comments