fix(regression): preserve announce thread ids

This commit is contained in:
Tak Hoffman
2026-03-27 23:21:12 -05:00
parent c0d4c07b88
commit 12488f45c2
2 changed files with 13 additions and 3 deletions

View File

@@ -97,4 +97,14 @@ describe("resolveAnnounceTargetFromKey", () => {
threadId: "99",
});
});
it("preserves decimal thread ids for Slack-style session keys", () => {
expect(
resolveAnnounceTargetFromKey("agent:main:slack:channel:general:thread:1699999999.0001"),
).toEqual({
channel: "slack",
to: "channel:general",
threadId: "1699999999.0001",
});
});
});

View File

@@ -32,8 +32,8 @@ export function resolveAnnounceTargetFromKey(sessionKey: string): AnnounceTarget
// Telegram uses :topic:, other platforms use :thread:
let threadId: string | undefined;
const restJoined = rest.join(":");
const topicMatch = restJoined.match(/:topic:(\d+)$/);
const threadMatch = restJoined.match(/:thread:(\d+)$/);
const topicMatch = restJoined.match(/:topic:([^:]+)$/);
const threadMatch = restJoined.match(/:thread:([^:]+)$/);
const match = topicMatch || threadMatch;
if (match) {
@@ -41,7 +41,7 @@ export function resolveAnnounceTargetFromKey(sessionKey: string): AnnounceTarget
}
// Remove :topic:N or :thread:N suffix from ID for target
const id = match ? restJoined.replace(/:(topic|thread):\d+$/, "") : restJoined.trim();
const id = match ? restJoined.replace(/:(topic|thread):[^:]+$/, "") : restJoined.trim();
if (!id) {
return null;