fix: use null check instead of typeof number for thread IDs in queue drain
Slack thread_ts values are always strings (e.g. "1769742846.264069"), so the typeof === "number" checks never matched, causing queued replies to lose their thread context and post as top-level channel messages. Replace all three typeof === "number" checks with != null to handle both string (Slack) and numeric thread IDs. Fixes #4380
This commit is contained in:
parent
87267fad4f
commit
ca54412bd4
@ -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("|"),
|
||||||
};
|
};
|
||||||
@ -61,7 +61,10 @@ export function scheduleFollowupDrain(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const items = queue.items.splice(0, queue.items.length);
|
const items = queue.items.splice(0, queue.items.length);
|
||||||
const summary = buildQueueSummaryPrompt({ state: queue, noun: "message" });
|
const summary = buildQueueSummaryPrompt({
|
||||||
|
state: queue,
|
||||||
|
noun: "message",
|
||||||
|
});
|
||||||
const run = items.at(-1)?.run ?? queue.lastRun;
|
const run = items.at(-1)?.run ?? queue.lastRun;
|
||||||
if (!run) break;
|
if (!run) break;
|
||||||
|
|
||||||
@ -72,7 +75,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({
|
||||||
@ -93,7 +96,10 @@ export function scheduleFollowupDrain(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const summaryPrompt = buildQueueSummaryPrompt({ state: queue, noun: "message" });
|
const summaryPrompt = buildQueueSummaryPrompt({
|
||||||
|
state: queue,
|
||||||
|
noun: "message",
|
||||||
|
});
|
||||||
if (summaryPrompt) {
|
if (summaryPrompt) {
|
||||||
const run = queue.lastRun;
|
const run = queue.lastRun;
|
||||||
if (!run) break;
|
if (!run) break;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user