fix: tighten shared chat envelope coverage

This commit is contained in:
Peter Steinberger
2026-03-13 22:00:22 +00:00
parent 2fe4c4f8e5
commit fb4aa7eaba
2 changed files with 3 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ describe("shared/chat-envelope", () => {
expect(stripEnvelope("hello")).toBe("hello");
expect(stripEnvelope("[note] hello")).toBe("[note] hello");
expect(stripEnvelope("[2026/01/24 13:36] hello")).toBe("[2026/01/24 13:36] hello");
expect(stripEnvelope("[Teams] hello")).toBe("[Teams] hello");
});
it("removes standalone message id hint lines but keeps inline mentions", () => {
@@ -21,6 +22,7 @@ describe("shared/chat-envelope", () => {
expect(stripMessageIdHints("hello\n [message_id: abc123] \nworld")).toBe("hello\nworld");
expect(stripMessageIdHints("[message_id: abc123]\nhello")).toBe("hello");
expect(stripMessageIdHints("[message_id: abc123]")).toBe("");
expect(stripMessageIdHints("hello\r\n[MESSAGE_ID: abc123]\r\nworld")).toBe("hello\nworld");
expect(stripMessageIdHints("I typed [message_id: abc123] inline")).toBe(
"I typed [message_id: abc123] inline",
);

View File

@@ -39,7 +39,7 @@ export function stripEnvelope(text: string): string {
}
export function stripMessageIdHints(text: string): string {
if (!text.includes("[message_id:")) {
if (!/\[message_id:/i.test(text)) {
return text;
}
const lines = text.split(/\r?\n/);