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

Commit 76a5fa7

Browse files
committed
DEV: Update sidebar grouping date labels
1 parent 81ef532 commit 76a5fa7

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default {
8787
@tracked links = new TrackedArray();
8888
@tracked topics = [];
8989
@tracked hasMore = [];
90+
@tracked loadedTodayLabel = false;
9091
@tracked loadedSevenDayLabel = false;
9192
@tracked loadedThirtyDayLabel = false;
9293
@tracked loadedMonthLabels = new Set();
@@ -133,6 +134,7 @@ export default {
133134

134135
addNewPMToSidebar(topic) {
135136
// Reset category labels since we're adding a new topic
137+
this.loadedTodayLabel = false;
136138
this.loadedSevenDayLabel = false;
137139
this.loadedThirtyDayLabel = false;
138140
this.loadedMonthLabels.clear();
@@ -225,8 +227,18 @@ export default {
225227
(now - lastPostedAt) / (1000 * 60 * 60 * 24)
226228
);
227229

230+
if (daysDiff <= 1 || !topic.last_posted_at) {
231+
if (!this.loadedTodayLabel) {
232+
this.loadedTodayLabel = true;
233+
return {
234+
text: i18n("discourse_ai.ai_bot.conversations.today"),
235+
classNames: "date-heading",
236+
name: "date-heading-today",
237+
};
238+
}
239+
}
228240
// Last 7 days group
229-
if (daysDiff <= 7) {
241+
else if (daysDiff <= 7) {
230242
if (!this.loadedSevenDayLabel) {
231243
this.loadedSevenDayLabel = true;
232244
return {
@@ -273,6 +285,7 @@ export default {
273285

274286
buildSidebarLinks() {
275287
// Reset date header tracking
288+
this.loadedTodayLabel = false;
276289
this.loadedSevenDayLabel = false;
277290
this.loadedThirtyDayLabel = false;
278291
this.loadedMonthLabels.clear();

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ body.has-ai-conversations-sidebar {
3333
opacity: 0.8;
3434
font-weight: 700;
3535
margin-top: 1em;
36-
37-
&[data-link-name="date-heading-last-7-days"] {
38-
margin-top: 0;
39-
}
36+
font-size: var(--font-down-2);
4037
}
4138

4239
.sidebar-section-link {
@@ -236,12 +233,6 @@ body.has-ai-conversations-sidebar {
236233
max-height: 2.5em;
237234
}
238235

239-
.spinner {
240-
margin: 0;
241-
width: 2em;
242-
height: 2em;
243-
}
244-
245236
#ai-bot-conversations-input {
246237
width: 100%;
247238
margin: 0;

config/locales/client.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ en:
727727
new: "New Question"
728728
min_input_length_message: "Message must be longer than 10 characters"
729729
messages_sidebar_title: "Conversations"
730+
today: "Today"
730731
last_7_days: "Last 7 days"
731732
last_30_days: "Last 30 days"
732733
sentiments:

spec/system/ai_bot/homepage_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,20 @@
151151

152152
expect(ai_pm_homepage).to have_homepage
153153
expect(sidebar).to have_section("ai-conversations-history")
154-
expect(sidebar).to have_section_link("Last 7 days")
154+
expect(sidebar).to have_section_link("Today")
155155
expect(sidebar).to have_section_link(pm.title)
156156
expect(sidebar).to have_no_css("button.ai-new-question-button")
157157
end
158158

159+
it "displays last_7_days label in the sidebar" do
160+
pm.update!(last_posted_at: Time.zone.now - 5.days)
161+
visit "/"
162+
header.click_bot_button
163+
164+
expect(ai_pm_homepage).to have_homepage
165+
expect(sidebar).to have_section_link("Last 7 days")
166+
end
167+
159168
it "displays last_30_days label in the sidebar" do
160169
pm.update!(last_posted_at: Time.zone.now - 28.days)
161170
visit "/"

0 commit comments

Comments
 (0)