From 74a7ac4a3d04726c34ab0b6fd9cfbf1b44a793f6 Mon Sep 17 00:00:00 2001 From: Keegan George Date: Thu, 14 Dec 2023 08:47:20 -0800 Subject: [PATCH] FEATURE: Add custom prompts to post helper options (#355) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * FEATURE: Add custom prompts to post helper options * 💄Make pretty * 💄Make pretty! --- .../components/ai-helper-custom-prompt.gjs | 46 ++++++++++ .../after-d-editor/ai-helper-context-menu.hbs | 26 ++---- .../ai-helper-options-menu.gjs | 83 +++++++++++++------ .../modules/ai-helper/common/ai-helper.scss | 49 +++++------ lib/ai_helper/assistant.rb | 4 +- 5 files changed, 131 insertions(+), 77 deletions(-) create mode 100644 assets/javascripts/discourse/components/ai-helper-custom-prompt.gjs diff --git a/assets/javascripts/discourse/components/ai-helper-custom-prompt.gjs b/assets/javascripts/discourse/components/ai-helper-custom-prompt.gjs new file mode 100644 index 00000000..b94cf0bd --- /dev/null +++ b/assets/javascripts/discourse/components/ai-helper-custom-prompt.gjs @@ -0,0 +1,46 @@ +import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; +import { Input } from "@ember/component"; +import { action } from "@ember/object"; +import didInsert from "@ember/render-modifiers/modifiers/did-insert"; +import DButton from "discourse/components/d-button"; +import i18n from "discourse-common/helpers/i18n"; +import not from "truth-helpers/helpers/not"; + +export default class AiHelperCustomPrompt extends Component { + + + @tracked _customPromptInput; + + @action + setupCustomPrompt() { + this._customPromptInput = document.querySelector( + ".ai-custom-prompt__input" + ); + this._customPromptInput.focus(); + } + + @action + sendInput() { + return this.args.submit(this.args.promptArgs); + } +} 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 b63cad7a..14843893 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 @@ -17,27 +17,11 @@