fix(matrix): keep draft previews mention-inert · openclaw/openclaw@96eec2a
vincentkoc
·
2026-05-27
·
via Recent Commits to openclaw:main
File tree
extensions/matrix/src/matrix
| Original file line number | Diff line number | Diff line change |
|---|
@@ -202,6 +202,7 @@ describe("createMatrixDraftStream", () => {
|
202 | 202 | .mockImplementation((text: string) => (text ? [text] : [])); |
203 | 203 | convertMarkdownTablesMock.mockReset().mockImplementation((text: string) => text); |
204 | 204 | sendModuleMocks.editMessageMatrix.mockClear(); |
| 205 | +sendModuleMocks.sendSingleTextMessageMatrix.mockClear(); |
205 | 206 | }); |
206 | 207 | |
207 | 208 | afterEach(() => { |
@@ -220,6 +221,11 @@ describe("createMatrixDraftStream", () => {
|
220 | 221 | |
221 | 222 | expect(sendMessageMock).toHaveBeenCalledTimes(1); |
222 | 223 | expect(sentContentAt(0).msgtype).toBe("m.text"); |
| 224 | +expect(sendModuleMocks.sendSingleTextMessageMatrix.mock.calls[0]?.[2]).toMatchObject({ |
| 225 | +includeMentions: false, |
| 226 | +live: true, |
| 227 | +msgtype: "m.text", |
| 228 | +}); |
223 | 229 | expect(stream.eventId()).toBe("$evt1"); |
224 | 230 | }); |
225 | 231 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,8 +17,11 @@ function resolveDraftPreviewOptions(mode: MatrixDraftPreviewMode): {
|
17 | 17 | includeMentions: false, |
18 | 18 | }; |
19 | 19 | } |
| 20 | +// Drafts can contain partial model text and raw tool-progress paths; keep |
| 21 | +// Matrix mentions inert until callers send a normal final message. |
20 | 22 | return { |
21 | 23 | msgtype: MsgType.Text, |
| 24 | +includeMentions: false, |
22 | 25 | }; |
23 | 26 | } |
24 | 27 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3097,7 +3097,7 @@ describe("matrix monitor handler draft streaming", () => {
|
3097 | 3097 | "draft options", |
3098 | 3098 | ); |
3099 | 3099 | expect(draftOptions.msgtype).not.toBe("m.notice"); |
3100 | | -expect(draftOptions.includeMentions).not.toBe(false); |
| 3100 | +expect(draftOptions.includeMentions).toBe(false); |
3101 | 3101 | |
3102 | 3102 | await deliver({ text: "Single block" }, { kind: "final" }); |
3103 | 3103 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -716,6 +716,30 @@ describe("sendSingleTextMessageMatrix", () => {
|
716 | 716 | ); |
717 | 717 | }); |
718 | 718 | |
| 719 | +it("supports partial draft preview sends without activating mention-looking text", async () => { |
| 720 | +const { client, sendMessage } = makeClient(); |
| 721 | + |
| 722 | +await sendSingleTextMessageMatrix( |
| 723 | +"room:!room:example", |
| 724 | +"Working...\n- `read matrix-progress-@room-@alice:example.org-!room:example.org.txt failed`", |
| 725 | +{ |
| 726 | + client, |
| 727 | +cfg: {} as never, |
| 728 | +includeMentions: false, |
| 729 | +live: true, |
| 730 | +}, |
| 731 | +); |
| 732 | + |
| 733 | +const content = sentContent(sendMessage); |
| 734 | +expect(content.msgtype).toBe("m.text"); |
| 735 | +expect(content).not.toHaveProperty("m.mentions"); |
| 736 | +expect(content["org.matrix.msc4357.live"]).toEqual({}); |
| 737 | +expect((content as { formatted_body?: string }).formatted_body).toContain( |
| 738 | +"<code>read matrix-progress-@room-@alice:example.org-!room:example.org.txt failed</code>", |
| 739 | +); |
| 740 | +expect((content as { formatted_body?: string }).formatted_body).not.toContain("matrix.to"); |
| 741 | +}); |
| 742 | + |
719 | 743 | it("does not activate mentions inside Matrix tool-progress code spans", async () => { |
720 | 744 | const { client, sendMessage } = makeClient(); |
721 | 745 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。