Discord: fix thread binding types in message/reply paths

This commit is contained in:
Onur
2026-02-26 23:27:09 +01:00
parent 3e2118caa8
commit 7853c4fb7f
3 changed files with 6 additions and 3 deletions

View File

@@ -117,8 +117,9 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
return; return;
} }
if (ctx.threadBinding?.threadId) { const boundThreadId = ctx.threadBinding?.conversation?.conversationId?.trim();
threadBindings.touchThread({ threadId: ctx.threadBinding.threadId }); if (boundThreadId && typeof threadBindings.touchThread === "function") {
threadBindings.touchThread({ threadId: boundThreadId });
} }
const ackReaction = resolveAckReaction(cfg, route.agentId, { const ackReaction = resolveAckReaction(cfg, route.agentId, {
channel: "discord", channel: "discord",

View File

@@ -20,6 +20,7 @@ export type DiscordThreadBindingLookupRecord = {
export type DiscordThreadBindingLookup = { export type DiscordThreadBindingLookup = {
listBySessionKey: (targetSessionKey: string) => DiscordThreadBindingLookupRecord[]; listBySessionKey: (targetSessionKey: string) => DiscordThreadBindingLookupRecord[];
touchThread?: (params: { threadId: string; at?: number; persist?: boolean }) => unknown;
}; };
function resolveTargetChannelId(target: string): string | undefined { function resolveTargetChannelId(target: string): string | undefined {
@@ -272,6 +273,6 @@ export async function deliverDiscordReply(params: {
} }
if (binding && deliveredAny) { if (binding && deliveredAny) {
params.threadBindings?.touchThread({ threadId: binding.threadId }); params.threadBindings?.touchThread?.({ threadId: binding.threadId });
} }
} }

View File

@@ -26,6 +26,7 @@ describe("thread binding persona", () => {
agentId: "codex", agentId: "codex",
boundBy: "system", boundBy: "system",
boundAt: Date.now(), boundAt: Date.now(),
lastActivityAt: Date.now(),
label: "codex-thread", label: "codex-thread",
} satisfies ThreadBindingRecord; } satisfies ThreadBindingRecord;
expect(resolveThreadBindingPersonaFromRecord(record)).toBe("⚙️ codex-thread"); expect(resolveThreadBindingPersonaFromRecord(record)).toBe("⚙️ codex-thread");