Skip to content

Commit 22fb4e7

Browse files
committed
fix(feishu): preserve topic group session default
1 parent d6462d6 commit 22fb4e7

6 files changed

Lines changed: 75 additions & 29 deletions

File tree

‎docs/channels/feishu.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,14 @@ conversion fails, OpenClaw falls back to a file attachment and logs the reason.
639639
- ✅ Thread replies
640640
- ✅ Media replies stay thread-aware when replying to a thread message
641641

642-
Native Feishu/Lark topic groups use the event `thread_id` (`omt_*`) as the
643-
canonical topic session key by default, so different topics run in separate
644-
sessions while each topic stays serial. Set `groupSessionScope: "group"` or
645-
`topicSessionMode: "disabled"` to keep a topic group chat-scoped. If a native
646-
topic starter event omits `thread_id`, OpenClaw hydrates it from Feishu before
647-
routing the turn. Normal group replies that OpenClaw turns into threads keep
648-
using the reply root message ID (`om_*`) so the first turn and follow-up turn
649-
stay in the same session.
642+
Native Feishu/Lark topic groups stay chat-scoped by default. Set
643+
`groupSessionScope: "group_topic"` or legacy `topicSessionMode: "enabled"` to
644+
use the event `thread_id` (`omt_*`) as the canonical topic session key, so
645+
different topics run in separate sessions while each topic stays serial. If a
646+
native topic starter event omits `thread_id`, OpenClaw hydrates it from Feishu
647+
before routing the turn. Normal group replies that OpenClaw turns into threads
648+
keep using the reply root message ID (`om_*`) so the first turn and follow-up
649+
turn stay in the same session.
650650

651651
---
652652

‎extensions/feishu/src/bot-content.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ export function resolveConfiguredFeishuGroupSessionScope(params: {
7878
return (
7979
params.groupConfig?.groupSessionScope ??
8080
params.feishuCfg?.groupSessionScope ??
81-
(legacyTopicSessionMode === "enabled" ||
82-
((params.chatType === "topic_group" || params.hasThread === true) &&
83-
legacyTopicSessionMode !== "disabled")
84-
? "group_topic"
85-
: "group")
81+
(legacyTopicSessionMode === "enabled" ? "group_topic" : "group")
8682
);
8783
}
8884

‎extensions/feishu/src/bot.test.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,7 +3214,7 @@ describe("handleFeishuMessage command authorization", () => {
32143214
expect(replyRouteRequest.parentPeer).toEqual({ kind: "group", id: "oc-group" });
32153215
});
32163216

3217-
it("routes native topic groups as topic sessions by default", async () => {
3217+
it("keeps native topic groups chat-scoped by default", async () => {
32183218
mockShouldComputeCommandAuthorized.mockReturnValue(false);
32193219

32203220
const cfg: ClawdbotConfig = {
@@ -3244,11 +3244,7 @@ describe("handleFeishuMessage command authorization", () => {
32443244

32453245
await dispatchMessage({ cfg, event });
32463246

3247-
expectResolvedRouteCall(
3248-
0,
3249-
{ kind: "group", id: "oc-group:topic:omt_default_topic" },
3250-
{ kind: "group", id: "oc-group" },
3251-
);
3247+
expectResolvedRouteCall(0, { kind: "group", id: "oc-group" }, null);
32523248
});
32533249

32543250
it("keeps native topic groups chat-scoped when groupSessionScope=group", async () => {

‎extensions/feishu/src/config-schema.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ const FeishuToolsConfigSchema = z
132132
* - "group_topic_sender": one session per (group + topic thread + sender),
133133
* falls back to (group + sender) if no topic
134134
*
135-
* Native topic groups default to "group_topic" when this option is unset.
136-
* Other group chats default to "group".
135+
* Defaults to "group" when unset. Use "group_topic" to isolate native topic
136+
* group threads into separate sessions.
137137
*/
138138
const GroupSessionScopeSchema = z
139139
.enum(["group", "group_sender", "group_topic", "group_topic_sender"])
@@ -146,8 +146,8 @@ const GroupSessionScopeSchema = z
146146
* - "disabled": All messages in a group share one session
147147
* - "enabled": Messages in different topics get separate sessions
148148
*
149-
* Leave unset to use the current default: native topic groups are topic-scoped,
150-
* while normal groups are chat-scoped unless groupSessionScope says otherwise.
149+
* Leave unset to use the current default: group chats, including native topic
150+
* groups, are chat-scoped unless groupSessionScope says otherwise.
151151
*
152152
* Topic routing uses Feishu topic-group `thread_id` when the event identifies a
153153
* native topic group, and keeps `root_id` precedence for normal groups so

‎extensions/feishu/src/monitor.message-handler.test.ts‎

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,17 @@ describe("createFeishuMessageReceiveHandler topic queueing", () => {
171171
},
172172
} as unknown as PluginRuntime["channel"];
173173
const handler = createFeishuMessageReceiveHandler({
174-
cfg: {} as ClawdbotConfig,
174+
cfg: {
175+
channels: {
176+
feishu: {
177+
groups: {
178+
oc_topic_group: {
179+
groupSessionScope: "group_topic",
180+
},
181+
},
182+
},
183+
},
184+
} as ClawdbotConfig,
175185
channelRuntime,
176186
accountId: "default",
177187
chatHistories: new Map(),
@@ -253,7 +263,17 @@ describe("createFeishuMessageReceiveHandler topic queueing", () => {
253263
},
254264
} as unknown as PluginRuntime["channel"];
255265
const handler = createFeishuMessageReceiveHandler({
256-
cfg: {} as ClawdbotConfig,
266+
cfg: {
267+
channels: {
268+
feishu: {
269+
groups: {
270+
oc_topic_group: {
271+
groupSessionScope: "group_topic",
272+
},
273+
},
274+
},
275+
},
276+
} as ClawdbotConfig,
257277
channelRuntime,
258278
accountId: "default",
259279
chatHistories: new Map(),
@@ -336,7 +356,17 @@ describe("createFeishuMessageReceiveHandler topic queueing", () => {
336356
},
337357
} as unknown as PluginRuntime["channel"];
338358
const handler = createFeishuMessageReceiveHandler({
339-
cfg: {} as ClawdbotConfig,
359+
cfg: {
360+
channels: {
361+
feishu: {
362+
groups: {
363+
oc_topic_group: {
364+
groupSessionScope: "group_topic",
365+
},
366+
},
367+
},
368+
},
369+
} as ClawdbotConfig,
340370
channelRuntime,
341371
accountId: "default",
342372
chatHistories: new Map(),
@@ -415,7 +445,17 @@ describe("createFeishuMessageReceiveHandler topic queueing", () => {
415445
},
416446
} as unknown as PluginRuntime["channel"];
417447
const handler = createFeishuMessageReceiveHandler({
418-
cfg: {} as ClawdbotConfig,
448+
cfg: {
449+
channels: {
450+
feishu: {
451+
groups: {
452+
oc_topic_group: {
453+
groupSessionScope: "group_topic",
454+
},
455+
},
456+
},
457+
},
458+
} as ClawdbotConfig,
419459
channelRuntime,
420460
accountId: "default",
421461
chatHistories: new Map(),

‎extensions/feishu/src/sequential-key.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe("getFeishuSequentialKey", () => {
7676
).toBe("feishu:default:oc_dm_chat:btw");
7777
});
7878

79-
it("uses native topic ids as the default lane for Feishu topic groups", () => {
79+
it("keeps Feishu topic groups on the chat lane by default", () => {
8080
expect(
8181
getFeishuSequentialKey({
8282
accountId: "default",
@@ -88,10 +88,24 @@ describe("getFeishuSequentialKey", () => {
8888
threadId: "omt_topic_1",
8989
}),
9090
}),
91-
).toBe("feishu:default:oc_topic_group:topic:omt_topic_1");
91+
).toBe("feishu:default:oc_topic_group");
92+
});
93+
94+
it("uses native topic ids when Feishu topic groups opt into topic sessions", () => {
9295
expect(
9396
getFeishuSequentialKey({
9497
accountId: "default",
98+
cfg: {
99+
channels: {
100+
feishu: {
101+
groups: {
102+
oc_topic_group: {
103+
groupSessionScope: "group_topic",
104+
},
105+
},
106+
},
107+
},
108+
},
95109
event: createTextEvent({
96110
text: "topic two",
97111
chatId: "oc_topic_group",

0 commit comments

Comments
 (0)