A platform for community discussion. Free, open, simple.
DEV: Gate AI bot docked composer behind upcoming change (#39708)
Keegan Georgeb3b561e5fad4
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-docked-composer.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-docked-composer.gjsindex 513c475f6d1..5990e46ce37 100644--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-docked-composer.gjs+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-bot-docked-composer.gjs@@ -79,7 +79,10 @@ export default class AiBotDockedComposer extends Component {}get isBotPm() {- return this.topic?.is_bot_pm === true;+ return (+ this.siteSettings.ai_bot_enable_docked_composer &&+ this.topic?.is_bot_pm === true+ );}get topicId() {diff --git a/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-bot-replies.js b/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-bot-replies.jsindex a08dd661c10..f5f1b4b59ad 100644--- a/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-bot-replies.js+++ b/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-bot-replies.js@@ -37,6 +37,8 @@ function attachHeaderIcon(api) {}function initializeAIBotReplies(api) {+ const siteSettings = api.container.lookup("service:site-settings");+initializePauseButton(api);api.renderInOutlet("topic-area-bottom", AiBotDockedComposer);@@ -48,7 +50,10 @@ function initializeAIBotReplies(api) {// route. Returning an empty tabs array instead keeps the component// rendering nothing regardless of transition timing.api.registerValueTransformer("more-topics-tabs", ({ value, context }) => {- if (context?.topic?.is_bot_pm) {+ if (+ siteSettings.ai_bot_enable_docked_composer &&+ context?.topic?.is_bot_pm+ ) {return [];}return value;@@ -132,7 +137,7 @@ function initializeAIBotReplies(api) {// receives is relayed to the docked composer via `composer:insert-block`// which our DEditor subscribes to.api.onAppEvent("page:compose-reply", (topic) => {- if (topic?.is_bot_pm) {+ if (siteSettings.ai_bot_enable_docked_composer && topic?.is_bot_pm) {focusDockedComposer();}});diff --git a/plugins/discourse-ai/config/locales/server.en.yml b/plugins/discourse-ai/config/locales/server.en.ymlindex 6fcc037da6c..9c57ca2d2b2 100644--- a/plugins/discourse-ai/config/locales/server.en.yml+++ b/plugins/discourse-ai/config/locales/server.en.yml@@ -126,6 +126,7 @@ en:ai_bot_add_to_header: "Display a button in the header to start a PM with an AI Bot"ai_bot_add_to_community_section: "Display a link in the sidebar community section to start a PM with an AI Bot"ai_bot_github_access_token: "GitHub access token for use with GitHub AI tools (required for search support)"+ ai_bot_enable_docked_composer: "Enable the docked chat-style composer for AI bot conversations instead of the standard floating composer."ai_discover_enabled: "Enable the discovery search feature"ai_discover_agent: "Agent to use for discovery search feature"diff --git a/plugins/discourse-ai/config/settings.yml b/plugins/discourse-ai/config/settings.ymlindex a5e53a50fb8..1f6c21ac678 100644--- a/plugins/discourse-ai/config/settings.yml+++ b/plugins/discourse-ai/config/settings.yml@@ -354,6 +354,14 @@ discourse_ai:default: ""secret: truearea: "ai-features/bot"+ ai_bot_enable_docked_composer:+ default: false+ hidden: true+ client: true+ area: "ai-features/bot"+ upcoming_change:+ status: "alpha"+ impact: "feature,all_members"ai_discover_enabled:default: falseclient: truediff --git a/plugins/discourse-ai/public/images/upcoming_changes/ai_bot_enable_docked_composer.png b/plugins/discourse-ai/public/images/upcoming_changes/ai_bot_enable_docked_composer.pngnew file mode 100644index 00000000000..6b859122b72Binary files /dev/null and b/plugins/discourse-ai/public/images/upcoming_changes/ai_bot_enable_docked_composer.png differdiff --git a/plugins/discourse-ai/spec/system/ai_bot/docked_composer_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/docked_composer_spec.rbindex 0e2ace4520c..bea428417ed 100644--- a/plugins/discourse-ai/spec/system/ai_bot/docked_composer_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/docked_composer_spec.rb@@ -48,6 +48,7 @@ RSpec.describe "AI Bot docked composer" dotoggle_enabled_bots(bots: [claude_2])SiteSetting.navigation_menu = "sidebar"SiteSetting.ai_bot_allowed_groups = "#{Group::AUTO_GROUPS[:trust_level_0]}"+ SiteSetting.ai_bot_enable_docked_composer = trueJobs.run_immediately!sign_in(user)end@@ -116,4 +117,12 @@ RSpec.describe "AI Bot docked composer" doexpect(find(".ai-bot-docked-composer .d-editor-input").value).to eq("")end++ it "falls back to the standard composer when the docked composer is disabled" do+ SiteSetting.ai_bot_enable_docked_composer = false+ topic_page.visit_topic(pm)++ expect(page).to have_no_css(".ai-bot-docked-composer")+ expect(page).to have_css("#topic-footer-buttons .create")+ endenddiff --git a/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rbindex b867f580a3e..5d2060053c5 100644--- a/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb@@ -133,7 +133,10 @@ RSpec.describe "AI Bot - Homepage" doendcontext "when `ai_bot_enable_dedicated_ux` is enabled" do- before { SiteSetting.ai_bot_add_to_header = true }+ before do+ SiteSetting.ai_bot_add_to_header = true+ SiteSetting.ai_bot_enable_docked_composer = true+ endit "allows uploading files to a new conversation" doai_pm_homepage.visit