mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-11 03:38:02 +00:00
fix: keep a tag's name when the last chat using it is archived (#32200)
This commit is contained in:
parent
d04f78b3bf
commit
78550396da
2 changed files with 2 additions and 4 deletions
|
|
@ -2522,7 +2522,7 @@ class ChatTable:
|
|||
columns = []
|
||||
for index, tag_id in enumerate(tag_ids):
|
||||
tag_id = tag_id.replace(' ', '_').lower()
|
||||
stmt = select(func.count(Chat.id)).filter_by(user_id=user_id, archived=False)
|
||||
stmt = select(func.count(Chat.id)).filter_by(user_id=user_id)
|
||||
stmt = stmt.where(Chat.meta['internal'].as_boolean().is_not(True))
|
||||
param = f'tag_id_{index}'
|
||||
if dialect_name == 'sqlite':
|
||||
|
|
@ -2550,7 +2550,7 @@ class ChatTable:
|
|||
db: AsyncSession | None = None,
|
||||
) -> None:
|
||||
"""Delete tag rows from *tag_ids* that appear in at most *threshold*
|
||||
non-archived chats for *user_id*. One query to find orphans, one to
|
||||
chats for *user_id*. One query to find orphans, one to
|
||||
delete them.
|
||||
|
||||
Use threshold=0 after a tag is already removed from a chat's meta.
|
||||
|
|
|
|||
|
|
@ -2014,8 +2014,6 @@ async def archive_chat_by_id(
|
|||
if chat.archived:
|
||||
# Cancel any in-flight LLM tasks before archiving
|
||||
await stop_item_tasks(request.app.state.redis, id)
|
||||
# Archived chats are excluded from count — clean up orphans
|
||||
await Chats.delete_orphan_tags_for_user(tag_ids, user.id, db=db)
|
||||
else:
|
||||
# Unarchived — ensure tag rows exist
|
||||
await Tags.ensure_tags_exist(tag_ids, user.id, db=db)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue