@@ -544,6 +544,15 @@ function registerEventHandlers(
544544 } ) ,
545545 } ,
546546 } ;
547+ const syntheticMessageId = syntheticEvent . message . message_id ;
548+ if ( await hasProcessedFeishuMessage ( syntheticMessageId , accountId , log ) ) {
549+ log ( `feishu[${ accountId } ]: dropping duplicate bot-menu event for ${ syntheticMessageId } ` ) ;
550+ return ;
551+ }
552+ if ( ! tryBeginFeishuMessageProcessing ( syntheticMessageId , accountId ) ) {
553+ log ( `feishu[${ accountId } ]: dropping in-flight bot-menu event for ${ syntheticMessageId } ` ) ;
554+ return ;
555+ }
547556 const handleLegacyMenu = ( ) =>
548557 handleFeishuMessage ( {
549558 cfg,
@@ -553,6 +562,7 @@ function registerEventHandlers(
553562 runtime,
554563 chatHistories,
555564 accountId,
565+ processingClaimHeld : true ,
556566 } ) ;
557567
558568 const promise = maybeHandleFeishuQuickActionMenu ( {
@@ -561,12 +571,19 @@ function registerEventHandlers(
561571 operatorOpenId,
562572 runtime,
563573 accountId,
564- } ) . then ( ( handledMenu ) => {
565- if ( handledMenu ) {
566- return ;
567- }
568- return handleLegacyMenu ( ) ;
569- } ) ;
574+ } )
575+ . then ( async ( handledMenu ) => {
576+ if ( handledMenu ) {
577+ await recordProcessedFeishuMessage ( syntheticMessageId , accountId , log ) ;
578+ releaseFeishuMessageProcessing ( syntheticMessageId , accountId ) ;
579+ return ;
580+ }
581+ return await handleLegacyMenu ( ) ;
582+ } )
583+ . catch ( ( err ) => {
584+ releaseFeishuMessageProcessing ( syntheticMessageId , accountId ) ;
585+ throw err ;
586+ } ) ;
570587 if ( fireAndForget ) {
571588 promise . catch ( ( err ) => {
572589 error ( `feishu[${ accountId } ]: error handling bot menu event: ${ String ( err ) } ` ) ;
0 commit comments