From a86dab246e0cfc037f8567ceff4988aa859e722c Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 11 Jul 2026 23:37:38 -0500 Subject: [PATCH] refac --- cptr/frontend/src/lib/components/GroupTabBar.svelte | 2 +- cptr/models/chats.py | 10 ++++++++++ cptr/utils/chat_task.py | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cptr/frontend/src/lib/components/GroupTabBar.svelte b/cptr/frontend/src/lib/components/GroupTabBar.svelte index 0c5f9fc..587ad1f 100644 --- a/cptr/frontend/src/lib/components/GroupTabBar.svelte +++ b/cptr/frontend/src/lib/components/GroupTabBar.svelte @@ -427,7 +427,7 @@ {tab.type === 'files' ? ($activeWorkspace?.name ?? $t('bar.files')) : tab.label} - {#if tab.type === 'chat' && isChatUnread(chatStatus)} + {#if tab.type === 'chat' && !isActive && isChatUnread(chatStatus)} {/if} {#if tab.unsaved}{/if} diff --git a/cptr/models/chats.py b/cptr/models/chats.py index f5be8cb..56805fc 100644 --- a/cptr/models/chats.py +++ b/cptr/models/chats.py @@ -111,6 +111,16 @@ class Chat(Base): await db.commit() return result.rowcount > 0 + @staticmethod + async def touch(chat_id: str, updated_at: int) -> bool: + """Record a completed background update without changing chat content.""" + async with await get_db() as db: + result = await db.execute( + update(Chat).where(Chat.id == chat_id).values(updated_at=updated_at) + ) + await db.commit() + return result.rowcount > 0 + @staticmethod async def update_last_read_at(chat_id: str, user_id: str, last_read_at: int) -> bool: """Mark a chat read without changing its activity timestamp.""" diff --git a/cptr/utils/chat_task.py b/cptr/utils/chat_task.py index aa492a0..88c2846 100644 --- a/cptr/utils/chat_task.py +++ b/cptr/utils/chat_task.py @@ -2638,6 +2638,7 @@ async def run_chat_task( _task_chat.pop(message_id, None) if chat_id not in get_active_chat_ids(): try: + await Chat.touch(chat_id, now_ms()) chat = await Chat.get_by_id(chat_id) await emit_to_user( user_id,