fix: align routed delivery thread parsing

This commit is contained in:
Peter Steinberger
2026-05-16 16:54:21 +01:00
parent a4115ee9a2
commit 79df536780
3 changed files with 6 additions and 16 deletions

View File

@@ -1120,8 +1120,8 @@ describe("dispatchPreparedSlackMessage preview fallback", () => {
);
expect(updateLastRouteMock).toHaveBeenCalledWith({
storePath: "/tmp/openclaw-store.json",
sessionKey: "agent:main:main",
agentId: "main",
deliveryContext: {
channel: "slack",
to: "user:U1",
@@ -1129,6 +1129,7 @@ describe("dispatchPreparedSlackMessage preview fallback", () => {
threadId: "701.000",
},
ctx: {
MessageThreadId: undefined,
ReplyToId: "701.000",
TransportThreadId: "701.000",
SessionKey: "agent:main:main",

View File

@@ -1950,18 +1950,8 @@ Second paragraph should still reach the agent after Slack's preview cutoff.`;
});
it("preserves Slack thread history when an existing DM session receives a thread reply", async () => {
const { storePath } = storeFixture.makeTmpStorePath();
fs.writeFileSync(
storePath,
JSON.stringify(
{
"agent:main:main": { updatedAt: Date.now() },
"agent:main:main:thread:650.000": { updatedAt: Date.now() },
},
null,
2,
),
);
seedExistingSession("agent:main:main");
seedExistingSession("agent:main:main:thread:650.000");
const replies = vi
.fn()
.mockResolvedValueOnce({
@@ -1978,7 +1968,6 @@ Second paragraph should still reach the agent after Slack's preview cutoff.`;
});
const slackCtx = createInboundSlackCtx({
cfg: {
session: { store: storePath },
channels: { slack: { enabled: true, replyToMode: "all" } },
} as OpenClawConfig,
appClient: { conversations: { replies } } as unknown as App["client"],

View File

@@ -1,4 +1,4 @@
import { parseSessionThreadInfoFast } from "../../config/sessions/thread-info.js";
import { parseThreadSessionSuffix } from "../../routing/session-key.js";
import type { MsgContext } from "../templating.js";
export function resolveRoutedDeliveryThreadId(params: {
@@ -11,5 +11,5 @@ export function resolveRoutedDeliveryThreadId(params: {
if (params.ctx.TransportThreadId != null) {
return params.ctx.TransportThreadId;
}
return parseSessionThreadInfoFast(params.sessionKey).threadId;
return parseThreadSessionSuffix(params.sessionKey).threadId;
}