fix(hud): catch the UNAVAILABLE word flush against Han and keep multi-word names whole

Han and kana have no word edges, so a CJK forbidden word now counts anywhere
in the reply. The proxy no longer counts words: the model reads Rue de Rivoli
as one, so only the 80-character word-boundary cap remains.

Also restore src/voice/gevActions.test.mjs, reformatted by mistake in 818d2c82.
This commit is contained in:
German Khokhlov committed 2026-11-02 17:13:58 +04:00
1 parent 818d2c8295
commit 645e13aeaa
5 files changed
+645 -2164

No files matched your search

+5 -4
View File
@@ -37,12 +37,12 @@ function parseHudSummaryReply(text, locale) {
? reply.feedState
: null;
return {
summary: toFiveWordHudSummary(reply?.summary, locale),
summary: toHudSummary(reply?.summary, locale),
feedState,
};
}
function toFiveWordHudSummary(value, requested) {
function toHudSummary(value, requested) {
const locale = hudSummaryLocale(requested);
const words = String(value || '')
.normalize('NFC')
@@ -55,7 +55,8 @@ function toFiveWordHudSummary(value, requested) {
// Japanese and Chinese have no spaces to count words by: cap characters.
if (hudSummaryIsUnspaced(locale))
return capAtWord(words.join(' '), HUD_SUMMARY_MAX_UNSPACED_CHARS, locale);
return capAtWord(words.slice(0, 5).join(' '), HUD_SUMMARY_MAX_CHARS, locale);
// No word count: the model counts Rue de Rivoli as one word.
return capAtWord(words.join(' '), HUD_SUMMARY_MAX_CHARS, locale);
}
/**
@@ -170,4 +171,4 @@ async function handleHudSummary(req, res) {
}
}
export { handleHudSummary };
export { handleHudSummary, parseHudSummaryReply };