Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion assets/javascripts/initializers/ai-conversations-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -273,6 +285,7 @@ export default {

buildSidebarLinks() {
// Reset date header tracking
this.loadedTodayLabel = false;
this.loadedSevenDayLabel = false;
this.loadedThirtyDayLabel = false;
this.loadedMonthLabels.clear();
Expand Down
11 changes: 1 addition & 10 deletions assets/stylesheets/modules/ai-bot-conversations/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Comment on lines -37 to -39
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removing margin on the first grouping date label in the sidebar... we can just have margin on them all to keep consistency.

font-size: var(--font-down-2);
}

.sidebar-section-link {
Expand Down Expand Up @@ -236,12 +233,6 @@ body.has-ai-conversations-sidebar {
max-height: 2.5em;
}

.spinner {
margin: 0;
width: 2em;
height: 2em;
}
Comment on lines -239 to -243
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used anymore.


#ai-bot-conversations-input {
width: 100%;
margin: 0;
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion spec/system/ai_bot/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,20 @@

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 "/"
Expand Down