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

Commit 4f980d5

Browse files
authored
FIX: always render "today" on top of conversation sidebar (#1400)
1 parent 59f4b66 commit 4f980d5

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

assets/javascripts/discourse/services/ai-conversations-sidebar-manager.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ export default class AiConversationsSidebarManager extends Service {
216216
const now = Date.now();
217217
const fresh = [];
218218

219+
const todaySection = {
220+
name: "today",
221+
title: i18n("discourse_ai.ai_bot.conversations.today"),
222+
links: new TrackedArray(),
223+
};
224+
fresh.push(todaySection);
225+
219226
this.topics.forEach((t) => {
220227
const postedAtMs = new Date(t.last_posted_at || now).valueOf();
221228
const diffDays = Math.floor((now - postedAtMs) / 86400000);
@@ -233,13 +240,16 @@ export default class AiConversationsSidebarManager extends Service {
233240
dateGroup = key;
234241
}
235242

236-
let sec = fresh.find((s) => s.name === dateGroup);
243+
let sec;
244+
if (dateGroup === "today") {
245+
sec = todaySection;
246+
} else {
247+
sec = fresh.find((s) => s.name === dateGroup);
248+
}
249+
237250
if (!sec) {
238251
let title;
239252
switch (dateGroup) {
240-
case "today":
241-
title = i18n("discourse_ai.ai_bot.conversations.today");
242-
break;
243253
case "last-7-days":
244254
title = i18n("discourse_ai.ai_bot.conversations.last_7_days");
245255
break;

assets/stylesheets/modules/ai-bot-conversations/common.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ 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) {
28+
display: none;
29+
}
30+
2631
.sidebar-toggle-all-sections {
2732
display: none;
2833
}

0 commit comments

Comments
 (0)