From fb5079df230a04ab02a8091e3c23a9341b784086 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Wed, 16 Apr 2025 12:20:52 -0500 Subject: [PATCH 1/8] Hide new question button from hamburger menu --- assets/stylesheets/modules/ai-bot-conversations/common.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/stylesheets/modules/ai-bot-conversations/common.scss b/assets/stylesheets/modules/ai-bot-conversations/common.scss index b6da8210d..17bc64e46 100644 --- a/assets/stylesheets/modules/ai-bot-conversations/common.scss +++ b/assets/stylesheets/modules/ai-bot-conversations/common.scss @@ -1,3 +1,8 @@ +// Hide the new question button from the hamburger menu's footer +.hamburger-panel .ai-new-question-button { + display: none; +} + body.has-ai-conversations-sidebar { .sidebar-wrapper { .sidebar-footer-actions { From d4082fbf3641d34f3f692cac03122d617a07df59 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Wed, 16 Apr 2025 14:27:08 -0500 Subject: [PATCH 2/8] infinite scrolling working --- .../ai_bot/conversations_controller.rb | 40 ++++- .../initializers/ai-conversations-sidebar.js | 137 ++++++++++++------ 2 files changed, 124 insertions(+), 53 deletions(-) diff --git a/app/controllers/discourse_ai/ai_bot/conversations_controller.rb b/app/controllers/discourse_ai/ai_bot/conversations_controller.rb index ee8bbdb59..201a6ae4e 100644 --- a/app/controllers/discourse_ai/ai_bot/conversations_controller.rb +++ b/app/controllers/discourse_ai/ai_bot/conversations_controller.rb @@ -7,21 +7,47 @@ class ConversationsController < ::ApplicationController requires_login def index + page = params[:page]&.to_i || 0 + per_page = params[:per_page]&.to_i || 40 + # Step 1: Retrieve all AI bot user IDs bot_user_ids = EntryPoint.all_bot_ids # Step 2: Query for PM topics including current_user and any bot ID + #pms = + #Topic + #.private_messages_for_user(current_user) + #.joins(:topic_users) + #.where(topic_users: { user_id: bot_user_ids }) + #.distinct + #.order(last_posted_at: :desc) + #.offset(page * per_page) + #.limit(per_page) + + #total = Topic + #.private_messages_for_user(current_user) + #.joins(:topic_users) + #.where(topic_users: { user_id: bot_user_ids }) + #.distinct + #.count + pms = Topic .private_messages_for_user(current_user) - .joins(:topic_users) - .where(topic_users: { user_id: bot_user_ids }) - .distinct - - # Step 3: Serialize (empty array if no results) - serialized_pms = serialize_data(pms, BasicTopicSerializer) + .order(last_posted_at: :desc) + .offset(page * per_page) + .limit(per_page) + total = Topic.private_messages_for_user(current_user).count - render json: serialized_pms, status: 200 + render json: { + conversations: serialize_data(pms, BasicTopicSerializer), + meta: { + total: total, + page: page, + per_page: per_page, + more: total > (page + 1) * per_page, + }, + } end end end diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index 0ba05bd37..c0dd43b7f 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -1,7 +1,8 @@ import { tracked } from "@glimmer/tracking"; +import { TrackedArray } from "@ember-compat/tracked-built-ins"; import { ajax } from "discourse/lib/ajax"; +import { bind } from "discourse/lib/decorators"; import { withPluginApi } from "discourse/lib/plugin-api"; -import { i18n } from "discourse-i18n"; import AiBotSidebarNewConversation from "../discourse/components/ai-bot-sidebar-new-conversation"; import { AI_CONVERSATIONS_PANEL } from "../discourse/services/ai-conversations-sidebar-manager"; @@ -21,9 +22,6 @@ export default { return; } - // TODO: Replace - const recentConversations = 10; - // Step 1: Add a custom sidebar panel api.addSidebarPanel( (BaseCustomSidebarPanel) => class AiConversationsSidebarPanel extends BaseCustomSidebarPanel { @@ -31,10 +29,6 @@ export default { hidden = true; // Hide from panel switching UI displayHeader = true; expandActiveSection = true; - - // Optional - customize if needed - // switchButtonLabel = "Your Panel"; - // switchButtonIcon = "cog"; } ); @@ -44,8 +38,10 @@ export default { api.addSidebarSection( (BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => { return class extends BaseCustomSidebarSection { - @tracked links = []; + @tracked links = new TrackedArray(); @tracked topics = []; + @tracked hasMore = []; + page = 0; isFetching = false; totalTopicsCount = 0; @@ -60,27 +56,83 @@ export default { }); } - fetchMessages() { + willDestroy() { + const sidebar = this.sidebarElement; + if (sidebar) { + sidebar.removeEventListener("scroll", this.scrollHandler); + } + } + + @bind + didInsert() { + const sidebar = this.sidebarElement; + if (sidebar) { + sidebar.addEventListener("scroll", this.scrollHandler); + } + } + + get sidebarElement() { + return document.querySelector( + ".sidebar-wrapper .sidebar-sections" + ); + } + + @bind + scrollHandler() { + const sidebarElement = this.sidebarElement; + if (!sidebarElement) { + return; + } + + const scrollPosition = sidebarElement.scrollTop; + const scrollHeight = sidebarElement.scrollHeight; + const clientHeight = sidebarElement.clientHeight; + + // When user has scrolled to bottom with a small threshold + if (scrollHeight - scrollPosition - clientHeight < 100) { + if (this.hasMore && !this.isFetching) { + this.loadMore(); + } + } + } + + fetchMessages(isLoadingMore = false) { if (this.isFetching) { return; } this.isFetching = true; - ajax("/discourse-ai/ai-bot/conversations.json") + ajax("/discourse-ai/ai-bot/conversations.json", { + data: { page: this.page, per_page: 40 }, + }) .then((data) => { - this.topics = data.conversations.slice( - 0, - recentConversations - ); + if (isLoadingMore) { + // Append to existing topics + this.topics = [...this.topics, ...data.conversations]; + } else { + this.topics = data.conversations; + } + + this.totalTopicsCount = data.meta.total; + this.hasMore = data.meta.more; this.isFetching = false; this.buildSidebarLinks(); }) - .catch((e) => { + .catch(() => { this.isFetching = false; }); } + loadMore() { + if (this.isFetching || !this.hasMore) { + return; + } + + this.page = this.page + 1; + this.fetchMessages(true); + } + addNewMessage(newTopic) { // the pm endpoint isn't fast enough include the newly created topic // so this adds the new topic to the existing list @@ -98,36 +150,29 @@ export default { this.links = [builtTopic, ...this.links]; } - buildSidebarLinks() { - this.links = this.topics.map((topic) => { - return new (class extends BaseCustomSidebarSectionLink { - name = topic.title; - route = "topic.fromParamsNear"; - models = [ - topic.slug, - topic.id, - topic.last_read_post_number || 0, - ]; - title = topic.title; - text = topic.title; - prefixType = "icon"; - prefixValue = "robot"; - })(); - }); + createBotConversationLink(SuperClass, topic) { + return new (class extends SuperClass { + name = topic.title; + route = "topic.fromParamsNear"; + models = [ + topic.slug, + topic.id, + topic.last_read_post_number || 0, + ]; + title = topic.title; + text = topic.title; + prefixType = "icon"; + prefixValue = "robot"; + })(); + } - if (this.totalTopicsCount > recentConversations) { - this.links.push( - new (class extends BaseCustomSidebarSectionLink { - name = "View All"; - route = "userPrivateMessages.user.index"; - models = [currentUser.username]; - title = "View all..."; - text = "View all..."; - prefixType = "icon"; - prefixValue = "list"; - })() - ); - } + buildSidebarLinks() { + this.links = this.topics.map((topic) => + this.createBotConversationLink( + BaseCustomSidebarSectionLink, + topic + ) + ); } watchForTitleUpdate(topic) { @@ -139,7 +184,7 @@ export default { } get name() { - return "custom-messages"; + return "ai-conversations-history"; } get text() { From 7afe1bfdc999e46ca0762f484680964f2c14ab26 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Wed, 16 Apr 2025 15:58:44 -0500 Subject: [PATCH 3/8] hacky implementation of updating topic title --- .../ai-bot-conversations-hidden-submit.js | 7 ++++-- .../initializers/ai-conversations-sidebar.js | 24 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/assets/javascripts/discourse/services/ai-bot-conversations-hidden-submit.js b/assets/javascripts/discourse/services/ai-bot-conversations-hidden-submit.js index 3973b2528..d2f61bf3c 100644 --- a/assets/javascripts/discourse/services/ai-bot-conversations-hidden-submit.js +++ b/assets/javascripts/discourse/services/ai-bot-conversations-hidden-submit.js @@ -37,7 +37,8 @@ export default class AiBotConversationsHiddenSubmit extends Service { // borrowed from ai-bot-helper.js const draftKey = "new_private_message_ai_" + new Date().getTime(); - const personaWithUsername = this.currentUser.ai_enabled_personas.find( + // For now.. find a persona with a username.. + const selectedPersona = this.currentUser.ai_enabled_personas.find( (persona) => persona.username ); @@ -45,13 +46,15 @@ export default class AiBotConversationsHiddenSubmit extends Service { await this.composer.open({ action: Composer.PRIVATE_MESSAGE, draftKey, - recipients: personaWithUsername.username, + recipients: selectedPersona.username, topicTitle: i18n("discourse_ai.ai_bot.default_pm_prefix"), topicBody: this.inputValue, archetypeId: "private_message", disableDrafts: true, }); + this.composer.model.metaData = { ai_persona_id: selectedPersona.id }; + try { await this.composer.save(); if (this.inputValue.length > 10) { diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index c0dd43b7f..18bf4f52b 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -26,7 +26,7 @@ export default { (BaseCustomSidebarPanel) => class AiConversationsSidebarPanel extends BaseCustomSidebarPanel { key = AI_CONVERSATIONS_PANEL; - hidden = true; // Hide from panel switching UI + hidden = true; displayHeader = true; expandActiveSection = true; } @@ -34,7 +34,6 @@ export default { api.renderInOutlet("sidebar-footer-actions", AiBotSidebarNewConversation); - // Step 2: Add a custom section to your panel api.addSidebarSection( (BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => { return class extends BaseCustomSidebarSection { @@ -145,6 +144,7 @@ export default { text = newTopic.title; prefixType = "icon"; prefixValue = "robot"; + classNames = `ai-conversation-${newTopic.topic_id}`; })(); this.links = [builtTopic, ...this.links]; @@ -163,6 +163,7 @@ export default { text = topic.title; prefixType = "icon"; prefixValue = "robot"; + classNames = `ai-conversation-${topic.id}`; })(); } @@ -177,12 +178,23 @@ export default { watchForTitleUpdate(topic) { const channel = `/discourse-ai/ai-bot/topic/${topic.topic_id}`; - messageBus.subscribe(channel, () => { - this.fetchMessages(); + const topicId = topic.topic_id; + const callback = this.updateTopicTitle.bind(this); + messageBus.subscribe(channel, ({ title }) => { + callback(topicId, title); messageBus.unsubscribe(channel); }); } + updateTopicTitle(topicId, title) { + const text = document.querySelector( + `.sidebar-section-link-wrapper .ai-conversation-${topicId} .sidebar-section-link-content-text` + ); + if (text) { + text.innerText = title; + } + } + get name() { return "ai-conversations-history"; } @@ -192,10 +204,6 @@ export default { //return i18n(themePrefix("messages_sidebar.title")); return "Conversations"; } - - get displaySection() { - return this.links?.length > 0; - } }; }, AI_CONVERSATIONS_PANEL From 7a295c06476bd1f61ea6adbe3fff1888e9767737 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 17 Apr 2025 09:12:09 -0500 Subject: [PATCH 4/8] refactor sidebar forcing logic --- .../routes/discourse-ai-bot-conversations.js | 15 +------ .../initializers/ai-conversations-sidebar.js | 42 +++++++++---------- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/assets/javascripts/discourse/routes/discourse-ai-bot-conversations.js b/assets/javascripts/discourse/routes/discourse-ai-bot-conversations.js index 55d328ae7..08c4d8b15 100644 --- a/assets/javascripts/discourse/routes/discourse-ai-bot-conversations.js +++ b/assets/javascripts/discourse/routes/discourse-ai-bot-conversations.js @@ -1,16 +1,3 @@ -import { service } from "@ember/service"; import DiscourseRoute from "discourse/routes/discourse"; -export default class DiscourseAiBotConversationsRoute extends DiscourseRoute { - @service aiConversationsSidebarManager; - - activate() { - super.activate(...arguments); - this.aiConversationsSidebarManager.forceCustomSidebar(); - } - - deactivate() { - super.deactivate(...arguments); - this.aiConversationsSidebarManager.stopForcingCustomSidebar(); - } -} +export default class DiscourseAiBotConversationsRoute extends DiscourseRoute {} diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index 18bf4f52b..d08d34e5b 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -209,28 +209,26 @@ export default { AI_CONVERSATIONS_PANEL ); - api.modifyClass( - "route:topic", - (Superclass) => - class extends Superclass { - activate() { - super.activate(); - const topic = this.modelFor("topic"); - if ( - topic && - topic.archetype === "private_message" && - topic.ai_persona_name - ) { - aiConversationsSidebarManager.forceCustomSidebar(); - } - } - - deactivate() { - super.activate(); - aiConversationsSidebarManager.stopForcingCustomSidebar(); - } - } - ); + const setSidebarPanel = (transition) => { + if (transition?.to?.name === "discourse-ai-bot-conversations") { + return aiConversationsSidebarManager.forceCustomSidebar(); + } + + const topic = api.container.lookup("route:topic").modelFor("topic"); + if ( + topic && + topic.archetype === "private_message" && + topic.ai_persona_name + ) { + return aiConversationsSidebarManager.forceCustomSidebar(); + } + + aiConversationsSidebarManager.stopForcingCustomSidebar(); + }; + + api.container + .lookup("service:router") + .on("routeDidChange", setSidebarPanel); }); }, }; From dad1584299a43492129cd9c1bf1ea45c906b1971 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 17 Apr 2025 09:15:37 -0500 Subject: [PATCH 5/8] get model from controller not route --- assets/javascripts/initializers/ai-conversations-sidebar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index d08d34e5b..6ffee9cb1 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -214,7 +214,7 @@ export default { return aiConversationsSidebarManager.forceCustomSidebar(); } - const topic = api.container.lookup("route:topic").modelFor("topic"); + const topic = api.container.lookup("controller:topic").model; if ( topic && topic.archetype === "private_message" && From eda32880c8be56a6c0c9858e06d696c5bbdaf115 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 17 Apr 2025 09:34:07 -0500 Subject: [PATCH 6/8] keep infinite scroll working on transition --- .../javascripts/initializers/ai-conversations-sidebar.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index 6ffee9cb1..9863efdc8 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -56,6 +56,11 @@ export default { } willDestroy() { + this.removeScrollListener(); + } + + @bind + removeScrollListener() { const sidebar = this.sidebarElement; if (sidebar) { sidebar.removeEventListener("scroll", this.scrollHandler); @@ -63,7 +68,7 @@ export default { } @bind - didInsert() { + attachScrollListener() { const sidebar = this.sidebarElement; if (sidebar) { sidebar.addEventListener("scroll", this.scrollHandler); @@ -116,7 +121,9 @@ export default { this.totalTopicsCount = data.meta.total; this.hasMore = data.meta.more; this.isFetching = false; + this.removeScrollListener(); this.buildSidebarLinks(); + this.attachScrollListener(); }) .catch(() => { this.isFetching = false; From 1a1a8fa1685a62f285196fc8262e8a157ba7dc56 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 17 Apr 2025 10:09:14 -0500 Subject: [PATCH 7/8] lots of cleanup --- .../initializers/ai-conversations-sidebar.js | 130 +++++++++--------- 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index 9863efdc8..53d74ce97 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -36,6 +36,41 @@ export default { api.addSidebarSection( (BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => { + const AiConversationLink = class extends BaseCustomSidebarSectionLink { + route = "topic.fromParamsNear"; + prefixType = "icon"; + prefixValue = "robot"; + + constructor(topic) { + super(...arguments); + this.topic = topic; + } + + get name() { + return this.topic.title; + } + + get models() { + return [ + this.topic.slug, + this.topic.id, + this.topic.last_read_post_number || 0, + ]; + } + + get title() { + return this.topic.title; + } + + get text() { + return this.topic.title; + } + + get classNames() { + return `ai-conversation-${this.topic.id}`; + } + }; + return class extends BaseCustomSidebarSection { @tracked links = new TrackedArray(); @tracked topics = []; @@ -48,17 +83,38 @@ export default { super(...arguments); this.fetchMessages(); - appEvents.on("topic:created", (topic) => { - // when asking a new question - this.addNewMessage(topic); - this.watchForTitleUpdate(topic); - }); + appEvents.on("topic:created", this, "addNewMessageToSidebar"); } + @bind willDestroy() { this.removeScrollListener(); + appEvents.on("topic:created", this, "addNewMessageToSidebar"); + } + +get name() { + return "ai-conversations-history"; + } + + get text() { + // TODO: FIX + //return i18n(themePrefix("messages_sidebar.title")); + return "Conversations"; + } + + get sidebarElement() { + return document.querySelector( + ".sidebar-wrapper .sidebar-sections" + ); } + addNewMessageToSidebar(topic) { + this.addNewMessage(topic); + this.watchForTitleUpdate(topic); + } + + + @bind removeScrollListener() { const sidebar = this.sidebarElement; @@ -75,12 +131,6 @@ export default { } } - get sidebarElement() { - return document.querySelector( - ".sidebar-wrapper .sidebar-sections" - ); - } - @bind scrollHandler() { const sidebarElement = this.sidebarElement; @@ -108,7 +158,7 @@ export default { this.isFetching = true; ajax("/discourse-ai/ai-bot/conversations.json", { - data: { page: this.page, per_page: 40 }, + data: { page: this.page, per_page: 20 }, }) .then((data) => { if (isLoadingMore) { @@ -139,50 +189,16 @@ export default { this.fetchMessages(true); } - addNewMessage(newTopic) { - // the pm endpoint isn't fast enough include the newly created topic - // so this adds the new topic to the existing list - const builtTopic = - new (class extends BaseCustomSidebarSectionLink { - name = newTopic.title; - route = "topic.fromParamsNear"; - models = [newTopic.topic_slug, newTopic.topic_id, 0]; - title = newTopic.title; - text = newTopic.title; - prefixType = "icon"; - prefixValue = "robot"; - classNames = `ai-conversation-${newTopic.topic_id}`; - })(); - - this.links = [builtTopic, ...this.links]; - } - - createBotConversationLink(SuperClass, topic) { - return new (class extends SuperClass { - name = topic.title; - route = "topic.fromParamsNear"; - models = [ - topic.slug, - topic.id, - topic.last_read_post_number || 0, - ]; - title = topic.title; - text = topic.title; - prefixType = "icon"; - prefixValue = "robot"; - classNames = `ai-conversation-${topic.id}`; - })(); - } - buildSidebarLinks() { - this.links = this.topics.map((topic) => - this.createBotConversationLink( - BaseCustomSidebarSectionLink, - topic - ) + this.links = this.topics.map( + (topic) => new AiConversationLink(topic) ); } + addNewMessage(newTopic) { + this.links = [new AiConversationLink(newTopic), ...this.links]; + } + watchForTitleUpdate(topic) { const channel = `/discourse-ai/ai-bot/topic/${topic.topic_id}`; const topicId = topic.topic_id; @@ -201,16 +217,6 @@ export default { text.innerText = title; } } - - get name() { - return "ai-conversations-history"; - } - - get text() { - // TODO: FIX - //return i18n(themePrefix("messages_sidebar.title")); - return "Conversations"; - } }; }, AI_CONVERSATIONS_PANEL From 2b3d18bd5698b2ab2393deb478d17c9207d0a95e Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 17 Apr 2025 10:10:39 -0500 Subject: [PATCH 8/8] remove testing hack for more PMs in sidebar --- .../ai_bot/conversations_controller.rb | 31 +++++++------------ .../initializers/ai-conversations-sidebar.js | 7 ++--- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/app/controllers/discourse_ai/ai_bot/conversations_controller.rb b/app/controllers/discourse_ai/ai_bot/conversations_controller.rb index 201a6ae4e..af5952b79 100644 --- a/app/controllers/discourse_ai/ai_bot/conversations_controller.rb +++ b/app/controllers/discourse_ai/ai_bot/conversations_controller.rb @@ -10,34 +10,25 @@ def index page = params[:page]&.to_i || 0 per_page = params[:per_page]&.to_i || 40 - # Step 1: Retrieve all AI bot user IDs bot_user_ids = EntryPoint.all_bot_ids - # Step 2: Query for PM topics including current_user and any bot ID - #pms = - #Topic - #.private_messages_for_user(current_user) - #.joins(:topic_users) - #.where(topic_users: { user_id: bot_user_ids }) - #.distinct - #.order(last_posted_at: :desc) - #.offset(page * per_page) - #.limit(per_page) - - #total = Topic - #.private_messages_for_user(current_user) - #.joins(:topic_users) - #.where(topic_users: { user_id: bot_user_ids }) - #.distinct - #.count - pms = Topic .private_messages_for_user(current_user) + .joins(:topic_users) + .where(topic_users: { user_id: bot_user_ids }) + .distinct .order(last_posted_at: :desc) .offset(page * per_page) .limit(per_page) - total = Topic.private_messages_for_user(current_user).count + + total = + Topic + .private_messages_for_user(current_user) + .joins(:topic_users) + .where(topic_users: { user_id: bot_user_ids }) + .distinct + .count render json: { conversations: serialize_data(pms, BasicTopicSerializer), diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index 53d74ce97..77bbc646c 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -92,7 +92,7 @@ export default { appEvents.on("topic:created", this, "addNewMessageToSidebar"); } -get name() { + get name() { return "ai-conversations-history"; } @@ -113,8 +113,6 @@ get name() { this.watchForTitleUpdate(topic); } - - @bind removeScrollListener() { const sidebar = this.sidebarElement; @@ -158,11 +156,10 @@ get name() { this.isFetching = true; ajax("/discourse-ai/ai-bot/conversations.json", { - data: { page: this.page, per_page: 20 }, + data: { page: this.page, per_page: 40 }, }) .then((data) => { if (isLoadingMore) { - // Append to existing topics this.topics = [...this.topics, ...data.conversations]; } else { this.topics = data.conversations;