A platform for community discussion. Free, open, simple.
DEV: remove `ai_bot_enable_dedicated_ux` setting (#35301)
Kris991f2af69ead
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-header-icon.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-header-icon.gjsindex d50b3a4f5ca..eccae7c0ad4 100644--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-header-icon.gjs+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-header-icon.gjs@@ -6,12 +6,10 @@ import PluginOutlet from "discourse/components/plugin-outlet";import lazyHash from "discourse/helpers/lazy-hash";import getURL from "discourse/lib/get-url";import { i18n } from "discourse-i18n";-import { composeAiBotMessage } from "../lib/ai-bot-helper";import { AI_CONVERSATIONS_PANEL } from "../services/ai-conversations-sidebar-manager";export default class AiBotHeaderIcon extends Component {@service appEvents;- @service composer;@service currentUser;@service navigationMenu;@service sidebarState;@@ -48,7 +46,6 @@ export default class AiBotHeaderIcon extends Component {get clickShouldRouteOutOfConversations() {return (!this.navigationMenu.isHeaderDropdownMode &&- this.siteSettings.ai_bot_enable_dedicated_ux &&this.sidebarState.currentPanel?.key === AI_CONVERSATIONS_PANEL);}@@ -58,23 +55,12 @@ export default class AiBotHeaderIcon extends Component {return getURL(this.aiConversationsSidebarManager.lastKnownAppURL || "/");}- if (this.siteSettings.ai_bot_enable_dedicated_ux) {- return getURL("/discourse-ai/ai-bot/conversations");- }-- return null;+ return getURL("/discourse-ai/ai-bot/conversations");}@actiononClick() {- if (!this.siteSettings.ai_bot_enable_dedicated_ux) {- composeAiBotMessage(this.bots[0], this.composer);- }-- if (- this.siteSettings.ai_bot_enable_dedicated_ux &&- !this.clickShouldRouteOutOfConversations- ) {+ if (!this.clickShouldRouteOutOfConversations) {this.appEvents.trigger("discourse-ai:bot-header-icon-clicked");}}diff --git a/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-conversations-sidebar.js b/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-conversations-sidebar.jsindex 8e9d91f421f..111272e2051 100644--- a/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-conversations-sidebar.js+++ b/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-conversations-sidebar.js@@ -7,11 +7,6 @@ export default {initialize() {withPluginApi((api) => {- const siteSettings = api.container.lookup("service:site-settings");- if (!siteSettings.ai_bot_enable_dedicated_ux) {- return;- }-const currentUser = api.container.lookup("service:current-user");if (!currentUser) {return;diff --git a/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-bot-helper.js b/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-bot-helper.jsindex cc4ce758d4a..702cbfedb50 100644--- a/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-bot-helper.js+++ b/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-bot-helper.js@@ -1,8 +1,6 @@import { ajax } from "discourse/lib/ajax";import { popupAjaxError } from "discourse/lib/ajax-error";import { getOwnerWithFallback } from "discourse/lib/get-owner";-import Composer from "discourse/models/composer";-import { i18n } from "discourse-i18n";import ShareFullTopicModal from "../components/modal/share-full-topic-modal";const MAX_PERSONA_USER_ID = -1200;@@ -59,44 +57,3 @@ export function showShareConversationModal(modal, topicId) {}).catch(popupAjaxError);}--export async function composeAiBotMessage(- targetBot,- composer,- options = {- skipFocus: false,- topicBody: "",- personaUsername: null,- }-) {- const currentUser = composer.currentUser;- const draftKey = "new_private_message_ai_" + new Date().getTime();-- let botUsername;- if (targetBot) {- botUsername = currentUser.ai_enabled_chat_bots.find(- (bot) => bot.model_name === targetBot- )?.username;- } else if (options.personaUsername) {- botUsername = options.personaUsername;- } else {- botUsername = currentUser.ai_enabled_chat_bots[0].username;- }-- const data = {- action: Composer.PRIVATE_MESSAGE,- recipients: botUsername,- topicTitle: i18n("discourse_ai.ai_bot.default_pm_prefix"),- archetypeId: "private_message",- draftKey,- hasGroups: false,- warningsDisabled: true,- };-- if (options.skipFocus) {- data.topicBody = options.topicBody;- await composer.open(data);- } else {- composer.focusComposer({ fallbackToNewTopic: true, openOpts: data });- }-}diff --git a/plugins/discourse-ai/assets/stylesheets/modules/ai-bot/common/bot-replies.scss b/plugins/discourse-ai/assets/stylesheets/modules/ai-bot/common/bot-replies.scssindex 9579b7bd719..05d19dec7c7 100644--- a/plugins/discourse-ai/assets/stylesheets/modules/ai-bot/common/bot-replies.scss+++ b/plugins/discourse-ai/assets/stylesheets/modules/ai-bot/common/bot-replies.scss@@ -2,27 +2,6 @@ nav.post-controls .actions button.cancel-streaming {display: none;}-.ai-bot-chat {- #reply-control {- .user-selector,- .title-and-category,- #private-message-users {- display: none;- }- }-- .persona-llm-selector {- display: flex;- justify-content: space-between;- align-items: center;-- .select-kit.single-select.dropdown-select-box ul.select-kit-collection {- max-height: 200px;- }- margin-bottom: 1em;- }-}-.ai-bot-pm {.gpt-persona {margin-bottom: 5px;diff --git a/plugins/discourse-ai/config/locales/server.en.yml b/plugins/discourse-ai/config/locales/server.en.ymlindex 4a5f9cb7a4c..f224142a967 100644--- a/plugins/discourse-ai/config/locales/server.en.yml+++ b/plugins/discourse-ai/config/locales/server.en.yml@@ -140,7 +140,6 @@ en:ai_discord_search_mode: "Select the search mode to use for Discord search"ai_discord_search_persona: "The persona to use for Discord search."ai_discord_allowed_guilds: "Discord guilds (servers) where the bot is allowed to search"- ai_bot_enable_dedicated_ux: "Allow for full screen bot interface, instead of a PM"ai_translation_enabled: "Enable the AI translation feature"ai_translation_model: "The model to use for translation. This model must support translation. Personas can override this setting."diff --git a/plugins/discourse-ai/config/settings.yml b/plugins/discourse-ai/config/settings.ymlindex 39ac1656381..5123459d0a6 100644--- a/plugins/discourse-ai/config/settings.yml+++ b/plugins/discourse-ai/config/settings.yml@@ -493,10 +493,6 @@ discourse_ai:default: falsehidden: true- ai_bot_enable_dedicated_ux:- default: true- client: true-ai_translation_enabled:default: falseclient: truediff --git a/plugins/discourse-ai/db/post_migrate/20251009141725_remove_ai_bot_enable_dedicated_ux_setting.rb b/plugins/discourse-ai/db/post_migrate/20251009141725_remove_ai_bot_enable_dedicated_ux_setting.rbnew file mode 100644index 00000000000..f5574627346--- /dev/null+++ b/plugins/discourse-ai/db/post_migrate/20251009141725_remove_ai_bot_enable_dedicated_ux_setting.rb@@ -0,0 +1,11 @@+# frozen_string_literal: true++class RemoveAiBotEnableDedicatedUxSetting < ActiveRecord::Migration[7.1]+ def up+ execute "DELETE FROM site_settings WHERE name = 'ai_bot_enable_dedicated_ux'"+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end+enddiff --git a/plugins/discourse-ai/spec/system/ai_bot/ai_bot_helper_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/ai_bot_helper_spec.rbindex 62dc2eae146..5aac61659a6 100644--- a/plugins/discourse-ai/spec/system/ai_bot/ai_bot_helper_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/ai_bot_helper_spec.rb@@ -18,49 +18,4 @@ RSpec.describe "AI chat channel summarization", type: :system dovisit "/latest"expect(page).not_to have_selector(".ai-bot-button")end-- it "shows the AI bot button, which is clickable (even if group is hidden)" do- # test was authored with this in mind- SiteSetting.ai_bot_enable_dedicated_ux = false- group.add(user)- group.save-- allowed_persona = AiPersona.last- allowed_persona.update!(allowed_group_ids: [group.id], enabled: true)-- # second persona to ensure dropdown shows (requires >1 option)- second_persona = Fabricate(:ai_persona, allowed_group_ids: [group.id], enabled: true)- second_persona.update!(allow_personal_messages: true)-- visit "/latest"- expect(page).to have_selector(".ai-bot-button")- find(".ai-bot-button").click-- find(".gpt-persona").click- expect(page).to have_css(".gpt-persona ul li", count: 2)-- find(".llm-selector").click- expect(page).to have_css(".llm-selector ul li", count: 2)-- expect(page).to have_selector(".d-editor-container")-- allowed_persona.create_user!- allowed_persona.update!(default_llm_id: gpt_4.id)- second_persona.create_user!- second_persona.update!(default_llm_id: gpt_4.id)-- gpt_4.update!(enabled_chat_bot: false)- gpt_3_5_turbo.update!(enabled_chat_bot: false)-- visit "/latest"- find(".ai-bot-button").click-- find(".gpt-persona").click- expect(page).to have_css(".gpt-persona ul li", count: 2)- expect(page).not_to have_selector(".llm-selector")-- SiteSetting.ai_bot_add_to_header = false- visit "/latest"- expect(page).not_to have_selector(".ai-bot-button")- endenddiff --git a/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rbindex 9ea7586ccd6..a69496a0616 100644--- a/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rb@@ -17,7 +17,6 @@ RSpec.describe "AI Bot - Header Toggle", type: :system doSiteSetting.ai_bot_enabled = truetoggle_enabled_bots(bots: [gpt_4, gpt_3_5_turbo])SiteSetting.ai_bot_allowed_groups = group.id.to_s- SiteSetting.ai_bot_enable_dedicated_ux = trueSiteSetting.ai_bot_add_to_header = trueSiteSetting.navigation_menu = "sidebar"diff --git a/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rbindex dbb7157a060..b2af0feec2d 100644--- a/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb@@ -101,7 +101,6 @@ RSpec.describe "AI Bot - Homepage", type: :system dopm.custom_fields[DiscourseAi::AiBot::TOPIC_AI_BOT_PM_FIELD] = "t"pm.save!- SiteSetting.ai_bot_enable_dedicated_ux = trueSiteSetting.ai_bot_enabled = trueSiteSetting.navigation_menu = "sidebar"Jobs.run_immediately!@@ -140,325 +139,294 @@ RSpec.describe "AI Bot - Homepage", type: :system doendend- context "when `ai_bot_enable_dedicated_ux` is enabled" do- it "allows uploading files to a new conversation" do- ai_pm_homepage.visit- expect(ai_pm_homepage).to have_homepage+ it "allows uploading files to a new conversation" do+ ai_pm_homepage.visit+ expect(ai_pm_homepage).to have_homepage- file_path_1 = file_from_fixtures("logo.png", "images").path- file_path_2 = file_from_fixtures("logo.jpg", "images").path- attach_file("ai-bot-file-uploader", [file_path_1, file_path_2], make_visible: true)+ file_path_1 = file_from_fixtures("logo.png", "images").path+ file_path_2 = file_from_fixtures("logo.jpg", "images").path+ attach_file("ai-bot-file-uploader", [file_path_1, file_path_2], make_visible: true)- expect(page).to have_css(".ai-bot-upload", count: 2)+ expect(page).to have_css(".ai-bot-upload", count: 2)- ai_pm_homepage.input.fill_in(with: "Here are two image attachments")+ ai_pm_homepage.input.fill_in(with: "Here are two image attachments")- expect(page).to have_no_css(".ai-bot-upload--in-progress")-- responses = ["hello user", "topic title"]- DiscourseAi::Completions::Llm.with_prepared_responses(responses) do- ai_pm_homepage.submit- expect(topic_page).to have_content("Here are two image attachments")- expect(page).to have_css(".cooked img", count: 2)- end+ expect(page).to have_no_css(".ai-bot-upload--in-progress")- find(".ai-new-question-button").click- expect(ai_pm_homepage).to have_homepage- expect(page).to have_no_css(".ai-bot-upload")+ responses = ["hello user", "topic title"]+ DiscourseAi::Completions::Llm.with_prepared_responses(responses) do+ ai_pm_homepage.submit+ expect(topic_page).to have_content("Here are two image attachments")+ expect(page).to have_css(".cooked img", count: 2)end- it "shows an error when trying to submit while uploads are in progress" do- ai_pm_homepage.visit- expect(ai_pm_homepage).to have_homepage+ find(".ai-new-question-button").click+ expect(ai_pm_homepage).to have_homepage+ expect(page).to have_no_css(".ai-bot-upload")+ end- file_path_1 = file_from_fixtures("logo.png", "images").path- file_path_2 = file_from_fixtures("logo.jpg", "images").path+ it "shows an error when trying to submit while uploads are in progress" do+ ai_pm_homepage.visit+ expect(ai_pm_homepage).to have_homepage- ai_pm_homepage.input.fill_in(with: "Some message to send to AI with uploads")+ file_path_1 = file_from_fixtures("logo.png", "images").path+ file_path_2 = file_from_fixtures("logo.jpg", "images").path- cdp.with_slow_upload do- attach_file("ai-bot-file-uploader", [file_path_1, file_path_2], make_visible: true)- expect(page).to have_css(".ai-bot-upload--in-progress", count: 2)+ ai_pm_homepage.input.fill_in(with: "Some message to send to AI with uploads")- ai_pm_homepage.submit- expect(page).to have_content(- I18n.t("js.discourse_ai.ai_bot.conversations.uploads_in_progress"),- )- end- end+ cdp.with_slow_upload do+ attach_file("ai-bot-file-uploader", [file_path_1, file_path_2], make_visible: true)+ expect(page).to have_css(".ai-bot-upload--in-progress", count: 2)- it "allows removing an upload before submission" do- ai_pm_homepage.visit- expect(ai_pm_homepage).to have_homepage+ ai_pm_homepage.submit+ expect(page).to have_content(+ I18n.t("js.discourse_ai.ai_bot.conversations.uploads_in_progress"),+ )+ end+ end- file_path = file_from_fixtures("logo.png", "images").path- attach_file("ai-bot-file-uploader", file_path, make_visible: true)- expect(page).to have_css(".ai-bot-upload", count: 1)+ it "allows removing an upload before submission" do+ ai_pm_homepage.visit+ expect(ai_pm_homepage).to have_homepage- find(".ai-bot-upload__remove").click+ file_path = file_from_fixtures("logo.png", "images").path+ attach_file("ai-bot-file-uploader", file_path, make_visible: true)+ expect(page).to have_css(".ai-bot-upload", count: 1)- expect(page).to have_no_css(".ai-bot-upload")+ find(".ai-bot-upload__remove").click- ai_pm_homepage.input.fill_in(with: "Message without attachments")+ expect(page).to have_no_css(".ai-bot-upload")- responses = ["hello user", "topic title"]- DiscourseAi::Completions::Llm.with_prepared_responses(responses) do- ai_pm_homepage.submit- expect(topic_page).to have_content("Message without attachments")- expect(page).to have_no_css(".cooked img")- end- end+ ai_pm_homepage.input.fill_in(with: "Message without attachments")- it "renders landing page on bot click" do- visit "/"- header.click_bot_button- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to be_visible+ responses = ["hello user", "topic title"]+ DiscourseAi::Completions::Llm.with_prepared_responses(responses) do+ ai_pm_homepage.submit+ expect(topic_page).to have_content("Message without attachments")+ expect(page).to have_no_css(".cooked img")end+ end- it "displays error when message is too short" do- visit "/"- header.click_bot_button+ it "renders landing page on bot click" do+ visit "/"+ header.click_bot_button+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to be_visible+ end- ai_pm_homepage.input.fill_in(with: "a")- ai_pm_homepage.submit- expect(ai_pm_homepage).to have_too_short_dialog- dialog.click_yes- expect(composer).to be_closed- end+ it "displays error when message is too short" do+ visit "/"+ header.click_bot_button- it "hides default content in the sidebar" do- visit "/"- header.click_bot_button+ ai_pm_homepage.input.fill_in(with: "a")+ ai_pm_homepage.submit+ expect(ai_pm_homepage).to have_too_short_dialog+ dialog.click_yes+ expect(composer).to be_closed+ end- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to have_no_tags_section- expect(sidebar).to have_no_section("categories")- expect(sidebar).to have_no_section("chat-dms")- expect(sidebar).to have_no_section("chat-channels")- expect(sidebar).to have_no_section("user-threads")- end+ it "hides default content in the sidebar" do+ visit "/"+ header.click_bot_button- it "shows the bot conversation in the sidebar" do- visit "/"- header.click_bot_button+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to have_no_tags_section+ expect(sidebar).to have_no_section("categories")+ expect(sidebar).to have_no_section("chat-dms")+ expect(sidebar).to have_no_section("chat-channels")+ expect(sidebar).to have_no_section("user-threads")+ end- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to have_section("Today")- expect(sidebar).to have_section_link(pm.title)- end+ it "shows the bot conversation in the sidebar" do+ visit "/"+ header.click_bot_button- it "allows navigating to a specific LLM and persona" do- # url encode name- persona_name = CGI.escape(persona.name)- llm_name = CGI.escape(claude_2_dup.display_name)- visit "/discourse-ai/ai-bot/conversations?persona=#{persona_name}&llm=#{llm_name}"+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to have_section("Today")+ expect(sidebar).to have_section_link(pm.title)+ end- ai_pm_homepage.persona_selector.expand # not needed, but helps to see what the list has- expect(ai_pm_homepage.persona_selector).to have_selected_name(persona.name)- expect(ai_pm_homepage.llm_selector).to have_selected_name(claude_2_dup.display_name)- end+ it "allows navigating to a specific LLM and persona" do+ # url encode name+ persona_name = CGI.escape(persona.name)+ llm_name = CGI.escape(claude_2_dup.display_name)+ visit "/discourse-ai/ai-bot/conversations?persona=#{persona_name}&llm=#{llm_name}"- it "removes persona from selector when allow_personal_messages is disabled" do- begin- persona.update!(allow_personal_messages: false)- ai_pm_homepage.visit- ai_pm_homepage.persona_selector.expand- expect(ai_pm_homepage.persona_selector).to have_no_option_name(persona.name)- ensure- persona.update!(allow_personal_messages: true)- end- end+ ai_pm_homepage.persona_selector.expand # not needed, but helps to see what the list has+ expect(ai_pm_homepage.persona_selector).to have_selected_name(persona.name)+ expect(ai_pm_homepage.llm_selector).to have_selected_name(claude_2_dup.display_name)+ end- it "includes persona in selector when allow_personal_messages is enabled" do- # default is true+ it "removes persona from selector when allow_personal_messages is disabled" do+ begin+ persona.update!(allow_personal_messages: false)ai_pm_homepage.visitai_pm_homepage.persona_selector.expand- expect(ai_pm_homepage.persona_selector).to have_option_name(persona.name)+ expect(ai_pm_homepage.persona_selector).to have_no_option_name(persona.name)+ ensure+ persona.update!(allow_personal_messages: true)end+ end- it "shows empty state when no PMs exist" do- pm.destroy!-- visit "/"- header.click_bot_button-- expect(page).to have_css(".sidebar-section .ai-bot-sidebar-empty-state", visible: true)- end+ it "includes persona in selector when allow_personal_messages is enabled" do+ # default is true+ ai_pm_homepage.visit+ ai_pm_homepage.persona_selector.expand+ expect(ai_pm_homepage.persona_selector).to have_option_name(persona.name)+ end- it "doesn't show empty state when a PM exists" do- visit "/"- header.click_bot_button+ it "shows empty state when no PMs exist" do+ pm.destroy!- expect(page).to have_no_css(".sidebar-section .ai-bot-sidebar-empty-state")- end+ visit "/"+ header.click_bot_button- it "displays last_7_days label in the sidebar" do- pm.update!(last_posted_at: 5.days.ago)- visit "/"- header.click_bot_button+ expect(page).to have_css(".sidebar-section .ai-bot-sidebar-empty-state", visible: true)+ end- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to have_section("Last 7 days")- end+ it "doesn't show empty state when a PM exists" do+ visit "/"+ header.click_bot_button- it "displays last_30_days label in the sidebar" do- pm.update!(last_posted_at: 28.days.ago)- visit "/"- header.click_bot_button+ expect(page).to have_no_css(".sidebar-section .ai-bot-sidebar-empty-state")+ end- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to have_section("Last 30 days")- end+ it "displays last_7_days label in the sidebar" do+ pm.update!(last_posted_at: 5.days.ago)+ visit "/"+ header.click_bot_button- it "displays month and year label in the sidebar for older conversations" do- pm.update!(last_posted_at: "2024-04-10 15:39:11.406192000 +00:00")- visit "/"- header.click_bot_button+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to have_section("Last 7 days")+ end- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to have_section("2024-3")- end+ it "displays last_30_days label in the sidebar" do+ pm.update!(last_posted_at: 28.days.ago)+ visit "/"+ header.click_bot_button- it "navigates to the bot conversation when clicked" do- visit "/"- header.click_bot_button+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to have_section("Last 30 days")+ end- expect(ai_pm_homepage).to have_homepage- ai_pm_homepage.click_fist_sidebar_conversation- expect(topic_page).to have_topic_title(pm.title)- end+ it "displays month and year label in the sidebar for older conversations" do+ pm.update!(last_posted_at: "2024-04-10 15:39:11.406192000 +00:00")+ visit "/"+ header.click_bot_button- it "displays the shuffle icon when on homepage or bot PM" do- visit "/"- expect(header).to have_icon_in_bot_button(icon: "robot")- header.click_bot_button+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to have_section("2024-3")+ end- expect(header).to have_icon_in_bot_button(icon: "shuffle")+ it "navigates to the bot conversation when clicked" do+ visit "/"+ header.click_bot_button- # Go to a PM and assert that the icon is still shuffle- ai_pm_homepage.click_fist_sidebar_conversation- expect(header).to have_icon_in_bot_button(icon: "shuffle")+ expect(ai_pm_homepage).to have_homepage+ ai_pm_homepage.click_fist_sidebar_conversation+ expect(topic_page).to have_topic_title(pm.title)+ end- # Go back home and assert that the icon is now robot again- header.click_bot_button- expect(header).to have_icon_in_bot_button(icon: "robot")- end+ it "displays the shuffle icon when on homepage or bot PM" do+ visit "/"+ expect(header).to have_icon_in_bot_button(icon: "robot")+ header.click_bot_button- it "displays 'new question' button on homepage and topic page" do- topic_page.visit_topic(pm)- expect(ai_pm_homepage).to have_new_question_button+ expect(header).to have_icon_in_bot_button(icon: "shuffle")- ai_pm_homepage.visit- expect(ai_pm_homepage).to have_new_question_button- end+ # Go to a PM and assert that the icon is still shuffle+ ai_pm_homepage.click_fist_sidebar_conversation+ expect(header).to have_icon_in_bot_button(icon: "shuffle")- it "redirect to the homepage when 'new question' is clicked" do- topic_page.visit_topic(pm)- expect(sidebar).to be_visible- ai_pm_homepage.click_new_question_button- expect(ai_pm_homepage).to have_homepage- end+ # Go back home and assert that the icon is now robot again+ header.click_bot_button+ expect(header).to have_icon_in_bot_button(icon: "robot")+ end- it "can send a new message to the bot" do- topic_page.visit_topic(pm)- topic_page.click_reply_button- expect(composer).to be_opened+ it "displays 'new question' button on homepage and topic page" do+ topic_page.visit_topic(pm)+ expect(ai_pm_homepage).to have_new_question_button- composer.fill_in(with: "Hello bot replying to you")- composer.submit- expect(page).to have_content("Hello bot replying to you")- end+ ai_pm_homepage.visit+ expect(ai_pm_homepage).to have_new_question_button+ end- it "does not render custom sidebar on non-authored bot pms" do- # Include user_2 in the PM by creating a new post and topic_allowed_user association- Fabricate(:post, topic: pm, user: user_2, post_number: 4)- Fabricate(:topic_allowed_user, topic: pm, user: user_2)- sign_in(user_2)+ it "redirect to the homepage when 'new question' is clicked" do+ topic_page.visit_topic(pm)+ expect(sidebar).to be_visible+ ai_pm_homepage.click_new_question_button+ expect(ai_pm_homepage).to have_homepage+ end- topic_page.visit_topic(pm)+ it "can send a new message to the bot" do+ topic_page.visit_topic(pm)+ topic_page.click_reply_button+ expect(composer).to be_opened- expect(sidebar).to be_visible- expect(sidebar).to have_no_section("ai-conversations-history")- expect(sidebar).to have_no_css("button.ai-new-question-button")- end+ composer.fill_in(with: "Hello bot replying to you")+ composer.submit+ expect(page).to have_content("Hello bot replying to you")+ end- it "does not include non-authored bot pms in sidebar" do- # Include user_2 in the PM by creating a new post and topic_allowed_user association- Fabricate(:post, topic: pm, user: user_2, post_number: 4)- Fabricate(:topic_allowed_user, topic: pm, user: user_2)- sign_in(user_2)- visit "/"- header.click_bot_button- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to have_no_section_link(pm.title)- end+ it "does not render custom sidebar on non-authored bot pms" do+ # Include user_2 in the PM by creating a new post and topic_allowed_user association+ Fabricate(:post, topic: pm, user: user_2, post_number: 4)+ Fabricate(:topic_allowed_user, topic: pm, user: user_2)+ sign_in(user_2)- it "Allows choosing persona and LLM" do- ai_pm_homepage.visit+ topic_page.visit_topic(pm)- ai_pm_homepage.llm_selector.expand- ai_pm_homepage.llm_selector.select_row_by_name(claude_2_dup.display_name)- ai_pm_homepage.llm_selector.collapse+ expect(sidebar).to be_visible+ expect(sidebar).to have_no_section("ai-conversations-history")+ expect(sidebar).to have_no_css("button.ai-new-question-button")+ end- # confirm memory works for llm selection- ai_pm_homepage.visit- expect(ai_pm_homepage.llm_selector).to have_selected_name(claude_2_dup.display_name)- end+ it "does not include non-authored bot pms in sidebar" do+ # Include user_2 in the PM by creating a new post and topic_allowed_user association+ Fabricate(:post, topic: pm, user: user_2, post_number: 4)+ Fabricate(:topic_allowed_user, topic: pm, user: user_2)+ sign_in(user_2)+ visit "/"+ header.click_bot_button+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to have_no_section_link(pm.title)+ end- it "does not render back to forum link" do- ai_pm_homepage.visit- expect(ai_pm_homepage).to have_no_sidebar_back_link- end+ it "Allows choosing persona and LLM" do+ ai_pm_homepage.visit- context "with hamburger menu" do- before { SiteSetting.navigation_menu = "header dropdown" }- it "keeps robot icon in the header and doesn't display sidebar back link" do- visit "/"- expect(header).to have_icon_in_bot_button(icon: "robot")- header.click_bot_button- expect(ai_pm_homepage).to have_homepage- expect(header).to have_icon_in_bot_button(icon: "robot")- expect(ai_pm_homepage).to have_no_sidebar_back_link- end+ ai_pm_homepage.llm_selector.expand+ ai_pm_homepage.llm_selector.select_row_by_name(claude_2_dup.display_name)+ ai_pm_homepage.llm_selector.collapse- it "still renders the sidebar" do- visit "/"- header.click_bot_button- expect(ai_pm_homepage).to have_homepage- expect(sidebar).to be_visible- expect(header_dropdown).to be_visible- end- end+ # confirm memory works for llm selection+ ai_pm_homepage.visit+ expect(ai_pm_homepage.llm_selector).to have_selected_name(claude_2_dup.display_name)end- context "when `ai_bot_enable_dedicated_ux` is disabled" do- before { SiteSetting.ai_bot_enable_dedicated_ux = false }+ it "does not render back to forum link" do+ ai_pm_homepage.visit+ expect(ai_pm_homepage).to have_no_sidebar_back_link+ end- it "opens composer on bot click" do+ context "with hamburger menu" do+ before { SiteSetting.navigation_menu = "header dropdown" }+ it "keeps robot icon in the header and doesn't display sidebar back link" dovisit "/"+ expect(header).to have_icon_in_bot_button(icon: "robot")header.click_bot_button-- expect(ai_pm_homepage).to have_no_homepage- expect(composer).to be_opened+ expect(ai_pm_homepage).to have_homepage+ expect(header).to have_icon_in_bot_button(icon: "robot")+ expect(ai_pm_homepage).to have_no_sidebar_back_linkend- it "does not render sidebar when navigation menu is set to header on pm" do- SiteSetting.navigation_menu = "header dropdown"- topic_page.visit_topic(pm)-- expect(ai_pm_homepage).to have_no_homepage- expect(sidebar).to be_not_visible+ it "still renders the sidebar" do+ visit "/"+ header.click_bot_button+ expect(ai_pm_homepage).to have_homepage+ expect(sidebar).to be_visibleexpect(header_dropdown).to be_visibleend-- it "shows default content in the sidebar" do- topic_page.visit_topic(pm)-- expect(sidebar).to have_section("categories")- expect(sidebar).to have_section("chat-dms")- expect(sidebar).to have_no_css("button.ai-new-question-button")- endendcontext "with header dropdown on mobile", mobile: true do