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;
}
if (ctx.threadBinding?.threadId) {
threadBindings.touchThread({ threadId: ctx.threadBinding.threadId });
const boundThreadId = ctx.threadBinding?.conversation?.conversationId?.trim();
if (boundThreadId && typeof threadBindings.touchThread === "function") {
threadBindings.touchThread({ threadId: boundThreadId });
}
const ackReaction = resolveAckReaction(cfg, route.agentId, {
channel: "discord",

View File

@@ -20,6 +20,7 @@ export type DiscordThreadBindingLookupRecord = {
export type DiscordThreadBindingLookup = {
listBySessionKey: (targetSessionKey: string) => DiscordThreadBindingLookupRecord[];
touchThread?: (params: { threadId: string; at?: number; persist?: boolean }) => unknown;
};
function resolveTargetChannelId(target: string): string | undefined {
@@ -272,6 +273,6 @@ export async function deliverDiscordReply(params: {
}
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",
boundBy: "system",
boundAt: Date.now(),
lastActivityAt: Date.now(),
label: "codex-thread",
} satisfies ThreadBindingRecord;
expect(resolveThreadBindingPersonaFromRecord(record)).toBe("⚙️ codex-thread");