Merge: paliadin meta-trailer defensive strip in renderer
Some checks are pending
Paliad CI gate / build (push) Waiting to run
Paliad CI gate / test-go (push) Waiting to run
Paliad CI gate / deploy (push) Blocked by required conditions

This commit is contained in:
mAi
2026-06-01 19:53:35 +02:00

View File

@@ -89,7 +89,17 @@ function renderBlocks(escapedHtml: string): string {
return out.join("");
}
// The [paliadin-meta] … [/paliadin-meta] trailer is internal telemetry
// (used_tools / rows_seen / classifier_tag) that the backend is meant to
// strip. Defensively strip it here too so it can NEVER reach the user even
// when the backend's strip misses it (e.g. an empty meta block on a greeting,
// or a chunk the aichat backend didn't catch). It always sits at the end,
// optionally preceded by a `---` separator, so we cut from the opener to EOS —
// which also handles a truncated/unterminated trailer.
const META_TRAILER_RE = /\n*\s*(?:-{3,}\s*\n+)?\[paliadin-meta\][\s\S]*$/i;
export function renderResponseHTML(raw: string): string {
raw = raw.replace(META_TRAILER_RE, "").replace(/\s+$/, "");
let html = raw
.replace(/&/g, "&")
.replace(/</g, "&lt;")