fix(session): generate session titles in English - #331
Conversation
The title prompt was bilingual (English + Chinese) and told the model to reply in the same language as the user request. In practice models such as DeepSeek often picked Chinese even for English conversations, so the chat list filled up with Chinese titles while the rest of the UI was English. Make the prompt English-only and always generate English titles. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Review mode: initial
Findings
-
[Minor] Hardcoded English title generation ignores the app's i18n support. The app supports Chinese and English UI (
i18nvia i18next, Chinese + English), but this change always instructs the model to reply in English (src/main/session/session-title-utils.ts:40). For users with the Chinese UI, session titles will remain in English even though the rest of the app is localized. This is a product tradeoff and is acknowledged in the PR description, but it is a regression for Chinese-speaking users.
Suggested fix: derive the title language from the user's locale instead of hardcoding English, e.g.:export function buildTitlePrompt(prompt: string, locale = 'en'): string { const isZh = locale.toLowerCase().startsWith('zh'); return [ isZh ? '根据用户请求生成一个简短的英文对话标题,规则如下:' : 'Generate a short title for the following user request. Rules:', '- Max 6 words (English)', '- Always reply in English, even if the user request is in another language', '- No quotes, numbering, or punctuation at the end', '', `User request: ${prompt.trim()}`, ].join('\n'); }
Note: this would require threading the locale through the call site. If the team prefers the minimal fix, at least document the behavior.
-
[Nit] No test changes accompany the prompt change. If there are existing unit tests asserting the old bilingual prompt content, they will fail; no new tests cover the English-only behavior.
Suggested fix: add a unit test insrc/tests/main/session/session-title-utils.test.tsthat asserts:- the built prompt contains
'Always reply in English, even if the user request is in another language' - it does not contain the removed Chinese instruction
'请根据用户请求生成一个简短的对话标题' - it includes the trimmed user request.
- the built prompt contains
Questions
- Is forcing English titles acceptable for all locales, or should this follow the app's current UI language? (The PR description notes this as a future extension, but it would be helpful to confirm it is intentionally not part of this change.)
Summary
Review mode: initial
- Review policy: advisory — the check reflects automation health/completion only; it does not approve the PR or resolve findings.
- The diff only modifies
buildTitlePrompt. No security, correctness, or data-loss issues were identified. The main risks are the hardcoded English behavior for non-English UI locales and missing test coverage.
Testing
- Not run (automation). Suggested: add/update unit tests for
buildTitlePromptas described above; verify no existing test relies on the Chinese prompt strings.
Open Cowork Bot
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Findings
- [Minor] Hardcoded English title language ignores the app's i18n support. The newly added instructions at
src/main/session/session-title-utils.ts:39-40always force an English title even when the user's UI is Chinese. Open Cowork supports both English and Chinese localization (i18next), so this is a product tradeoff: it fixes the reported Chinese-title issue but keeps sidebar titles non-localized for Chinese-UI users. The PR body acknowledges this as future work. If this is intentional, no code change is needed; if locale-aware titles are desired:
export function buildTitlePrompt(prompt: string, locale = 'en'): string {
const isZh = locale.toLowerCase().startsWith('zh');
return [
'Generate a short title for the following user request. Rules:',
isZh ? '- Max 15 characters (Chinese)' : '- Max 6 words (English)',
isZh ? '- Reply in Chinese' : '- Always reply in English, even if the user request is in another language',
'- No quotes, numbering, or punctuation at the end',
'',
`User request: ${prompt.trim()}`,
].join('\n');
}This requires threading the locale through the call site. If the minimal change is preferred, documenting the behavior is sufficient.
Questions
- Is forcing English titles acceptable for all locales, or should this follow the app's current UI language? (The PR description notes this as a future extension, but it would be helpful to confirm it is intentionally out of scope.)
Summary
Review mode: follow-up after new commits
- Review policy: advisory — the check reflects automation health/completion only; it does not approve the PR or resolve findings.
- The new commit adds a test for the English-only prompt behavior and removes the old Chinese-language assertions, addressing the previously reported missing test coverage.
- The Minor i18n finding remains: the English-only title prompt is not locale-aware. No correctness, security, regression, or data-loss issues were found.
- Residual risk: the fix relies on the model following the instruction; some models may occasionally return non-English titles despite the prompt.
Testing
- Not run (automation). The updated test covers the main behavior; consider also asserting that other removed Chinese strings (e.g., '不超过15个字') are absent and that
prompt.trim()is included in the prompt.
Open Cowork Bot
|
Thanks for the review. To answer the open question: forcing English titles is intentional for this PR. Rationale:
Your suggested locale-aware The test additions were updated accordingly in the second commit. |
Problem
Session titles in the chat list were generated in Chinese even for conversations held entirely in English. The title prompt in
session-title-utils.tswas bilingual (English + Chinese instructions) and told the model to "reply in the same language as the user request" — in practice, models such as DeepSeek picked Chinese for English chats, so the sidebar filled up with Chinese titles while the rest of the UI stayed English.Fix
Make the title prompt English-only and always instruct the model to generate English titles, matching the app's UI.
Notes
If multi-language titles are desired in the future, this could be extended to follow the app's i18n locale instead of being fixed to English. This PR intentionally keeps the change minimal.