Skip to content

Commit bb79c08

Browse files
authored
fix(dashboard): drop stale exclude_ids hardcode hiding conversations (#10129)
The dashboard conversation pages hardcoded exclude_ids="astrbot", and the backend expanded each entry into `user_id NOT LIKE '<id>%'`. Since user_id is the UMO "<platform_id>:<message_type>:<session_id>", every conversation of a platform whose adapter id is "astrbot" (or any id starting with it) was filtered out and the list showed 0 items (#10126). The parameter never matched the built-in WebChat sessions it presumably targeted (their UMO starts with "webchat:"), so it has had no functional effect since it was introduced; remove it instead of replacing it. Tighten the remaining exclude_ids semantics for API callers: match only the exact user_id or its platform segment ("id:...") and escape LIKE wildcards, so "astrbot" no longer swallows "astrbotweb". Fixes #10126
1 parent f99c76e commit bb79c08

4 files changed

Lines changed: 67 additions & 9 deletions

File tree

‎astrbot/core/db/sqlite.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,23 @@ async def get_filtered_conversations(
433433
conditions.append(col(ConversationV2.platform_id).in_(platforms))
434434
exclude_ids = kwargs.get("exclude_ids") or []
435435
for exclude_id in exclude_ids:
436+
# Match the whole UMO or its platform segment only, so an id
437+
# like "astrbot" does not swallow platforms such as
438+
# "astrbotweb". Escape LIKE wildcards inside the id itself.
439+
escaped = (
440+
exclude_id.replace("\\", "\\\\")
441+
.replace("%", r"\%")
442+
.replace("_", r"\_")
443+
)
436444
conditions.append(
437-
not_(col(ConversationV2.user_id).like(f"{exclude_id}%"))
445+
not_(
446+
or_(
447+
col(ConversationV2.user_id) == exclude_id,
448+
col(ConversationV2.user_id).like(
449+
f"{escaped}:%", escape="\\"
450+
),
451+
)
452+
)
438453
)
439454
exclude_platforms = kwargs.get("exclude_platforms") or []
440455
if exclude_platforms:

‎dashboard/src/views/ConversationPage.vue‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ export default {
802802
params.search = search;
803803
}
804804
805-
params.exclude_ids = 'astrbot';
806805
params.include_history = false;
807806
808807
const response = await conversationApi.list(params, {

‎dashboard/src/views/conversation/ConversationWorkspacePage.vue‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,7 @@ async function fetchConversations() {
355355
group_by_session: groupBySession.value,
356356
};
357357
if (keyword.value.trim()) params.keyword = keyword.value.trim();
358-
if (umoQuery.value.trim()) {
359-
params.umo = umoQuery.value.trim();
360-
} else {
361-
params.exclude_ids = "astrbot";
362-
}
358+
if (umoQuery.value.trim()) params.umo = umoQuery.value.trim();
363359
if (selectedBotIds.value.length) {
364360
params.platforms = selectedBotIds.value.join(",");
365361
}

‎tests/test_conversation_list.py‎

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ async def test_filtered_conversations_summary_skips_content_and_applies_filters(
6060
created_at=datetime(2023, 1, 1, tzinfo=timezone.utc),
6161
updated_at=datetime(2023, 1, 1, tzinfo=timezone.utc),
6262
),
63+
ConversationV2(
64+
conversation_id="astrbotweb",
65+
platform_id="astrbotweb",
66+
user_id="astrbotweb:GroupMessage:9",
67+
content=[{"role": "assistant", "content": "kept"}],
68+
created_at=datetime(2025, 6, 1, tzinfo=timezone.utc),
69+
updated_at=datetime(2025, 6, 1, tzinfo=timezone.utc),
70+
),
71+
ConversationV2(
72+
conversation_id="astrbot-legacy",
73+
platform_id="astrbot",
74+
user_id="astrbot",
75+
content=[{"role": "assistant", "content": "excluded"}],
76+
created_at=datetime(2022, 1, 1, tzinfo=timezone.utc),
77+
updated_at=datetime(2022, 1, 1, tzinfo=timezone.utc),
78+
),
6379
]
6480
async with db.get_db() as session:
6581
async with session.begin():
@@ -74,10 +90,11 @@ async def test_filtered_conversations_summary_skips_content_and_applies_filters(
7490
exclude_platforms=["webchat"],
7591
)
7692

77-
assert total == 3
93+
assert total == 4
7894
assert [item.conversation_id for item in summary] == [
7995
"friend",
8096
"group",
97+
"astrbotweb",
8198
"other",
8299
]
83100
assert all("content" in sqlalchemy_inspect(item).unloaded for item in summary)
@@ -96,6 +113,33 @@ async def test_filtered_conversations_summary_skips_content_and_applies_filters(
96113
assert all(item.history == "[]" for item in manager_summary)
97114
assert all(json.loads(item.history) == [] for item in manager_summary)
98115

116+
# exclude_ids must match only the exact user_id or its platform segment,
117+
# so "astrbot" does not swallow "astrbotweb", while a colon-less legacy
118+
# user_id "astrbot" is still matched exactly.
119+
segment_matches, segment_total = await db.get_filtered_conversations(
120+
page=1,
121+
page_size=10,
122+
include_history=False,
123+
exclude_ids=["astrbot"],
124+
)
125+
assert segment_total == 5
126+
assert [item.conversation_id for item in segment_matches] == [
127+
"friend",
128+
"group",
129+
"astrbotweb",
130+
"other",
131+
"webchat",
132+
]
133+
134+
# LIKE wildcards inside an exclude id must stay literal.
135+
_, wildcard_total = await db.get_filtered_conversations(
136+
page=1,
137+
page_size=10,
138+
include_history=False,
139+
exclude_ids=["%"],
140+
)
141+
assert wildcard_total == 7
142+
99143
title_matches, _ = await db.get_filtered_conversations(
100144
search_query="中文标题",
101145
include_history=False,
@@ -119,7 +163,7 @@ async def test_filtered_conversations_summary_skips_content_and_applies_filters(
119163
assert keyword_does_not_match_umo == []
120164

121165
full, full_total = await db.get_filtered_conversations(page_size=10)
122-
assert full_total == 5
166+
assert full_total == 7
123167
assert all("content" not in sqlalchemy_inspect(item).unloaded for item in full)
124168

125169
umo_matches, _ = await db.get_filtered_conversations(
@@ -135,14 +179,18 @@ async def test_filtered_conversations_summary_skips_content_and_applies_filters(
135179
include_history=False,
136180
)
137181
assert [item.conversation_id for item in updated_ascending] == [
182+
"astrbot-legacy",
138183
"astrbot",
139184
"webchat",
140185
"other",
186+
"astrbotweb",
141187
"group",
142188
"friend",
143189
]
144190

145191
assert await db.get_conversation_platform_ids() == [
192+
"astrbot",
193+
"astrbotweb",
146194
"qq",
147195
"telegram",
148196
"webchat",

0 commit comments

Comments
 (0)