fix(chat): generate conversation titles in the UI locale#267
Merged
su-fen merged 2 commits intoJul 25, 2026
Conversation
Title generation previously always used English system/user prompts, so Chinese UI users still got English sidebar titles. Follow settings.locale (default zh-CN) for title prompts and use a CJK-aware length cap.
normalizeConversationTitle also sanitizes what the user types in the
sidebar rename box, so putting the new 24-character CJK cap inside it
silently truncated hand-typed Chinese titles, and cut latin titles
mid-word whenever they contained a single CJK token ("Fix 中文 encoding
in the parser module and add regression tests" -> "Fix 中文 encoding in
the p"). The WebUI rename path does not cap at all, so the same rename
also behaved differently on the two frontends.
Move the cap into normalizeGeneratedConversationTitle, used only by the
title job:
- it applies only when the title is predominantly CJK, so a latin title
with a stray CJK token keeps the word cap;
- it slices by code point, so an astral char on the boundary no longer
leaves a lone surrogate rendering as U+FFFD;
- normalizeConversationTitle is back to its previous behaviour, so
renames are untouched.
Also make locale required on startConversationTitleJob and on both prompt
builders: with a zh-CN default, a future caller that forgets to pass it
would hand English-UI users Chinese titles.
Tests: the previous CJK case was exactly 24 characters, so it asserted
nothing about truncation. Replaced with longer literal expectations plus
mixed-script and astral-boundary cases, and the title-job test now
asserts the locale actually reaches the model request for both locales.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
settings.locale(app default iszh-CN): Chinese UI → 简体中文标题; English UI → English titles.Why
LiveAgent UI default locale is already
zh-CN, butconversationTitleJobhard-coded English prompts like "You generate concise conversation titles..." and "generate a title within 10 words". Models therefore defaulted to English titles.Changes
buildConversationTitleSystemPrompt(locale)/buildConversationTitlePrompt(content, locale)inchatPageHelpers.tsstartConversationTitleJobacceptslocaleand passes it into the title LLM calluseSendChatTurnpassessettings.localeTest plan
node --test test/chat/messages.test.mjs(49 pass)biome checkon touched filesNotes
make dev/ build-from-source can verify earlier.