mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix(matrix): keep draft previews mention-inert
This commit is contained in:
@@ -202,6 +202,7 @@ describe("createMatrixDraftStream", () => {
|
||||
.mockImplementation((text: string) => (text ? [text] : []));
|
||||
convertMarkdownTablesMock.mockReset().mockImplementation((text: string) => text);
|
||||
sendModuleMocks.editMessageMatrix.mockClear();
|
||||
sendModuleMocks.sendSingleTextMessageMatrix.mockClear();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -220,6 +221,11 @@ describe("createMatrixDraftStream", () => {
|
||||
|
||||
expect(sendMessageMock).toHaveBeenCalledTimes(1);
|
||||
expect(sentContentAt(0).msgtype).toBe("m.text");
|
||||
expect(sendModuleMocks.sendSingleTextMessageMatrix.mock.calls[0]?.[2]).toMatchObject({
|
||||
includeMentions: false,
|
||||
live: true,
|
||||
msgtype: "m.text",
|
||||
});
|
||||
expect(stream.eventId()).toBe("$evt1");
|
||||
});
|
||||
|
||||
|
||||
@@ -17,8 +17,11 @@ function resolveDraftPreviewOptions(mode: MatrixDraftPreviewMode): {
|
||||
includeMentions: false,
|
||||
};
|
||||
}
|
||||
// Drafts can contain partial model text and raw tool-progress paths; keep
|
||||
// Matrix mentions inert until callers send a normal final message.
|
||||
return {
|
||||
msgtype: MsgType.Text,
|
||||
includeMentions: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3097,7 +3097,7 @@ describe("matrix monitor handler draft streaming", () => {
|
||||
"draft options",
|
||||
);
|
||||
expect(draftOptions.msgtype).not.toBe("m.notice");
|
||||
expect(draftOptions.includeMentions).not.toBe(false);
|
||||
expect(draftOptions.includeMentions).toBe(false);
|
||||
|
||||
await deliver({ text: "Single block" }, { kind: "final" });
|
||||
|
||||
|
||||
@@ -716,6 +716,30 @@ describe("sendSingleTextMessageMatrix", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("supports partial draft preview sends without activating mention-looking text", async () => {
|
||||
const { client, sendMessage } = makeClient();
|
||||
|
||||
await sendSingleTextMessageMatrix(
|
||||
"room:!room:example",
|
||||
"Working...\n- `read matrix-progress-@room-@alice:example.org-!room:example.org.txt failed`",
|
||||
{
|
||||
client,
|
||||
cfg: {} as never,
|
||||
includeMentions: false,
|
||||
live: true,
|
||||
},
|
||||
);
|
||||
|
||||
const content = sentContent(sendMessage);
|
||||
expect(content.msgtype).toBe("m.text");
|
||||
expect(content).not.toHaveProperty("m.mentions");
|
||||
expect(content["org.matrix.msc4357.live"]).toEqual({});
|
||||
expect((content as { formatted_body?: string }).formatted_body).toContain(
|
||||
"<code>read matrix-progress-@room-@alice:example.org-!room:example.org.txt failed</code>",
|
||||
);
|
||||
expect((content as { formatted_body?: string }).formatted_body).not.toContain("matrix.to");
|
||||
});
|
||||
|
||||
it("does not activate mentions inside Matrix tool-progress code spans", async () => {
|
||||
const { client, sendMessage } = makeClient();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user