Skip to content

fix(session): generate session titles in English - #331

Open
srbose wants to merge 2 commits into
OpenCoworkAI:mainfrom
srbose:fix/english-session-titles
Open

fix(session): generate session titles in English#331
srbose wants to merge 2 commits into
OpenCoworkAI:mainfrom
srbose:fix/english-session-titles

Conversation

@srbose

@srbose srbose commented Aug 16, 2026

Copy link
Copy Markdown

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.ts was 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.

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>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review mode: initial

Findings

  • [Minor] Hardcoded English title generation ignores the app's i18n support. The app supports Chinese and English UI (i18n via 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 in src/tests/main/session/session-title-utils.test.ts that 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.

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 buildTitlePrompt as described above; verify no existing test relies on the Chinese prompt strings.

Open Cowork Bot

Co-Authored-By: Claude <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-40 always 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

@srbose

srbose commented Aug 16, 2026

Copy link
Copy Markdown
Author

Thanks for the review. To answer the open question: forcing English titles is intentional for this PR.

Rationale:

  • The actual bug is that the bilingual prompt let the model pick a title language inconsistently — English conversations were getting Chinese titles while the rest of the UI stayed English. Making the instruction deterministic (English-only) fixes that directly.
  • The reported case is exactly this: an English UI (locale en) showing Chinese sidebar titles, so the fixed behavior now matches the UI.
  • Chinese-UI users lose native-language auto-titles, but titles remain editable by the user, and the chat content language is unaffected.

Your suggested locale-aware buildTitlePrompt(prompt, locale) is a good follow-up (e.g. pass the renderer's i18n locale into the title flow); I've noted it in the PR description as future work rather than expanding this change now.

The test additions were updated accordingly in the second commit.

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.

1 participant