diff --git a/assets/javascripts/discourse/connectors/after-composer-title-input/ai-title-suggester.gjs b/assets/javascripts/discourse/connectors/after-composer-title-input/ai-title-suggester.gjs
new file mode 100644
index 00000000..6350270a
--- /dev/null
+++ b/assets/javascripts/discourse/connectors/after-composer-title-input/ai-title-suggester.gjs
@@ -0,0 +1,108 @@
+import Component from '@glimmer/component';
+import DButton from "discourse/components/d-button";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import { ajax } from "discourse/lib/ajax";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+import didInsert from "@ember/render-modifiers/modifiers/did-insert";
+import { bind } from "discourse-common/utils/decorators";
+
+export default class AITitleSuggester extends Component {
+
+
+ {{#if this.showMenu}}
+ {{! template-lint-disable modifier-name-case }}
+
+ {{/if}}
+
+
+ @tracked loading = false;
+ @tracked showMenu = false;
+ @tracked generatedTitleSuggestions = [];
+ @tracked suggestTitleIcon = "discourse-sparkles";
+ mode = {
+ id: -2,
+ name: "generate_titles",
+ translated_name: "Suggest topic titles",
+ prompt_type: "list"
+ };
+
+ willDestroy() {
+ super.willDestroy(...arguments);
+ document.removeEventListener("click", this.onClickOutside);
+ }
+
+ get composerInput() {
+ return document.querySelector(".d-editor-input").value || this.args.outletArgs.composer.reply;
+ }
+
+ get disableSuggestionButton() {
+ return this.loading;
+ }
+
+ closeMenu() {
+ this.suggestTitleIcon = "discourse-sparkles";
+ this.showMenu = false;
+ }
+
+ @bind
+ onClickOutside(event) {
+ const menu = document.querySelector(".ai-title-suggestions-menu");
+
+ if (event.target === menu) {
+ return;
+ }
+
+ return this.closeMenu();
+ }
+
+ @action
+ handleClickOutside() {
+ document.addEventListener("click", this.onClickOutside);
+ }
+
+ @action
+ updateTopicTitle(title) {
+ const composer = this.args.outletArgs?.composer;
+
+ if (composer) {
+ composer.set("title", title);
+ this.closeMenu();
+ }
+ }
+
+ @action
+ async suggestTitles() {
+ this.loading = true;
+ this.suggestTitleIcon = "spinner";
+
+ return ajax("/discourse-ai/ai-helper/suggest", {
+ method: "POST",
+ data: { mode: this.mode.id, text: this.composerInput },
+ }).then((data) => {
+ this.generatedTitleSuggestions = data.suggestions;
+ }).catch(popupAjaxError).finally(() => {
+ this.loading = false;
+ this.suggestTitleIcon = "sync-alt";
+ this.showMenu = true;
+ });
+
+ }
+}
\ No newline at end of file
diff --git a/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.hbs b/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.hbs
index edb11df2..d4e3e557 100644
--- a/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.hbs
+++ b/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.hbs
@@ -27,20 +27,6 @@
{{/each}}
- {{else if (eq this.menuState this.CONTEXT_MENU_STATES.suggestions)}}
-
-
{{else if (eq this.menuState this.CONTEXT_MENU_STATES.loading)}}