This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
javascripts/discourse/services
stylesheets/modules/ai-bot-conversations Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ export default class AiConversationsSidebarManager extends Service {
8484 ) ;
8585 }
8686
87+ addEmptyStateClass ( ) {
88+ document . body . classList . toggle (
89+ "has-empty-ai-conversations-sidebar" ,
90+ ! this . topics . length
91+ ) ;
92+ }
93+
8794 forceCustomSidebar ( ) {
8895 document . body . classList . add ( "has-ai-conversations-sidebar" ) ;
8996 if ( ! this . sidebarState . isForcingSidebar ) {
@@ -100,13 +107,15 @@ export default class AiConversationsSidebarManager extends Service {
100107
101108 // don't render sidebar multiple times
102109 if ( this . _didInit ) {
110+ this . addEmptyStateClass ( ) ;
103111 return true ;
104112 }
105113
106114 this . _didInit = true ;
107115
108116 this . fetchMessages ( ) . then ( ( ) => {
109117 this . sidebarState . setPanel ( AI_CONVERSATIONS_PANEL ) ;
118+ this . addEmptyStateClass ( ) ;
110119 } ) ;
111120
112121 return true ;
@@ -140,6 +149,7 @@ export default class AiConversationsSidebarManager extends Service {
140149
141150 stopForcingCustomSidebar ( ) {
142151 document . body . classList . remove ( "has-ai-conversations-sidebar" ) ;
152+ document . body . classList . remove ( "has-empty-ai-conversations-sidebar" ) ;
143153
144154 const isAdmin = this . sidebarState . currentPanel ?. key === ADMIN_PANEL ;
145155 if ( this . sidebarState . isForcingSidebar && ! isAdmin ) {
Original file line number Diff line number Diff line change @@ -23,8 +23,20 @@ body.has-ai-conversations-sidebar {
2323 }
2424 }
2525
26- // we always have the "today" section rendered at the top of the sidebar but hide it when empty
27- .sidebar-section [data-section-name = " today" ]:has (.ai-bot-sidebar-empty-state ) {
26+ // When the sidebar is empty, we want to hide the "Today" header
27+ // and only show the empty state component
28+ & .has-empty-ai-conversations-sidebar
29+ .sidebar-section [data-section-name = " today" ]
30+ .sidebar-section-header-wrapper {
31+ display : none ;
32+ }
33+
34+ // When the sidebar isn't empty, BUT "today" is empty, hide
35+ // the entire section
36+ & :not (.has-empty-ai-conversations-sidebar )
37+ .sidebar-section [data-section-name = " today" ]:has (
38+ .ai-bot-sidebar-empty-state
39+ ) {
2840 display : none ;
2941 }
3042
Original file line number Diff line number Diff line change 226226 expect ( sidebar ) . to have_section_link ( pm . title )
227227 end
228228
229+ it "shows empty state when no PMs exist" do
230+ pm . destroy!
231+
232+ visit "/"
233+ header . click_bot_button
234+
235+ expect ( page ) . to have_css ( ".sidebar-section .ai-bot-sidebar-empty-state" , visible : true )
236+ end
237+
238+ it "doesn't show empty state when a PM exists" do
239+ visit "/"
240+ header . click_bot_button
241+
242+ expect ( page ) . to have_no_css ( ".sidebar-section .ai-bot-sidebar-empty-state" )
243+ end
244+
229245 it "displays last_7_days label in the sidebar" do
230246 pm . update! ( last_posted_at : Time . zone . now - 5 . days )
231247 visit "/"
You can’t perform that action at this time.
0 commit comments