diff --git a/assets/javascripts/initializers/ai-conversations-sidebar.js b/assets/javascripts/initializers/ai-conversations-sidebar.js index a60ee284..69b01a3d 100644 --- a/assets/javascripts/initializers/ai-conversations-sidebar.js +++ b/assets/javascripts/initializers/ai-conversations-sidebar.js @@ -87,6 +87,7 @@ export default { @tracked links = new TrackedArray(); @tracked topics = []; @tracked hasMore = []; + @tracked loadedTodayLabel = false; @tracked loadedSevenDayLabel = false; @tracked loadedThirtyDayLabel = false; @tracked loadedMonthLabels = new Set(); @@ -133,6 +134,7 @@ export default { addNewPMToSidebar(topic) { // Reset category labels since we're adding a new topic + this.loadedTodayLabel = false; this.loadedSevenDayLabel = false; this.loadedThirtyDayLabel = false; this.loadedMonthLabels.clear(); @@ -225,8 +227,18 @@ export default { (now - lastPostedAt) / (1000 * 60 * 60 * 24) ); + if (daysDiff <= 1 || !topic.last_posted_at) { + if (!this.loadedTodayLabel) { + this.loadedTodayLabel = true; + return { + text: i18n("discourse_ai.ai_bot.conversations.today"), + classNames: "date-heading", + name: "date-heading-today", + }; + } + } // Last 7 days group - if (daysDiff <= 7) { + else if (daysDiff <= 7) { if (!this.loadedSevenDayLabel) { this.loadedSevenDayLabel = true; return { @@ -273,6 +285,7 @@ export default { buildSidebarLinks() { // Reset date header tracking + this.loadedTodayLabel = false; this.loadedSevenDayLabel = false; this.loadedThirtyDayLabel = false; this.loadedMonthLabels.clear(); diff --git a/assets/stylesheets/modules/ai-bot-conversations/common.scss b/assets/stylesheets/modules/ai-bot-conversations/common.scss index b5dbd877..213003ba 100644 --- a/assets/stylesheets/modules/ai-bot-conversations/common.scss +++ b/assets/stylesheets/modules/ai-bot-conversations/common.scss @@ -33,10 +33,7 @@ body.has-ai-conversations-sidebar { opacity: 0.8; font-weight: 700; margin-top: 1em; - - &[data-link-name="date-heading-last-7-days"] { - margin-top: 0; - } + font-size: var(--font-down-2); } .sidebar-section-link { @@ -236,12 +233,6 @@ body.has-ai-conversations-sidebar { max-height: 2.5em; } - .spinner { - margin: 0; - width: 2em; - height: 2em; - } - #ai-bot-conversations-input { width: 100%; margin: 0; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 9ec92915..8e02e480 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -727,6 +727,7 @@ en: new: "New Question" min_input_length_message: "Message must be longer than 10 characters" messages_sidebar_title: "Conversations" + today: "Today" last_7_days: "Last 7 days" last_30_days: "Last 30 days" sentiments: diff --git a/spec/system/ai_bot/homepage_spec.rb b/spec/system/ai_bot/homepage_spec.rb index d166a36f..14033959 100644 --- a/spec/system/ai_bot/homepage_spec.rb +++ b/spec/system/ai_bot/homepage_spec.rb @@ -151,11 +151,20 @@ RSpec.describe "AI Bot - Homepage", type: :system do expect(ai_pm_homepage).to have_homepage expect(sidebar).to have_section("ai-conversations-history") - expect(sidebar).to have_section_link("Last 7 days") + expect(sidebar).to have_section_link("Today") expect(sidebar).to have_section_link(pm.title) expect(sidebar).to have_no_css("button.ai-new-question-button") end + it "displays last_7_days label in the sidebar" do + pm.update!(last_posted_at: Time.zone.now - 5.days) + visit "/" + header.click_bot_button + + expect(ai_pm_homepage).to have_homepage + expect(sidebar).to have_section_link("Last 7 days") + end + it "displays last_30_days label in the sidebar" do pm.update!(last_posted_at: Time.zone.now - 28.days) visit "/"