From 4f980d5514f571683596bb9042968d210feb0cef Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 3 Jun 2025 14:52:12 -0400 Subject: [PATCH] FIX: always render "today" on top of conversation sidebar (#1400) --- .../ai-conversations-sidebar-manager.js | 18 ++++++++++++++---- .../modules/ai-bot-conversations/common.scss | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js b/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js index 64c4f376..4628a236 100644 --- a/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js +++ b/assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js @@ -216,6 +216,13 @@ export default class AiConversationsSidebarManager extends Service { const now = Date.now(); const fresh = []; + const todaySection = { + name: "today", + title: i18n("discourse_ai.ai_bot.conversations.today"), + links: new TrackedArray(), + }; + fresh.push(todaySection); + this.topics.forEach((t) => { const postedAtMs = new Date(t.last_posted_at || now).valueOf(); const diffDays = Math.floor((now - postedAtMs) / 86400000); @@ -233,13 +240,16 @@ export default class AiConversationsSidebarManager extends Service { dateGroup = key; } - let sec = fresh.find((s) => s.name === dateGroup); + let sec; + if (dateGroup === "today") { + sec = todaySection; + } else { + sec = fresh.find((s) => s.name === dateGroup); + } + if (!sec) { let title; switch (dateGroup) { - case "today": - title = i18n("discourse_ai.ai_bot.conversations.today"); - break; case "last-7-days": title = i18n("discourse_ai.ai_bot.conversations.last_7_days"); break; diff --git a/assets/stylesheets/modules/ai-bot-conversations/common.scss b/assets/stylesheets/modules/ai-bot-conversations/common.scss index 8b3b01e2..db1954e0 100644 --- a/assets/stylesheets/modules/ai-bot-conversations/common.scss +++ b/assets/stylesheets/modules/ai-bot-conversations/common.scss @@ -23,6 +23,11 @@ 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) { + display: none; + } + .sidebar-toggle-all-sections { display: none; }