fix(chat): đổi tên hội thoại thì tiêu đề khung chat đổi theo ngay

Đổi tên một hội thoại ở cột lịch sử (chuột phải → Đổi tên) thì tiêu đề khung
chat bên phải vẫn giữ tên cũ, phải click ra ngoài rồi click lại mới đổi. Tệ hơn,
self.title cũ vẫn nằm trong bộ nhớ nên lượt chat kế tiếp lưu đè tên cũ lên tên
người dùng vừa đặt.

- HistorySidebar phát conversation_renamed(session_id, title); WorkspaceTab nối
  vào apply_renamed_title của Cowork. Hội thoại đang mở thì đổi luôn self.title
  và làm mới thanh tiêu đề.
- Tiêu đề hội thoại chỉ hiện tối đa 10 ký tự, dư thì "…", tên đầy đủ ở tooltip.
  Áp cho cả thanh tiêu đề khung chat lẫn danh sách hội thoại trong project
  (dùng chung clip_chars). Hộp thoại Đổi tên vẫn điền tên đầy đủ.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
minhanhpkpro
2026-09-25 14:40:05 +09:00
co-authored by Claude Opus 5.5
parent ddb31f9aff
commit fefc9f94db
6 changed files with 129 additions and 2 deletions
+17
View File
@@ -224,6 +224,23 @@ class ChatSessionMixin:
if getattr(self, "_usage_total_lbl", None) is not None:
self.refresh_usage()
def set_title_label(self, lbl, fallback: str) -> None:
"""Đặt tiêu đề hội thoại lên nhãn: tối đa 10 ký tự, bản đầy đủ ở tooltip."""
from .chat_helpers import clip_chars
full = self.title or fallback
lbl.setText(clip_chars(full))
lbl.setToolTip(full)
def apply_renamed_title(self, session_id: str, title: str) -> None:
"""Hội thoại đang mở vừa được đổi tên ở cột lịch sử: đổi luôn ``self.title``.
Không chỉ để thanh tiêu đề cập nhật ngay — lượt chat kế tiếp lưu bằng
``self.title``, giữ tên cũ sẽ ghi đè mất tên người dùng vừa đặt."""
if session_id and session_id == self.session_id:
self.title = title
self._notify_title()
def load_conversation(self, conv: Dict[str, Any]) -> None:
"""Switch the view to a stored conversation. Allowed while work is running —
the current turns keep going in the background."""