Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions app/controllers/discourse_ai/ai_bot/conversations_controller.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default class AiBotHeaderIcon extends Component {
@service currentUser;
@service siteSettings;
@service composer;
@service router;

get bots() {
const availableBots = this.currentUser.ai_enabled_chat_bots
Expand All @@ -25,9 +24,6 @@ export default class AiBotHeaderIcon extends Component {

@action
compose() {
if (this.siteSettings.ai_enable_experimental_bot_ux) {
return this.router.transitionTo("discourse-ai-bot-conversations");
}
composeAiBotMessage(this.bots[0], this.composer);
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

51 changes: 16 additions & 35 deletions assets/javascripts/discourse/lib/ai-bot-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,24 @@ export function showShareConversationModal(modal, topicId) {
.catch(popupAjaxError);
}

export async function composeAiBotMessage(
targetBot,
composer,
options = {
skipFocus: false,
topicBody: "",
personaUsername: null,
}
) {
export function composeAiBotMessage(targetBot, composer) {
const currentUser = composer.currentUser;
const draftKey = "new_private_message_ai_" + new Date().getTime();

let botUsername;
if (targetBot) {
botUsername = currentUser.ai_enabled_chat_bots.find(
(bot) => bot.model_name === targetBot
)?.username;
} else if (options.personaUsername) {
botUsername = options.personaUsername;
} else {
botUsername = currentUser.ai_enabled_chat_bots[0].username;
}
let botUsername = currentUser.ai_enabled_chat_bots.find(
(bot) => bot.model_name === targetBot
).username;

const data = {
action: Composer.PRIVATE_MESSAGE,
recipients: botUsername,
topicTitle: i18n("discourse_ai.ai_bot.default_pm_prefix"),
archetypeId: "private_message",
draftKey,
hasGroups: false,
warningsDisabled: true,
};

if (options.skipFocus) {
data.topicBody = options.topicBody;
await composer.open(data);
} else {
composer.focusComposer({ fallbackToNewTopic: true, openOpts: data });
}
composer.focusComposer({
fallbackToNewTopic: true,
openOpts: {
action: Composer.PRIVATE_MESSAGE,
recipients: botUsername,
topicTitle: i18n("discourse_ai.ai_bot.default_pm_prefix"),
archetypeId: "private_message",
draftKey,
hasGroups: false,
warningsDisabled: true,
},
});
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading