Skip to content

Commit 9a9a998

Browse files
committed
fix(feishu): bound btw out-of-band lanes
1 parent 3b5b3c2 commit 9a9a998

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("getFeishuSequentialKey", () => {
3030
[createTextEvent({ text: "hello" }), "feishu:default:oc_dm_chat"],
3131
[createTextEvent({ text: "/status" }), "feishu:default:oc_dm_chat"],
3232
[createTextEvent({ text: "/stop" }), "feishu:default:oc_dm_chat:control"],
33-
[createTextEvent({ text: "/btw what changed?" }), "feishu:default:oc_dm_chat:btw:om_message_1"],
33+
[createTextEvent({ text: "/btw what changed?" }), "feishu:default:oc_dm_chat:btw"],
3434
])("resolves sequential key %#", (event, expected) => {
3535
expect(
3636
getFeishuSequentialKey({
@@ -40,6 +40,24 @@ describe("getFeishuSequentialKey", () => {
4040
).toBe(expected);
4141
});
4242

43+
it("keeps /btw on a stable per-chat lane across different message ids", () => {
44+
const first = createTextEvent({ text: "/btw one", messageId: "om_message_1" });
45+
const second = createTextEvent({ text: "/btw two", messageId: "om_message_2" });
46+
47+
expect(
48+
getFeishuSequentialKey({
49+
accountId: "default",
50+
event: first,
51+
}),
52+
).toBe("feishu:default:oc_dm_chat:btw");
53+
expect(
54+
getFeishuSequentialKey({
55+
accountId: "default",
56+
event: second,
57+
}),
58+
).toBe("feishu:default:oc_dm_chat:btw");
59+
});
60+
4361
it("falls back to a stable btw lane when the message id is unavailable", () => {
4462
const event = createTextEvent({ text: "/btw what changed?" });
4563
delete (event.message as { message_id?: string }).message_id;

extensions/feishu/src/sequential-key.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export function getFeishuSequentialKey(params: {
1818
}
1919

2020
if (isBtwRequestText(text)) {
21-
const messageId = event.message.message_id?.trim();
22-
return messageId ? `${baseKey}:btw:${messageId}` : `${baseKey}:btw`;
21+
return `${baseKey}:btw`;
2322
}
2423

2524
return baseKey;

0 commit comments

Comments
 (0)