Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit f9fc6ec

Browse files
committed
DEV: Load authored pms with any bot id
1 parent c9df623 commit f9fc6ec

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

app/controllers/discourse_ai/ai_bot/conversations_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ def index
1414
base_query =
1515
Topic
1616
.private_messages_for_user(current_user)
17+
.where(user: current_user) # Only show PMs where the current user is the author
1718
.joins(:topic_users)
1819
.where(topic_users: { user_id: bot_user_ids })
1920
.distinct
21+
2022
total = base_query.count
2123
pms = base_query.order(last_posted_at: :desc).offset(page * per_page).limit(per_page)
2224

assets/javascripts/initializers/ai-conversations-sidebar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,11 @@ export default {
232232
}
233233

234234
const topic = api.container.lookup("controller:topic").model;
235+
// if the topic is not a private message, not created by the current user,
236+
// or doesn't have a bot response, we don't need to override sidebar
235237
if (
236238
topic?.archetype === "private_message" &&
239+
topic.user_id === currentUser.id &&
237240
topic.postStream.posts.some((post) =>
238241
isPostFromAiBot(post, currentUser)
239242
)

0 commit comments

Comments
 (0)