Skip to content

A platform for community discussion. Free, open, simple.

DEV: Make `enable_ai_bot_starred_conversations` permanent (#41844)

Penar Musaraj5806d9a6b648
diff --git a/plugins/discourse-ai/app/models/discourse_ai/ai_bot/conversation_star.rb b/plugins/discourse-ai/app/models/discourse_ai/ai_bot/conversation_star.rb
index 9d5fc9d86ef..5ad892ec2d7 100644
--- a/plugins/discourse-ai/app/models/discourse_ai/ai_bot/conversation_star.rb
+++ b/plugins/discourse-ai/app/models/discourse_ai/ai_bot/conversation_star.rb
@@ -47,13 +47,8 @@ module DiscourseAi
end
def self.list(user, page: 0, per_page: 40)
- starred = []
- if SiteSetting.enable_ai_bot_starred_conversations
- starred = page == 0 ? starred_conversations_for(user).to_a : []
- unstarred_relation = unstarred_conversations_for(user)
- else
- unstarred_relation = conversations_query_for(user)
- end
+ starred = page == 0 ? starred_conversations_for(user).to_a : []
+ unstarred_relation = unstarred_conversations_for(user)
unstarred_page =
ConversationPage.paginate(
@@ -64,12 +59,7 @@ module DiscourseAi
all_topics = starred + unstarred_page.records
- starred_lookup =
- if SiteSetting.enable_ai_bot_starred_conversations
- starred_at_by_topic_id(user, all_topics)
- else
- {}
- end
+ starred_lookup = starred_at_by_topic_id(user, all_topics)
conversations =
ConversationPage.new(
diff --git a/plugins/discourse-ai/app/services/discourse_ai/ai_bot/update_conversation_star.rb b/plugins/discourse-ai/app/services/discourse_ai/ai_bot/update_conversation_star.rb
index a7d725c268a..51a5e32a91f 100644
--- a/plugins/discourse-ai/app/services/discourse_ai/ai_bot/update_conversation_star.rb
+++ b/plugins/discourse-ai/app/services/discourse_ai/ai_bot/update_conversation_star.rb
@@ -5,8 +5,6 @@ module DiscourseAi
class UpdateConversationStar
include Service::Base
- policy :feature_enabled
-
params do
attribute :topic_id, :integer
attribute :starred, :boolean
@@ -36,10 +34,6 @@ module DiscourseAi
private
- def feature_enabled
- SiteSetting.enable_ai_bot_starred_conversations
- end
-
def fetch_user(guardian:)
guardian.user
end
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-conversation-sidebar-context-menu.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-conversation-sidebar-context-menu.gjs
index 606a146b5c8..e45c6573410 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-conversation-sidebar-context-menu.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-conversation-sidebar-context-menu.gjs
@@ -20,10 +20,6 @@ export default class AiConversationSidebarContextMenu extends Component {
return this.args.data.manager;
}
- get canStarConversations() {
- return this.manager.siteSettings.enable_ai_bot_starred_conversations;
- }
-
get canShare() {
return this.currentUser?.can_share_ai_bot_conversations;
}
@@ -44,7 +40,7 @@ export default class AiConversationSidebarContextMenu extends Component {
@action
async toggleStarred() {
- if (!this.canStarConversations || !this.topic || this.isTogglingStarred) {
+ if (!this.topic || this.isTogglingStarred) {
return;
}
@@ -70,18 +66,16 @@ export default class AiConversationSidebarContextMenu extends Component {
<template>
<DDropdownMenu class="ai-conversation-sidebar-link-menu" as |dropdown|>
- {{#if this.canStarConversations}}
- <dropdown.item>
- <DButton
- @action={{this.toggleStarred}}
- @disabled={{this.isTogglingStarred}}
- @icon={{this.starIcon}}
- @label={{this.starLabel}}
- @title={{this.starLabel}}
- class="ai-conversation-sidebar-link-menu__star-conversation"
- />
- </dropdown.item>
- {{/if}}
+ <dropdown.item>
+ <DButton
+ @action={{this.toggleStarred}}
+ @disabled={{this.isTogglingStarred}}
+ @icon={{this.starIcon}}
+ @label={{this.starLabel}}
+ @title={{this.starLabel}}
+ class="ai-conversation-sidebar-link-menu__star-conversation"
+ />
+ </dropdown.item>
{{#if this.canShare}}
<dropdown.item>
<DButton
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js b/plugins/discourse-ai/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js
index 3014043b07b..2817aeedeed 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js
+++ b/plugins/discourse-ai/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js
@@ -26,8 +26,6 @@ export default class AiConversationsSidebarManager extends Service {
@service router;
@service menu;
@service capabilities;
- @service currentUser;
- @service siteSettings;
@tracked topics = [];
@tracked sections = trackedArray();
@@ -334,15 +332,11 @@ export default class AiConversationsSidebarManager extends Service {
return bDate - aDate;
});
- if (this.siteSettings.enable_ai_bot_starred_conversations) {
- fresh.push({
- name: "starred-conversations",
- title: i18n("discourse_ai.ai_bot.conversations.starred"),
- links: trackedArray(
- starredTopics.map((t) => this._conversationLink(t))
- ),
- });
- }
+ fresh.push({
+ name: "starred-conversations",
+ title: i18n("discourse_ai.ai_bot.conversations.starred"),
+ links: trackedArray(starredTopics.map((t) => this._conversationLink(t))),
+ });
const todaySection = {
name: "today",
@@ -353,11 +347,7 @@ export default class AiConversationsSidebarManager extends Service {
fresh.push(todaySection);
this.topics
- .filter(
- (t) =>
- !this.siteSettings.enable_ai_bot_starred_conversations ||
- !t.ai_conversation_starred
- )
+ .filter((t) => !t.ai_conversation_starred)
.sort((a, b) => {
const bDate = new Date(b.last_posted_at || now);
const aDate = new Date(a.last_posted_at || now);
@@ -486,10 +476,7 @@ export default class AiConversationsSidebarManager extends Service {
_conversationLink(topic) {
const isStarred = !!topic.ai_conversation_starred;
- const canShowConversationMenu =
- (this.siteSettings.enable_ai_bot_starred_conversations ||
- this.currentUser?.can_share_ai_bot_conversations) &&
- !this.capabilities.isIpadOS;
+ const canShowConversationMenu = !this.capabilities.isIpadOS;
return {
key: topic.id,
diff --git a/plugins/discourse-ai/config/settings.yml b/plugins/discourse-ai/config/settings.yml
index 93875bd7c88..094242283c9 100644
--- a/plugins/discourse-ai/config/settings.yml
+++ b/plugins/discourse-ai/config/settings.yml
@@ -384,7 +384,7 @@ discourse_ai:
hidden: true
client: true
upcoming_change:
- status: "beta"
+ status: "permanent"
impact: "feature,all_members"
learn_more_url: "https://meta.discourse.org/t/-/403285"
ai_bot_enabled_llms:
diff --git a/plugins/discourse-ai/spec/requests/ai_bot/conversations_controller_spec.rb b/plugins/discourse-ai/spec/requests/ai_bot/conversations_controller_spec.rb
index d2abbfd70df..40678c75d92 100644
--- a/plugins/discourse-ai/spec/requests/ai_bot/conversations_controller_spec.rb
+++ b/plugins/discourse-ai/spec/requests/ai_bot/conversations_controller_spec.rb
@@ -23,7 +23,6 @@ RSpec.describe DiscourseAi::AiBot::ConversationsController do
before do
enable_current_plugin
- SiteSetting.enable_ai_bot_starred_conversations = true
sign_in(current_user)
[conversation, starred_conversation, other_conversation].each { |topic| mark_ai_bot_pm(topic) }
end
@@ -77,46 +76,9 @@ RSpec.describe DiscourseAi::AiBot::ConversationsController do
be_in([starred_conversation.id, *extra_starred_conversations.map(&:id)]),
)
end
-
- it "returns the legacy response when the upcoming change is disabled" do
- SiteSetting.enable_ai_bot_starred_conversations = false
-
- get "/discourse-ai/ai-bot/conversations.json"
-
- expect(response.status).to eq(200)
- json = response.parsed_body
- expect(json).not_to have_key("starred_conversations")
- starred_topic = json["conversations"].find { |topic| topic["id"] == starred_conversation.id }
- expect(starred_topic["ai_conversation_starred"]).to eq(false)
- expect(json["conversations"].map { |topic| topic["id"] }).to include(starred_conversation.id)
- end
end
describe "PUT /discourse-ai/ai-bot/conversations/:topic_id/starred.json" do
- context "when the upcoming change is disabled" do
- before { SiteSetting.enable_ai_bot_starred_conversations = false }
-
- it "returns 404 and does not star the conversation" do
- put "/discourse-ai/ai-bot/conversations/#{conversation.id}/starred.json",
- params: {
- starred: true,
- }
-
- expect(response.status).to eq(404)
- expect(
- DiscourseAi::AiBot::ConversationStar.exists?(user: current_user, topic: conversation),
- ).to eq(false)
- end
- it "returns 404 even when params are invalid" do
- put "/discourse-ai/ai-bot/conversations/#{conversation.id}/starred.json",
- params: {
- starred: "wat",
- }
-
- expect(response.status).to eq(404)
- end
- end
-
it "stars a conversation for the current user" do
put "/discourse-ai/ai-bot/conversations/#{conversation.id}/starred.json",
params: {
diff --git a/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/list_conversations_spec.rb b/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/list_conversations_spec.rb
index e5e1e17e1cd..bc856b284f2 100644
--- a/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/list_conversations_spec.rb
+++ b/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/list_conversations_spec.rb
@@ -54,7 +54,6 @@ RSpec.describe DiscourseAi::AiBot::ListConversations do
before do
enable_current_plugin
- SiteSetting.enable_ai_bot_starred_conversations = true
[conversation, starred_conversation, other_conversation].each do |topic|
mark_ai_bot_pm(topic)
end
@@ -110,15 +109,6 @@ RSpec.describe DiscourseAi::AiBot::ListConversations do
expect(result[:conversations].records).to include(starred_conversation)
expect(result[:meta]).to eq(page: 0, per_page: 1, has_more: true)
end
-
- context "when the upcoming change is disabled" do
- before { SiteSetting.enable_ai_bot_starred_conversations = false }
-
- it "returns the legacy conversation list" do
- expect(conversations).to include(starred_conversation)
- expect(conversations).to include(conversation)
- end
- end
end
def mark_ai_bot_pm(topic)
diff --git a/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/update_conversation_star_spec.rb b/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/update_conversation_star_spec.rb
index 4dac9d93064..ba4c6724bf9 100644
--- a/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/update_conversation_star_spec.rb
+++ b/plugins/discourse-ai/spec/services/discourse_ai/ai_bot/update_conversation_star_spec.rb
@@ -39,7 +39,6 @@ RSpec.describe DiscourseAi::AiBot::UpdateConversationStar do
before do
enable_current_plugin
- SiteSetting.enable_ai_bot_starred_conversations = true
mark_ai_bot_pm(conversation)
mark_ai_bot_pm(other_conversation)
mark_ai_bot_pm(invisible_pm)
@@ -59,16 +58,6 @@ RSpec.describe DiscourseAi::AiBot::UpdateConversationStar do
end
end
- context "when the upcoming change is disabled" do
- before { SiteSetting.enable_ai_bot_starred_conversations = false }
-
- it { is_expected.to fail_a_policy(:feature_enabled) }
-
- it "does not create a star" do
- expect { result }.not_to change { DiscourseAi::AiBot::ConversationStar.count }
- end
- end
-
context "when the conversation cannot be found" do
let(:params) { { topic_id: 99_999_999, starred: true } }
diff --git a/plugins/discourse-ai/spec/system/ai_bot/ai_bot_starred_conversations_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/ai_bot_starred_conversations_spec.rb
index f4b0ce64fa8..572f727bed9 100644
--- a/plugins/discourse-ai/spec/system/ai_bot/ai_bot_starred_conversations_spec.rb
+++ b/plugins/discourse-ai/spec/system/ai_bot/ai_bot_starred_conversations_spec.rb
@@ -34,7 +34,6 @@ RSpec.describe "AI Bot starred conversations" do
before do
enable_current_plugin
SiteSetting.ai_bot_enabled = true
- SiteSetting.enable_ai_bot_starred_conversations = true
SiteSetting.navigation_menu = "sidebar"
toggle_enabled_bots(bots: [gpt_4])
diff --git a/plugins/discourse-ai/spec/system/ai_bot/ai_conversation_sidebar_share_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/ai_conversation_sidebar_share_spec.rb
index 0929f27c918..2c68e852865 100644
--- a/plugins/discourse-ai/spec/system/ai_bot/ai_conversation_sidebar_share_spec.rb
+++ b/plugins/discourse-ai/spec/system/ai_bot/ai_conversation_sidebar_share_spec.rb
@@ -23,9 +23,6 @@ RSpec.describe "AI Bot conversation sidebar share" do
before do
enable_current_plugin
SiteSetting.ai_bot_enabled = true
- # Starring is intentionally disabled to prove the conversation menu still
- # appears (and exposes Share) purely on the strength of sharing access.
- SiteSetting.enable_ai_bot_starred_conversations = false
SiteSetting.ai_bot_public_sharing_allowed_groups = "1" # admins
SiteSetting.navigation_menu = "sidebar"
toggle_enabled_bots(bots: [gpt_4])
@@ -39,13 +36,13 @@ RSpec.describe "AI Bot conversation sidebar share" do
sign_in(admin)
end
- it "shows Share in the conversation menu when starring is disabled" do
+ it "shows Share in the conversation menu" do
page.visit(Topic.relative_url(pm.id, pm.slug))
ai_pm_homepage.open_conversation_menu(pm)
expect(ai_pm_homepage).to have_share_conversation_menu_item
- expect(ai_pm_homepage).to have_no_star_conversation_menu_item
+ expect(ai_pm_homepage).to have_star_conversation_menu_item
end
it "opens the share modal from the conversation menu" do
diff --git a/plugins/discourse-ai/spec/system/page_objects/components/ai_pm_homepage.rb b/plugins/discourse-ai/spec/system/page_objects/components/ai_pm_homepage.rb
index 9fad8c32392..70b299e2522 100644
--- a/plugins/discourse-ai/spec/system/page_objects/components/ai_pm_homepage.rb
+++ b/plugins/discourse-ai/spec/system/page_objects/components/ai_pm_homepage.rb
@@ -111,6 +111,10 @@ module PageObjects
page.has_no_css?(".ai-conversation-sidebar-link-menu__star-conversation")
end
+ def has_star_conversation_menu_item?
+ page.has_css?(".ai-conversation-sidebar-link-menu__star-conversation")
+ end
+
def has_no_sidebar_back_link?
page.has_no_css?(".sidebar-sections__back-to-forum")
end
diff --git a/plugins/discourse-ai/test/javascripts/unit/services/ai-conversations-sidebar-manager-test.js b/plugins/discourse-ai/test/javascripts/unit/services/ai-conversations-sidebar-manager-test.js
index 9f5cc5c6cf4..ccc8c7b54c4 100644
--- a/plugins/discourse-ai/test/javascripts/unit/services/ai-conversations-sidebar-manager-test.js
+++ b/plugins/discourse-ai/test/javascripts/unit/services/ai-conversations-sidebar-manager-test.js
@@ -26,7 +26,6 @@ module("Unit | Service | ai-conversations-sidebar-manager", function (hooks) {
setPanelCount += 1;
assert.strictEqual(panel, AI_CONVERSATIONS_PANEL);
};
- service.siteSettings.enable_ai_bot_starred_conversations = true;
service.capabilities.isIpadOS = false;
const lastPostedAt = new Date(Date.now() - 3 * 86400000).toISOString();