- Canonicalized assistant and thinking messages by trimming and collapsing dot text. - Skipped rendering assistant and thinking blocks when canonicalized content was empty. - Filtered ACP thinking notifications and session outputs to ignore placeholder content. - Added canonicalizeMessage tests for undefined, blank, whitespace, and dot-only inputs.
12 lines
364 B
TypeScript
12 lines
364 B
TypeScript
export function canonicalizeMessage(text: string | null | undefined): string {
|
|
if (!text) return "";
|
|
const trimmed = text.trim();
|
|
for (let i = 0; i < trimmed.length; i++) {
|
|
const code = trimmed.charCodeAt(i);
|
|
if (code !== 0x2e && code !== 0x2026 && code !== 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) {
|
|
return trimmed;
|
|
}
|
|
}
|
|
return "";
|
|
}
|