Skip to content

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

Ai suggest toolbar menu (#42480)

chapoid3cd53844ac9
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-composer-helper-menu.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-composer-helper-menu.gjs
index e98bc830d5e..1b936f02a5e 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-composer-helper-menu.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-composer-helper-menu.gjs
@@ -10,12 +10,16 @@ import { i18n } from "discourse-i18n";
import AiHelperOptionsList from "../components/ai-helper-options-list";
import ModalDiffModal from "../components/modal/diff-modal";
import ThumbnailSuggestion from "../components/modal/thumbnail-suggestions";
+import AiTitleSuggestionsMenu from "../components/suggestion-menus/ai-title-suggestions-menu";
+import { MIN_CHARACTER_COUNT } from "../lib/ai-helper-suggestions";
export default class AiComposerHelperMenu extends Component {
@service modal;
@service siteSettings;
@service currentUser;
@service site;
+ @service composer;
+ @service menu;
@tracked customPromptValue = "";
prompts = [];
@@ -30,7 +34,6 @@ export default class AiComposerHelperMenu extends Component {
prompts = prompts
.filter((p) => p.location.includes("composer"))
- .filter((p) => p.name !== "generate_titles")
.map((p) => {
// AI helper by default returns interface locale on translations
// Since we want site default translations (and we are using: force_default_locale)
@@ -64,6 +67,16 @@ export default class AiComposerHelperMenu extends Component {
prompts = prompts.filter((p) => p.name !== "custom_prompt");
}
+ const canSuggestTitles =
+ this.siteSettings.ai_helper_enabled_features.includes("suggestions") &&
+ this.composer.model?.canEditTitle &&
+ !this.composer.model?.disableTitleInput &&
+ this.composer.model?.reply?.length > MIN_CHARACTER_COUNT;
+
+ if (!canSuggestTitles) {
+ prompts = prompts.filter((p) => p.name !== "generate_titles");
+ }
+
prompts.forEach((p) => {
this.prompts[p.name] = p;
});
@@ -105,6 +118,16 @@ export default class AiComposerHelperMenu extends Component {
async suggestChanges(option) {
await this.args.close();
+ if (option.name === "generate_titles") {
+ return this.menu.show(document.querySelector(".ai-helper-trigger"), {
+ identifier: "ai-title-suggester",
+ modalForMobile: true,
+ interactive: true,
+ component: AiTitleSuggestionsMenu,
+ data: { model: this.composer.model },
+ });
+ }
+
if (option.name === "illustrate_post") {
return this.modal.show(ThumbnailSuggestion, {
model: {
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggester.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggester.gjs
index f1fb648e8d3..08bbc60fcaf 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggester.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggester.gjs
@@ -1,22 +1,16 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
-import { array, fn } from "@ember/helper";
+import { array } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import DMenu from "discourse/float-kit/components/d-menu";
-import { ajax } from "discourse/lib/ajax";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import DButton from "discourse/ui-kit/d-button";
-import DDropdownMenu from "discourse/ui-kit/d-dropdown-menu";
import { i18n } from "discourse-i18n";
import {
- isAiCreditLimitError,
- popupAiCreditLimitError,
-} from "../../lib/ai-errors";
-import {
+ fetchTitleSuggestions,
MIN_CHARACTER_COUNT,
showSuggestionsError,
} from "../../lib/ai-helper-suggestions";
+import AiTitleSuggestionsList from "./ai-title-suggestions-list";
export default class AiTitleSuggester extends Component {
@tracked loading = false;
@@ -33,9 +27,6 @@ export default class AiTitleSuggester extends Component {
this.content?.length > MIN_CHARACTER_COUNT ||
this.args.topicState === "edit";
- document
- .querySelector(".composer-fields")
- ?.classList.toggle("showing-ai-suggestions", showTrigger);
document
.querySelector(".edit-topic-title")
?.classList.toggle("showing-ai-suggestions", showTrigger);
@@ -55,35 +46,24 @@ export default class AiTitleSuggester extends Component {
this.loading = true;
this.triggerIcon = "spinner";
- const data = {};
- if (this.content) {
- data.text = this.content;
- } else {
- data.topic_id = this.args.buffered.content.id;
+ const suggestions = await fetchTitleSuggestions({
+ text: this.content,
+ topicId: this.args.buffered?.content?.id,
+ });
+
+ this.loading = false;
+ this.triggerIcon = "rotate";
+
+ if (suggestions == null) {
+ return;
}
- try {
- const { suggestions } = await ajax(
- "/discourse-ai/ai-helper/suggest_title",
- { method: "POST", data }
- );
-
- this.suggestions = suggestions;
-
- if (suggestions?.length === 0) {
- showSuggestionsError(this, this.loadSuggestions.bind(this));
- return;
- }
- } catch (error) {
- if (isAiCreditLimitError(error)) {
- popupAiCreditLimitError(error);
- } else {
- popupAjaxError(error);
- }
- } finally {
- this.loading = false;
- this.triggerIcon = "rotate";
+ this.suggestions = suggestions;
+
+ if (suggestions.length === 0) {
+ showSuggestionsError(this, this.loadSuggestions.bind(this));
+ return;
}
return this.suggestions;
@@ -135,19 +115,10 @@ export default class AiTitleSuggester extends Component {
>
<:content>
{{#if this.showDropdown}}
- <DDropdownMenu as |dropdown|>
- {{#each this.suggestions as |suggestion index|}}
- <dropdown.item>
- <DButton
- @translatedLabel={{suggestion}}
- @action={{fn this.applySuggestion suggestion}}
- data-name={{suggestion}}
- data-value={{index}}
- title={{suggestion}}
- />
- </dropdown.item>
- {{/each}}
- </DDropdownMenu>
+ <AiTitleSuggestionsList
+ @suggestions={{this.suggestions}}
+ @onSelect={{this.applySuggestion}}
+ />
{{/if}}
</:content>
</DMenu>
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggestions-list.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggestions-list.gjs
new file mode 100644
index 00000000000..bbed809e485
--- /dev/null
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggestions-list.gjs
@@ -0,0 +1,19 @@
+import { fn } from "@ember/helper";
+import DButton from "discourse/ui-kit/d-button";
+import DDropdownMenu from "discourse/ui-kit/d-dropdown-menu";
+
+export default <template>
+ <DDropdownMenu as |dropdown|>
+ {{#each @suggestions as |suggestion index|}}
+ <dropdown.item>
+ <DButton
+ @translatedLabel={{suggestion}}
+ @action={{fn @onSelect suggestion}}
+ data-name={{suggestion}}
+ data-value={{index}}
+ title={{suggestion}}
+ />
+ </dropdown.item>
+ {{/each}}
+ </DDropdownMenu>
+</template>
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggestions-menu.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggestions-menu.gjs
new file mode 100644
index 00000000000..3d69942f9fa
--- /dev/null
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/suggestion-menus/ai-title-suggestions-menu.gjs
@@ -0,0 +1,71 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import didInsert from "@ember/render-modifiers/modifiers/did-insert";
+import DButton from "discourse/ui-kit/d-button";
+import dIcon from "discourse/ui-kit/helpers/d-icon";
+import { i18n } from "discourse-i18n";
+import { fetchTitleSuggestions } from "../../lib/ai-helper-suggestions";
+import AiTitleSuggestionsList from "./ai-title-suggestions-list";
+
+export default class AiTitleSuggestionsMenu extends Component {
+ @tracked loading = true;
+ @tracked suggestions = null;
+
+ get model() {
+ return this.args.data.model;
+ }
+
+ get noResults() {
+ return this.suggestions?.length === 0;
+ }
+
+ @action
+ async loadSuggestions() {
+ this.loading = true;
+
+ const suggestions = await fetchTitleSuggestions({
+ text: this.model?.reply,
+ });
+
+ this.loading = false;
+
+ if (suggestions == null) {
+ this.args.close();
+ return;
+ }
+
+ this.suggestions = suggestions;
+ }
+
+ @action
+ applySuggestion(suggestion) {
+ this.model?.set("title", suggestion);
+ this.args.close();
+ }
+
+ <template>
+ <div class="ai-suggestions-menu" {{didInsert this.loadSuggestions}}>
+ {{#if this.loading}}
+ <div class="ai-suggestions-menu__loading">{{dIcon "spinner"}}</div>
+ {{else if this.suggestions.length}}
+ <AiTitleSuggestionsList
+ @suggestions={{this.suggestions}}
+ @onSelect={{this.applySuggestion}}
+ />
+ {{else if this.noResults}}
+ <div class="ai-suggestions-menu__empty">
+ <span class="ai-suggestions-menu__empty-text">
+ {{i18n "discourse_ai.ai_helper.suggest_errors.no_suggestions"}}
+ </span>
+ <DButton
+ @icon="rotate"
+ @label="discourse_ai.ai_helper.context_menu.regen"
+ @action={{this.loadSuggestions}}
+ class="btn-small btn-transparent --primary"
+ />
+ </div>
+ {{/if}}
+ </div>
+ </template>
+}
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/connectors/after-composer-title-input/ai-title-suggestion.gjs b/plugins/discourse-ai/assets/javascripts/discourse/connectors/after-composer-title-input/ai-title-suggestion.gjs
deleted file mode 100644
index 4a8640778a9..00000000000
--- a/plugins/discourse-ai/assets/javascripts/discourse/connectors/after-composer-title-input/ai-title-suggestion.gjs
+++ /dev/null
@@ -1,20 +0,0 @@
-import Component from "@glimmer/component";
-import AiTitleSuggester from "../../components/suggestion-menus/ai-title-suggester";
-import { showComposerAiHelper } from "../../lib/show-ai-helper";
-
-export default class AiTitleSuggestion extends Component {
- static shouldRender(args, context) {
- return showComposerAiHelper(
- args?.composer,
- context.siteSettings,
- context.currentUser,
- "suggestions"
- );
- }
-
- <template>
- {{#unless @outletArgs.composer.disableTitleInput}}
- <AiTitleSuggester @composer={{@outletArgs.composer}} @topicState="new" />
- {{/unless}}
- </template>
-}
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-helper-suggestions.js b/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-helper-suggestions.js
index e2f665eb33c..a0ae778bcd2 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-helper-suggestions.js
+++ b/plugins/discourse-ai/assets/javascripts/discourse/lib/ai-helper-suggestions.js
@@ -1,9 +1,33 @@
import { getOwner } from "@ember/owner";
import { later } from "@ember/runloop";
+import { ajax } from "discourse/lib/ajax";
+import { popupAjaxError } from "discourse/lib/ajax-error";
import { i18n } from "discourse-i18n";
+import { isAiCreditLimitError, popupAiCreditLimitError } from "./ai-errors";
export const MIN_CHARACTER_COUNT = 40;
+// Fetches title suggestions from the server. Returns the suggestions array,
+// or null when the request failed (the relevant error is shown to the user).
+export async function fetchTitleSuggestions({ text, topicId }) {
+ const data = text ? { text } : { topic_id: topicId };
+
+ try {
+ const { suggestions } = await ajax(
+ "/discourse-ai/ai-helper/suggest_title",
+ { method: "POST", data }
+ );
+ return suggestions;
+ } catch (error) {
+ if (isAiCreditLimitError(error)) {
+ popupAiCreditLimitError(error);
+ } else {
+ popupAjaxError(error);
+ }
+ return null;
+ }
+}
+
export function tagNames(tags) {
return (tags ?? [])
.map((tag) => (typeof tag === "string" ? tag : tag?.name))
diff --git a/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scss b/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scss
index addd077b276..706e3025e5d 100644
--- a/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scss
+++ b/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scss
@@ -233,19 +233,13 @@
// Suggest Titles Related
.showing-ai-suggestions {
- .title-input {
- // border on focus should be on top of suggestion button
- input:focus {
- z-index: 1;
- }
- }
-
#edit-title {
padding-right: 2em;
}
}
-.suggestion-button {
+.suggestion-button,
+.ai-split-topic-suggestion-button {
.d-icon-spinner {
animation: spin 1s linear infinite;
}
@@ -260,7 +254,6 @@
.suggest-titles-button {
position: absolute;
- #reply-control &,
.edit-topic-title & {
background: var(--primary-low);
right: var(--space-1);
@@ -269,21 +262,12 @@
padding: 0.4em;
font-size: var(--font-down-1-rem);
z-index: z("composer", "dropdown");
+ transform: translateY(50%);
.d-icon {
color: var(--tertiary);
}
}
-
- .edit-topic-title & {
- transform: translateY(50%);
- }
-
- #reply-control & {
- transform: translateY(
- calc(50% - 0.25em)
- ); // .25em = half of input margin-bottom padding
- }
}
#reply-control {
@@ -294,12 +278,6 @@
// while also keeping them below the composer tips
z-index: z("composer", "dropdown") + 2;
}
-
- .showing-ai-suggestions {
- #reply-title {
- padding-right: 2em;
- }
- }
}
.ai-suggestions-menu .btn {
@@ -379,12 +357,6 @@
margin-bottom: 0;
}
}
-
- .ai-split-topic-suggestion-button {
- .d-icon-spinner {
- animation: spin 1s linear infinite;
- }
- }
}
.ai-split-topic-suggestion__results {
@@ -532,7 +504,8 @@
}
}
-.fk-d-menu {
+.fk-d-menu,
+.fk-d-menu-modal {
&[data-identifier="ai-composer-helper-menu"],
&[data-identifier="ai-title-suggester"] {
z-index: z("modal", "dialog");
@@ -541,8 +514,32 @@
z-index: z("header") + 1;
}
- .mobile-view & {
- z-index: z("mobile-composer");
+ .ai-suggestions-menu {
+ max-width: 100%;
+
+ &__loading {
+ text-align: center;
+ padding: var(--space-2);
+
+ .d-icon-spinner {
+ animation: spin 1s linear infinite;
+ }
+ }
+
+ &__empty {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+ padding: var(--space-1) var(--space-2) var(--space-1) var(--space-4);
+ }
+
+ &__empty-text {
+ font-size: var(--font-down-1-rem);
+ }
+
+ .d-button-label {
+ @include ellipsis;
+ }
}
}
}
diff --git a/plugins/discourse-ai/config/locales/server.en.yml b/plugins/discourse-ai/config/locales/server.en.yml
index 0de58de99fe..29728bc1dbd 100644
--- a/plugins/discourse-ai/config/locales/server.en.yml
+++ b/plugins/discourse-ai/config/locales/server.en.yml
@@ -114,7 +114,7 @@ en:
ai_helper_allowed_in_pm: "Enable the composer's AI helper in PMs."
ai_helper_automatic_chat_thread_title_delay: "Delay in minutes before the AI helper automatically sets the chat thread title."
ai_helper_automatic_chat_thread_title: "Automatically set the chat thread titles based on thread contents."
- ai_helper_enabled_features: "Select the features to enable in the AI helper."
+ ai_helper_enabled_features: "Select the features to enable in the AI helper. Title suggestions in the composer are offered through the AI helper menu and also require the context_menu feature."
ai_image_caption_agent: "The agent to use for AI image captions. Custom agents must have image uploads enabled and use a vision-capable LLM."
ai_post_image_captions_enabled: "Enable AI captions for post images. Generating missing captions requires a configured {{setting:ai_image_caption_agent}}."
ai_post_image_captions_per_post_limit: "Maximum number of post images to caption per post."
@@ -388,7 +388,7 @@ en:
unknown_error: "An unexpected error occurred while generating thumbnails. Please try again."
prompts:
translate: Translate to %{language}
- generate_titles: Suggest topic titles
+ generate_titles: Suggest topic title
proofread: Proofread text
markdown_table: Generate Markdown table
custom_prompt: "Custom Prompt"
diff --git a/plugins/discourse-ai/lib/ai_helper/assistant.rb b/plugins/discourse-ai/lib/ai_helper/assistant.rb
index d4c5a7a1e61..b914121d0a2 100644
--- a/plugins/discourse-ai/lib/ai_helper/assistant.rb
+++ b/plugins/discourse-ai/lib/ai_helper/assistant.rb
@@ -443,7 +443,7 @@ module DiscourseAi
when TRANSLATE
"language"
when GENERATE_TITLES
- "heading"
+ "discourse-h1"
when PROOFREAD
"spell-check"
when MARKDOWN_TABLE
diff --git a/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb b/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb
index 47ac3d2038e..879fbc3b3eb 100644
--- a/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb
+++ b/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb
@@ -238,7 +238,7 @@ RSpec.describe "AI Composer helper" do
end
end
- context "when suggesting titles with AI title suggester" do
+ context "when suggesting titles from the AI helper menu" do
let(:mode) { DiscourseAi::AiHelper::Assistant::GENERATE_TITLES }
let(:titles) do
@@ -253,12 +253,10 @@ RSpec.describe "AI Composer helper" do
}
end
- it "opens a menu with title suggestions" do
- visit("/latest")
- page.find("#create-topic").click
- composer.fill_content(input)
+ it "opens a dropdown with title suggestions" do
+ trigger_composer_helper(input)
DiscourseAi::Completions::Llm.with_prepared_responses([titles]) do
- ai_suggestion_dropdown.click_suggest_titles_button
+ ai_helper_menu.select_helper_model(mode)
wait_for { ai_suggestion_dropdown.has_dropdown? }
@@ -267,11 +265,9 @@ RSpec.describe "AI Composer helper" do
end
it "replaces the topic title with the selected title" do
- visit("/latest")
- page.find("#create-topic").click
- composer.fill_content(input)
+ trigger_composer_helper(input)
DiscourseAi::Completions::Llm.with_prepared_responses([titles]) do
- ai_suggestion_dropdown.click_suggest_titles_button
+ ai_helper_menu.select_helper_model(mode)
wait_for { ai_suggestion_dropdown.has_dropdown? }
ai_suggestion_dropdown.select_suggestion_by_value(1)
@@ -279,13 +275,10 @@ RSpec.describe "AI Composer helper" do
end
end
- it "closes the menu when clicking outside" do
- visit("/latest")
- page.find("#create-topic").click
- composer.fill_content(input)
-
+ it "closes the dropdown when clicking outside" do
+ trigger_composer_helper(input)
DiscourseAi::Completions::Llm.with_prepared_responses([titles]) do
- ai_suggestion_dropdown.click_suggest_titles_button
+ ai_helper_menu.select_helper_model(mode)
wait_for { ai_suggestion_dropdown.has_dropdown? }
@@ -295,15 +288,17 @@ RSpec.describe "AI Composer helper" do
end
end
- it "only shows trigger button if there is sufficient content in the composer" do
- visit("/latest")
- page.find("#create-topic").click
- composer.fill_content("abc")
+ it "only offers title suggestions when there is sufficient content in the composer" do
+ trigger_composer_helper("abc")
- expect(ai_suggestion_dropdown).to have_no_suggestion_button
+ expect(ai_helper_menu).to have_context_menu
+ expect(ai_helper_menu).to have_no_option(mode)
+ ai_helper_menu.press_escape_key
composer.fill_content(input)
- expect(ai_suggestion_dropdown).to have_suggestion_button
+ composer.click_toolbar_button("ai-helper-trigger")
+
+ expect(ai_helper_menu).to have_option(mode)
end
end
@@ -524,7 +519,6 @@ RSpec.describe "AI Composer helper" do
end
context "when AI helper is disabled" do
- let(:mode) { DiscourseAi::AiHelper::Assistant::GENERATE_TITLES }
before { SiteSetting.ai_helper_enabled = false }
it "does not show the AI helper button in the composer toolbar" do
@@ -533,17 +527,9 @@ RSpec.describe "AI Composer helper" do
composer.fill_content(input)
expect(page).to have_no_css(".d-editor-button-bar button.ai-helper-trigger")
end
-
- it "does not trigger AI suggestion buttons" do
- visit("/latest")
- page.find("#create-topic").click
- composer.fill_content(input)
- expect(ai_suggestion_dropdown).to have_no_suggestion_button
- end
end
context "when user is not a member of AI helper allowed group" do
- let(:mode) { DiscourseAi::AiHelper::Assistant::GENERATE_TITLES }
before { SiteSetting.composer_ai_helper_allowed_groups = non_member_group.id.to_s }
it "does not show the AI helper button in the composer toolbar" do
@@ -552,24 +538,16 @@ RSpec.describe "AI Composer helper" do
composer.fill_content(input)
expect(page).to have_no_css(".d-editor-button-bar button.ai-helper-trigger")
end
-
- it "does not trigger AI suggestion buttons" do
- visit("/latest")
- page.find("#create-topic").click
- composer.fill_content(input)
- expect(ai_suggestion_dropdown).to have_no_suggestion_button
- end
end
- context "when suggestion features are disabled" do
+ context "when the suggestions feature is disabled" do
let(:mode) { DiscourseAi::AiHelper::Assistant::GENERATE_TITLES }
before { SiteSetting.ai_helper_enabled_features = "context_menu" }
- it "does not show suggestion buttons in the composer" do
- visit("/latest")
- page.find("#create-topic").click
- composer.fill_content(input)
- expect(ai_suggestion_dropdown).to have_no_suggestion_button
+ it "does not offer title suggestions in the AI helper menu" do
+ trigger_composer_helper(input)
+ expect(ai_helper_menu).to have_context_menu
+ expect(ai_helper_menu).to have_no_option(mode)
end
end
diff --git a/plugins/discourse-ai/spec/system/page_objects/components/ai_composer_helper_menu.rb b/plugins/discourse-ai/spec/system/page_objects/components/ai_composer_helper_menu.rb
index 1cd657a3008..55cbd1f776d 100644
--- a/plugins/discourse-ai/spec/system/page_objects/components/ai_composer_helper_menu.rb
+++ b/plugins/discourse-ai/spec/system/page_objects/components/ai_composer_helper_menu.rb
@@ -17,6 +17,14 @@ module PageObjects
).click
end
+ def has_option?(mode)
+ page.has_css?("#{OPTIONS_STATE_SELECTOR} li[data-value=\"#{mode}\"]")
+ end
+
+ def has_no_option?(mode)
+ page.has_no_css?("#{OPTIONS_STATE_SELECTOR} li[data-value=\"#{mode}\"]")
+ end
+
def press_undo_keys
find(COMPOSER_EDITOR_SELECTOR).send_keys([PLATFORM_KEY_MODIFIER, "z"])
end
diff --git a/plugins/discourse-ai/spec/system/page_objects/components/ai_suggestion_dropdown.rb b/plugins/discourse-ai/spec/system/page_objects/components/ai_suggestion_dropdown.rb
index eed37efbb97..0e4541f7e95 100644
--- a/plugins/discourse-ai/spec/system/page_objects/components/ai_suggestion_dropdown.rb
+++ b/plugins/discourse-ai/spec/system/page_objects/components/ai_suggestion_dropdown.rb
@@ -3,27 +3,12 @@
module PageObjects
module Components
class AiSuggestionDropdown < PageObjects::Components::Base
- SUGGESTION_BUTTON_SELECTOR = ".suggestion-button"
- TITLE_BUTTON_SELECTOR = "#{SUGGESTION_BUTTON_SELECTOR}.suggest-titles-button"
MENU_SELECTOR = ".ai-suggestions-menu"
- def click_suggest_titles_button
- page.find(TITLE_BUTTON_SELECTOR, visible: :all).click
- end
-
def select_suggestion_by_value(index)
find("#{MENU_SELECTOR} button[data-value=\"#{index}\"]").click
end
- def select_suggestion_by_name(name)
- find("#{MENU_SELECTOR} button[data-name=\"#{name}\"]").click
- end
-
- def suggestion_name(index)
- suggestion = find("#{MENU_SELECTOR} button[data-value=\"#{index}\"]")
- suggestion["data-name"]
- end
-
def has_dropdown?
has_css?(MENU_SELECTOR)
end
@@ -31,14 +16,6 @@ module PageObjects
def has_no_dropdown?
has_no_css?(MENU_SELECTOR)
end
-
- def has_suggestion_button?
- has_css?(SUGGESTION_BUTTON_SELECTOR)
- end
-
- def has_no_suggestion_button?
- has_no_css?(SUGGESTION_BUTTON_SELECTOR)
- end
end
end
end