Skip to content

fix(acp): never let an English auto-summary replace a Chinese title - #1103

Open
gongcavalry wants to merge 2 commits into
spacering-net:mainfrom
gongcavalry:pr/zh-title-protection
Open

gongcavalry wants to merge 2 commits into
spacering-net:mainfrom
gongcavalry:pr/zh-title-protection

Conversation

@gongcavalry

Copy link
Copy Markdown
Contributor

Problem

Cursor and Grok publish an English auto-summary right after the first prompt. When the user opened the chat in Chinese, that English summary overwrites the Chinese title and becomes the conversation's only name in the sidebar.

Fix

adopt_prompt_title now refuses an ASCII-only incoming title when the stored title already contains CJK characters (title_has_cjk). A Chinese title is therefore never clobbered by a later English auto-summary; titles without CJK behave exactly as before.

Tests

  • New unit tests cover: CJK title kept over English replacement, English title still updates, empty/ASCII transitions.
  • cargo test --lib adopt_prompt passes.

Made with Cursor

Cursor and Grok publish an English summary right after the first prompt.
When the user opened the chat in Chinese, that summary must not become
the conversation's only name: a title containing CJK is kept over an
incoming ASCII-only replacement.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI 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.

🟡 Changes recommended

Non-atomic title updates can overwrite protected Chinese names, while follow-up prompts or attachment filenames can incorrectly rename existing conversations.

3 open issues
What changed in this PR

This PR aims to preserve Chinese conversation names in Codeg’s sidebar when agents publish English summaries after a user prompt.

Changes:

  • Adds an ideograph-based guard to shared automatic title refreshes.
  • Introduces prompt-title adoption and uses it after successful ACP sends.
  • Adds regression tests for Chinese-title preservation and prompt adoption.
File Description
src-tauri/​src/​db/​service/​conversation_service.rs Adds title detection, refresh protection, prompt adoption, and tests.
src-tauri/​src/​acp/​manager.rs Uses prompt-title adoption after successful sends and updates explanatory comments.

Review effort: Max

{
match conversation_service::seed_auto_title_if_empty(&db.conn, cid, title)
.await
match conversation_service::adopt_prompt_title(&db.conn, cid, title).await

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — fixed in 8c21827. Title adoption now uses only the prompt's own prose (new prompt_text_title, text blocks only), and adopt_prompt_title only replaces a non-CJK title on the conversation's opening prompt (message_count == 0). A follow-up like 继续 or an upload like 报告.pdf now degrades to seed_auto_title_if_empty: it can fill an untitled row but never renames a titled chat. Regression tests added for both cases.

Comment on lines +229 to +231
if let Some(row) = conversation::Entity::find_by_id(conversation_id)
.one(conn)
.await?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8c21827. The CJK guard is now atomic with the write: refresh_auto_title re-reads the row and issues a compare-and-swap UPDATE whose WHERE matches the observed title, so an English refresh that read a NULL/English title no longer lands after a concurrent Chinese write — the UPDATE matches nothing and the loop re-checks instead of overwriting.

Comment on lines +312 to +324
let Some(row) = conversation::Entity::find_by_id(conversation_id)
.one(conn)
.await?
else {
return Ok(false);
};
if row.title_locked || row.deleted_at.is_some() {
return Ok(false);
}
if row.title.as_deref().is_some_and(title_has_cjk) {
return Ok(false);
}
refresh_auto_title(conn, conversation_id, title.to_string()).await

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8c21827. adopt_prompt_title uses the same compare-and-swap shape (cas_title): the UPDATE matches the observed title, and on a failed match it re-reads the row and re-checks the CJK, lock, and deletion guards (one retry) instead of overwriting the Chinese name that landed in between.

…tion

- Make the Chinese-title guard atomic with the write: refresh_auto_title
  and adopt_prompt_title now compare-and-swap on the observed title, so a
  Chinese name landing between read and write is re-checked, never
  overwritten.
- Adopt only prose from the conversation's OPENING prompt (message_count
  == 0): a follow-up like 继续 degrades to seed_auto_title_if_empty and
  can no longer rename an agent-titled chat.
- Attachment filenames are never adoption material (prompt_text_title is
  text-blocks-only); attachment-only prompts merely seed an empty row.

Co-authored-by: Cursor <cursoragent@cursor.com>
gongcavalry added a commit to gongcavalry/codeg that referenced this pull request Nov 7, 2026
Copilot 评审后的原子标题守卫和 Cursor 模型回补已在 PR 分支上 CI 全绿,本机日常包仍是评审前版本。三路合并进 bc,重启后与已回捐的修复一致。

Co-authored-by: Cursor <cursoragent@cursor.com>
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