Skip to content

Commit 886dfe2

Browse files
committed
refactor: remove synthetic chat callback recovery
1 parent 0e0b896 commit 886dfe2

4 files changed

Lines changed: 2 additions & 27 deletions

File tree

‎src/shared/chat-content.test.ts‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Chat content tests cover message content normalization for chat surfaces.
21
import { describe, expect, it } from "vitest";
32
import { extractTextFromChatContent } from "./chat-content.js";
43

@@ -62,22 +61,4 @@ describe("shared/chat-content", () => {
6261
}),
6362
).toBeNull();
6463
});
65-
66-
it("tolerates sanitize and normalize hooks that return non-string values", () => {
67-
expect(
68-
extractTextFromChatContent("hello", {
69-
sanitizeText: () => undefined as unknown as string,
70-
}),
71-
).toBeNull();
72-
expect(
73-
extractTextFromChatContent([{ type: "text", text: "hello" }], {
74-
sanitizeText: () => 42 as unknown as string,
75-
}),
76-
).toBe("42");
77-
expect(
78-
extractTextFromChatContent("hello", {
79-
normalizeText: () => undefined as unknown as string,
80-
}),
81-
).toBeNull();
82-
});
8364
});

‎src/shared/chat-content.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ export function extractTextFromChatContent(
3333
normalizeText?: (text: string) => string;
3434
},
3535
): string | null {
36-
const normalizeText = opts?.normalizeText ?? ((text: string) => text.replace(/\s+/g, " ").trim());
36+
const normalize = opts?.normalizeText ?? ((text: string) => text.replace(/\s+/g, " ").trim());
3737
const joinWith = opts?.joinWith ?? " ";
3838
const sanitize = (text: unknown): string => {
3939
const raw = coerceChatContentText(text);
40-
const sanitized = opts?.sanitizeText ? opts.sanitizeText(raw) : raw;
41-
return coerceChatContentText(sanitized);
40+
return opts?.sanitizeText ? opts.sanitizeText(raw) : raw;
4241
};
43-
const normalize = (text: unknown): string =>
44-
coerceChatContentText(normalizeText(coerceChatContentText(text)));
4542

4643
if (typeof content === "string") {
4744
const value = sanitize(content);

‎src/shared/chat-envelope.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Chat envelope tests cover parsing and formatting channel-prefixed chat text.
21
import { describe, expect, it } from "vitest";
32
import { stripEnvelope, stripMessageIdHints } from "./chat-envelope.js";
43

‎src/shared/chat-envelope.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Chat envelope helpers parse and format channel prefixes in chat text.
21
const ENVELOPE_PREFIX = /^\[([^\]]+)\]\s*/;
32
const ENVELOPE_CHANNELS = [
43
"WebChat",
@@ -13,7 +12,6 @@ const ENVELOPE_CHANNELS = [
1312
"Matrix",
1413
"Zalo",
1514
"Zalo Personal",
16-
"iMessage",
1715
];
1816

1917
const MESSAGE_ID_LINE = /^\s*\[message_id:\s*[^\]]+\]\s*$/i;

0 commit comments

Comments
 (0)