mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-20 18:44:58 +00:00
Matrix: tighten fallback resolution and ACP lookup
This commit is contained in:
@@ -83,11 +83,6 @@ function normalizeMatrixThreadTarget(raw: string): string | undefined {
|
||||
return normalized || undefined;
|
||||
}
|
||||
|
||||
function normalizeMatrixDirectUserTarget(raw: string): string | undefined {
|
||||
const normalized = normalizeMatrixThreadTarget(raw);
|
||||
return normalized?.startsWith("@") ? normalized : undefined;
|
||||
}
|
||||
|
||||
export function resolveMatrixAutoThreadId(params: {
|
||||
to: string;
|
||||
toolContext?: ChannelThreadingToolContext;
|
||||
@@ -101,15 +96,11 @@ export function resolveMatrixAutoThreadId(params: {
|
||||
if (!target || !currentChannel) {
|
||||
return undefined;
|
||||
}
|
||||
// Matrix user:@ targets resolve to a DM room at send time, which can differ
|
||||
// from the current room after DM recreation or stale m.direct ordering.
|
||||
// Only auto-thread when the explicit room target already matches.
|
||||
if (target.toLowerCase() !== currentChannel.toLowerCase()) {
|
||||
const directTarget = normalizeMatrixDirectUserTarget(params.to);
|
||||
const currentDirectUserId = normalizeMatrixDirectUserTarget(context.currentDirectUserId ?? "");
|
||||
if (!directTarget || !currentDirectUserId) {
|
||||
return undefined;
|
||||
}
|
||||
if (directTarget.toLowerCase() !== currentDirectUserId.toLowerCase()) {
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
return context.currentThreadTs;
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ describe("runMessageAction threading auto-injection", () => {
|
||||
expect(call?.ctx?.params?.threadId).toBe("$explicit");
|
||||
});
|
||||
|
||||
it("injects threadId for matching Matrix dm user target", async () => {
|
||||
it("skips threadId for Matrix dm user targets until the resolved room matches", async () => {
|
||||
mockHandledSendAction();
|
||||
|
||||
const call = await runThreadingAction({
|
||||
@@ -322,8 +322,8 @@ describe("runMessageAction threading auto-injection", () => {
|
||||
toolContext: defaultMatrixDmToolContext,
|
||||
});
|
||||
|
||||
expect(call?.threadId).toBe("$thread");
|
||||
expect(call?.ctx?.params?.threadId).toBe("$thread");
|
||||
expect(call?.threadId).toBeUndefined();
|
||||
expect(call?.ctx?.params?.threadId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("skips threadId for different Matrix dm user target", async () => {
|
||||
|
||||
@@ -115,6 +115,10 @@ export {
|
||||
resolveMatrixLegacyFlatStoragePaths,
|
||||
sanitizeMatrixPathSegment,
|
||||
} from "../infra/matrix-storage-paths.js";
|
||||
export {
|
||||
requiresExplicitMatrixDefaultAccount,
|
||||
resolveMatrixDefaultOrOnlyAccountId,
|
||||
} from "../infra/matrix-account-selection.js";
|
||||
export {
|
||||
hasActionableMatrixMigration,
|
||||
hasPendingMatrixMigration,
|
||||
|
||||
Reference in New Issue
Block a user