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 4 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { i18n } from "discourse-i18n";

<template>
<div class="ai-bot-sidebar-empty-state">
{{i18n "discourse_ai.ai_bot.sidebar_empty"}}
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ export default class AiBotSidebarNewConversation extends Component {
@service sidebarState;

get shouldRender() {
return (
this.router.currentRouteName !== "discourse-ai-bot-conversations" &&
this.sidebarState.isCurrentPanel(AI_CONVERSATIONS_PANEL)
);
return this.sidebarState.isCurrentPanel(AI_CONVERSATIONS_PANEL);
}

@action
routeTo() {
this.router.transitionTo("/discourse-ai/ai-bot/conversations");
if (this.router.currentRouteName !== "discourse-ai-bot-conversations") {
this.router.transitionTo("/discourse-ai/ai-bot/conversations");
}
this.args.outletArgs?.toggleNavigationMenu?.();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default RouteTemplate(
{{on "input" @controller.updateInputValue}}
{{on "keydown" @controller.handleKeyDown}}
id="ai-bot-conversations-input"
autofocus="true"
placeholder={{i18n "discourse_ai.ai_bot.conversations.placeholder"}}
minlength="10"
disabled={{@controller.loading}}
Expand Down
5 changes: 5 additions & 0 deletions assets/javascripts/initializers/ai-conversations-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { bind } from "discourse/lib/decorators";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
import { withPluginApi } from "discourse/lib/plugin-api";
import { i18n } from "discourse-i18n";
import AiBotSidebarEmptyState from "../discourse/components/ai-bot-sidebar-empty-state";
import AiBotSidebarNewConversation from "../discourse/components/ai-bot-sidebar-new-conversation";
import { AI_CONVERSATIONS_PANEL } from "../discourse/services/ai-conversations-sidebar-manager";

Expand Down Expand Up @@ -121,6 +122,10 @@ export default {
return "ai-conversations-history";
}

get emptyStateComponent() {
return AiBotSidebarEmptyState;
}

get text() {
return i18n(
"discourse_ai.ai_bot.conversations.messages_sidebar_title"
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ en:
share: "Copy AI conversation"
conversation_shared: "Conversation copied"
debug_ai: "View raw AI request and response"
sidebar_empty: "Bot conversation history will appear here."
debug_ai_modal:
title: "View AI interaction"
copy_request: "Copy request"
Expand Down
24 changes: 23 additions & 1 deletion spec/system/ai_bot/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,22 @@
expect(header).to have_icon_in_bot_button(icon: "robot")
end

it "displays 'new question' button on the topic page" do
topic_page.visit_topic(pm)
expect(sidebar).to have_css(
"button.ai-new-question-button",
text: I18n.t("js.discourse_ai.ai_bot.conversations.new"),
)
end

it "displays 'new question' button on the topic page" do
ai_pm_homepage.visit
expect(sidebar).to have_css(
"button.ai-new-question-button",
text: I18n.t("js.discourse_ai.ai_bot.conversations.new"),
)
end

it "displays sidebar and 'new question' on the topic page" do
topic_page.visit_topic(pm)
expect(sidebar).to be_visible
Expand Down Expand Up @@ -232,6 +248,7 @@
Fabricate(:post, topic: pm, user: user_2, post_number: 4)
Fabricate(:topic_allowed_user, topic: pm, user: user_2)
sign_in(user_2)

topic_page.visit_topic(pm)

expect(sidebar).to be_visible
Expand All @@ -244,13 +261,18 @@
Fabricate(:post, topic: pm, user: user_2, post_number: 4)
Fabricate(:topic_allowed_user, topic: pm, user: user_2)
sign_in(user_2)

visit "/"
header.click_bot_button
expect(ai_pm_homepage).to have_homepage
expect(sidebar).to have_no_section_link(pm.title)
end

it "renders empty state in sidebar with no bot PM history" do
sign_in(user_2)
ai_pm_homepage.visit
expect(ai_pm_homepage).to have_empty_state
end

it "Allows choosing persona and LLM" do
ai_pm_homepage.visit

Expand Down
4 changes: 4 additions & 0 deletions spec/system/page_objects/components/ai_pm_homepage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def click_new_question_button
page.find(".ai-new-question-button").click
end

def has_empty_state?
page.has_css?(".ai-bot-sidebar-empty-state")
end

def click_fist_sidebar_conversation
page.find(
".sidebar-section[data-section-name='ai-conversations-history'] a.sidebar-section-link:not(.date-heading)",
Expand Down
Loading