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
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export default class AiConversationsSidebarManager extends Service {
);
}

addEmptyStateClass() {
document.body.classList.toggle(
"has-empty-ai-conversations-sidebar",
!this.topics.length
);
}

forceCustomSidebar() {
document.body.classList.add("has-ai-conversations-sidebar");
if (!this.sidebarState.isForcingSidebar) {
Expand All @@ -100,13 +107,15 @@ export default class AiConversationsSidebarManager extends Service {

// don't render sidebar multiple times
if (this._didInit) {
this.addEmptyStateClass();
return true;
}

this._didInit = true;

this.fetchMessages().then(() => {
this.sidebarState.setPanel(AI_CONVERSATIONS_PANEL);
this.addEmptyStateClass();
});

return true;
Expand Down Expand Up @@ -140,6 +149,7 @@ export default class AiConversationsSidebarManager extends Service {

stopForcingCustomSidebar() {
document.body.classList.remove("has-ai-conversations-sidebar");
document.body.classList.remove("has-empty-ai-conversations-sidebar");

const isAdmin = this.sidebarState.currentPanel?.key === ADMIN_PANEL;
if (this.sidebarState.isForcingSidebar && !isAdmin) {
Expand Down
16 changes: 14 additions & 2 deletions assets/stylesheets/modules/ai-bot-conversations/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@ body.has-ai-conversations-sidebar {
}
}

// we always have the "today" section rendered at the top of the sidebar but hide it when empty
.sidebar-section[data-section-name="today"]:has(.ai-bot-sidebar-empty-state) {
// When the sidebar is empty, we want to hide the "Today" header
// and only show the empty state component
&.has-empty-ai-conversations-sidebar
.sidebar-section[data-section-name="today"]
.sidebar-section-header-wrapper {
display: none;
}

// When the sidebar isn't empty, BUT "today" is empty, hide
// the entire section
&:not(.has-empty-ai-conversations-sidebar)
.sidebar-section[data-section-name="today"]:has(
.ai-bot-sidebar-empty-state
) {
display: none;
}

Expand Down
16 changes: 16 additions & 0 deletions spec/system/ai_bot/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@
expect(sidebar).to have_section_link(pm.title)
end

it "shows empty state when no PMs exist" do
pm.destroy!

visit "/"
header.click_bot_button

expect(page).to have_css(".sidebar-section .ai-bot-sidebar-empty-state", visible: true)
end

it "doesn't show empty state when a PM exists" do
visit "/"
header.click_bot_button

expect(page).to have_no_css(".sidebar-section .ai-bot-sidebar-empty-state")
end

it "displays last_7_days label in the sidebar" do
pm.update!(last_posted_at: Time.zone.now - 5.days)
visit "/"
Expand Down