Skip to content

fix(chat): generate conversation titles in the UI locale#267

Merged
su-fen merged 2 commits into
Stack-Cairn:mainfrom
eric7h:feat/conversation-title-follow-locale
Jul 25, 2026
Merged

fix(chat): generate conversation titles in the UI locale#267
su-fen merged 2 commits into
Stack-Cairn:mainfrom
eric7h:feat/conversation-title-follow-locale

Conversation

@eric7h

@eric7h eric7h commented Jul 25, 2026

Copy link
Copy Markdown

Summary

  • Conversation title generation previously always used English system/user prompts, so users with Chinese UI still got English sidebar titles.
  • Title prompts now follow settings.locale (app default is zh-CN): Chinese UI → 简体中文标题; English UI → English titles.
  • CJK titles use a character-based length cap (24) instead of an English word cap that does not fit unspaced Chinese.

Why

LiveAgent UI default locale is already zh-CN, but conversationTitleJob hard-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) in chatPageHelpers.ts
  • startConversationTitleJob accepts locale and passes it into the title LLM call
  • useSendChatTurn passes settings.locale
  • unit tests for zh-CN / en-US prompts and CJK normalize

Test plan

  • node --test test/chat/messages.test.mjs (49 pass)
  • biome check on touched files
  • Manual: set Settings → Language to 简体中文, start a new chat with a Chinese first message, confirm sidebar title is Chinese
  • Manual: switch Language to English, new chat gets English title

Notes

  • Does not rewrite existing history titles (those remain until renamed / re-titled).
  • Official signed builds still come from upstream Releases; this PR needs merge + release to ship in installers. Local make dev / build-from-source can verify earlier.

X and others added 2 commits July 25, 2026 11:49
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>
@su-fen
su-fen merged commit 01f91ab into Stack-Cairn:main Jul 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants