Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 06ab446

Browse files
authored
UX: Adjust bot conversation header and sidebar on hamburger mode (#1295)
Context in dev conversation -- in hamburger mode we don't need the robot icon to swap to shuffle, AND we don't need back to forum link.
1 parent 541e6d7 commit 06ab446

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

assets/javascripts/discourse/components/ai-bot-header-icon.gjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AI_CONVERSATIONS_PANEL } from "../services/ai-conversations-sidebar-man
1010
export default class AiBotHeaderIcon extends Component {
1111
@service composer;
1212
@service currentUser;
13+
@service navigationMenu;
1314
@service router;
1415
@service sidebarState;
1516
@service siteSettings;
@@ -35,6 +36,7 @@ export default class AiBotHeaderIcon extends Component {
3536

3637
get clickShouldRouteOutOfConversations() {
3738
return (
39+
!this.navigationMenu.isHeaderDropdownMode &&
3840
this.siteSettings.ai_enable_experimental_bot_ux &&
3941
this.sidebarState.currentPanel?.key === AI_CONVERSATIONS_PANEL
4042
);

assets/javascripts/initializers/ai-conversations-sidebar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ export default {
2929
);
3030
const appEvents = api.container.lookup("service:app-events");
3131
const messageBus = api.container.lookup("service:message-bus");
32+
const navigationMenu = api.container.lookup("service:navigationMenu");
3233

3334
api.addSidebarPanel(
3435
(BaseCustomSidebarPanel) =>
3536
class AiConversationsSidebarPanel extends BaseCustomSidebarPanel {
3637
key = AI_CONVERSATIONS_PANEL;
3738
hidden = true;
38-
displayHeader = true;
39+
displayHeader = !navigationMenu.isHeaderDropdownMode;
3940
expandActiveSection = true;
4041
}
4142
);

spec/system/ai_bot/homepage_spec.rb

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999

100100
SiteSetting.ai_enable_experimental_bot_ux = true
101101
SiteSetting.ai_bot_enabled = true
102+
SiteSetting.navigation_menu = "sidebar"
102103
Jobs.run_immediately!
103104
SiteSetting.ai_bot_allowed_groups = "#{Group::AUTO_GROUPS[:trust_level_0]}"
104105
sign_in(user)
@@ -123,15 +124,6 @@
123124
expect(composer).to be_closed
124125
end
125126

126-
it "renders sidebar even when navigation menu is set to header" do
127-
SiteSetting.navigation_menu = "header dropdown"
128-
visit "/"
129-
header.click_bot_button
130-
expect(ai_pm_homepage).to have_homepage
131-
expect(sidebar).to be_visible
132-
expect(header_dropdown).to be_visible
133-
end
134-
135127
it "hides default content in the sidebar" do
136128
visit "/"
137129
header.click_bot_button
@@ -266,6 +258,31 @@
266258
ai_pm_homepage.llm_selector.select_row_by_name(claude_2_dup.display_name)
267259
ai_pm_homepage.llm_selector.collapse
268260
end
261+
262+
it "renders back to forum link" do
263+
ai_pm_homepage.visit
264+
expect(ai_pm_homepage).to have_sidebar_back_link
265+
end
266+
267+
context "with hamburger menu" do
268+
before { SiteSetting.navigation_menu = "header dropdown" }
269+
it "keeps robot icon in the header and doesn't display sidebar back link" do
270+
visit "/"
271+
expect(header).to have_icon_in_bot_button(icon: "robot")
272+
header.click_bot_button
273+
expect(ai_pm_homepage).to have_homepage
274+
expect(header).to have_icon_in_bot_button(icon: "robot")
275+
expect(ai_pm_homepage).to have_no_sidebar_back_link
276+
end
277+
278+
it "still renders the sidebar" do
279+
visit "/"
280+
header.click_bot_button
281+
expect(ai_pm_homepage).to have_homepage
282+
expect(sidebar).to be_visible
283+
expect(header_dropdown).to be_visible
284+
end
285+
end
269286
end
270287

271288
context "when `ai_enable_experimental_bot_ux` is disabled" do

spec/system/page_objects/components/ai_pm_homepage.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ def persona_selector
5353
def llm_selector
5454
PageObjects::Components::SelectKit.new(".persona-llm-selector__llm-dropdown")
5555
end
56+
57+
def has_sidebar_back_link?
58+
page.has_css?(".sidebar-sections__back-to-forum")
59+
end
60+
61+
def has_no_sidebar_back_link?
62+
page.has_no_css?(".sidebar-sections__back-to-forum")
63+
end
5664
end
5765
end
5866
end

0 commit comments

Comments
 (0)