fix: tighten isSilentReplyText to match whole-text only

The suffix regex matched NO_REPLY at the end of any response,
suppressing substantive replies when models (e.g. Gemini 3 Pro)
appended NO_REPLY to real content.

Replace prefix+suffix regexes with a single whole-string match.
Only responses that are entirely the silent token (with optional
whitespace) are now suppressed.

Add unit tests for the fix.

Fixes #19537
This commit is contained in:
HAL
2026-02-17 18:02:20 -06:00
committed by Ayaan Zaidi
parent a7d56e3554
commit 2f2110a32c
2 changed files with 41 additions and 6 deletions

View File

@@ -11,12 +11,10 @@ export function isSilentReplyText(
return false;
}
const escaped = escapeRegExp(token);
const prefix = new RegExp(`^\\s*${escaped}(?=$|\\W)`);
if (prefix.test(text)) {
return true;
}
const suffix = new RegExp(`\\b${escaped}\\b\\W*$`);
return suffix.test(text);
// Only match when the entire response (trimmed) is the silent token,
// optionally surrounded by whitespace/punctuation. This prevents
// substantive replies ending with NO_REPLY from being suppressed (#19537).
return new RegExp(`^\\s*${escaped}\\s*$`).test(text);
}
export function isSilentReplyPrefixText(