fix(queue): use null checks for thread ID instead of typeof number

The queue drain logic used typeof threadId === "number" to detect
thread IDs, but Slack thread timestamps are strings (e.g.
"1769742846.264069"). This caused queued replies to lose thread
context and post as top-level channel messages.

Replace all three typeof === "number" checks with != null so both
string and numeric thread IDs are handled correctly.

Fixes #4380
This commit is contained in:
Ayush Ojha 2026-01-30 00:20:47 -08:00
parent 9025da2296
commit 90ebd51d70

View File

@ -40,13 +40,13 @@ export function scheduleFollowupDrain(
const to = item.originatingTo; const to = item.originatingTo;
const accountId = item.originatingAccountId; const accountId = item.originatingAccountId;
const threadId = item.originatingThreadId; const threadId = item.originatingThreadId;
if (!channel && !to && !accountId && typeof threadId !== "number") { if (!channel && !to && !accountId && threadId == null) {
return {}; return {};
} }
if (!isRoutableChannel(channel) || !to) { if (!isRoutableChannel(channel) || !to) {
return { cross: true }; return { cross: true };
} }
const threadKey = typeof threadId === "number" ? String(threadId) : ""; const threadKey = threadId != null ? String(threadId) : "";
return { return {
key: [channel, to, accountId || "", threadKey].join("|"), key: [channel, to, accountId || "", threadKey].join("|"),
}; };
@ -72,7 +72,7 @@ export function scheduleFollowupDrain(
(i) => i.originatingAccountId, (i) => i.originatingAccountId,
)?.originatingAccountId; )?.originatingAccountId;
const originatingThreadId = items.find( const originatingThreadId = items.find(
(i) => typeof i.originatingThreadId === "number", (i) => i.originatingThreadId != null,
)?.originatingThreadId; )?.originatingThreadId;
const prompt = buildCollectPrompt({ const prompt = buildCollectPrompt({