@@ -8,7 +8,11 @@ const cfg = {
88 feishu : {
99 appId : "cli_test" ,
1010 appSecret : "secret_test" ,
11+ groupSessionScope : "group_topic" ,
1112 groups : {
13+ oc_group_chat : {
14+ groupSessionScope : "group" ,
15+ } ,
1216 oc_topic_chat : {
1317 groupSessionScope : "group_topic" ,
1418 } ,
@@ -97,7 +101,7 @@ describe("getFeishuSequentialKey", () => {
97101 ) . resolves . toBe ( "feishu:default:oc_dm_chat:btw" ) ;
98102 } ) ;
99103
100- it ( "uses the configured topic session scope for group queue keys" , async ( ) => {
104+ it ( "uses configured topic thread_id scope for group queue keys" , async ( ) => {
101105 const first = createTextEvent ( {
102106 text : "topic one" ,
103107 chatId : "oc_topic_chat" ,
@@ -119,6 +123,55 @@ describe("getFeishuSequentialKey", () => {
119123 ) . resolves . toBe ( "feishu:default:oc_topic_chat:topic:omt_topic_2" ) ;
120124 } ) ;
121125
126+ it ( "keeps group queues chat-scoped when groupSessionScope is group" , async ( ) => {
127+ const event = createTextEvent ( {
128+ text : "plain group" ,
129+ chatId : "oc_group_chat" ,
130+ chatType : "topic_group" ,
131+ threadId : "omt_topic_1" ,
132+ } ) ;
133+
134+ await expect ( getFeishuSequentialKey ( { cfg, accountId : "default" , event } ) ) . resolves . toBe (
135+ "feishu:default:oc_group_chat" ,
136+ ) ;
137+ } ) ;
138+
139+ it ( "uses the top-level groupSessionScope thread_id when a group has no override" , async ( ) => {
140+ const event = createTextEvent ( {
141+ text : "global topic scope" ,
142+ chatId : "oc_global_topic_chat" ,
143+ chatType : "topic_group" ,
144+ threadId : "omt_global_topic_1" ,
145+ } ) ;
146+
147+ await expect ( getFeishuSequentialKey ( { cfg, accountId : "default" , event } ) ) . resolves . toBe (
148+ "feishu:default:oc_global_topic_chat:topic:omt_global_topic_1" ,
149+ ) ;
150+ } ) ;
151+
152+ it ( "does not hydrate thread_id when groupSessionScope keeps the chat queue" , async ( ) => {
153+ const event = createTextEvent ( {
154+ text : "plain group without thread id" ,
155+ chatId : "oc_group_chat" ,
156+ chatType : "topic_group" ,
157+ messageId : "om_group_scope_message" ,
158+ } ) ;
159+ let fetched = false ;
160+
161+ await expect (
162+ getFeishuSequentialKey ( {
163+ cfg,
164+ accountId : "default" ,
165+ event,
166+ fetchMessage : async ( ) => {
167+ fetched = true ;
168+ throw new Error ( "should not fetch for chat-scoped queues" ) ;
169+ } ,
170+ } ) ,
171+ ) . resolves . toBe ( "feishu:default:oc_group_chat" ) ;
172+ expect ( fetched ) . toBe ( false ) ;
173+ } ) ;
174+
122175 it ( "keeps control lanes scoped within the topic queue" , async ( ) => {
123176 const event = createTextEvent ( {
124177 text : "/stop" ,
0 commit comments