fix(site/src/pages/AgentsPage): rename "This Week" group to "Past 7 days" (#28504)

This commit is contained in:
david-fraley
2026-08-25 10:14:59 +03:00
committed by GitHub
parent 303935a2dc
commit 0f41ccd664
3 changed files with 16 additions and 12 deletions
@@ -740,7 +740,7 @@ export const SectionHeadersCollapse: Story = {
await expect(canvas.getByText("Pinned (2)")).toBeInTheDocument();
await expect(canvas.getByText("Today (2)")).toBeInTheDocument();
await expect(canvas.getByText("Yesterday (1)")).toBeInTheDocument();
await expect(canvas.getByText("This Week (1)")).toBeInTheDocument();
await expect(canvas.getByText("Past 7 days (1)")).toBeInTheDocument();
const pinnedToggle = canvas.getByRole("button", {
name: "Collapse Pinned section",
@@ -14,7 +14,7 @@ describe("getTimeGroup", () => {
});
it("exports the expected group labels in order", () => {
expect(TIME_GROUPS).toEqual(["Today", "Yesterday", "This Week", "Older"]);
expect(TIME_GROUPS).toEqual(["Today", "Yesterday", "Past 7 days", "Older"]);
});
it('returns "Today" for a date later today', () => {
@@ -37,19 +37,19 @@ describe("getTimeGroup", () => {
expect(getTimeGroup("2025-07-14T00:00:00.000Z")).toBe("Yesterday");
});
it('returns "This Week" for a date 2 days ago', () => {
expect(getTimeGroup("2025-07-13T12:00:00.000Z")).toBe("This Week");
it('returns "Past 7 days" for a date 2 days ago', () => {
expect(getTimeGroup("2025-07-13T12:00:00.000Z")).toBe("Past 7 days");
});
it('returns "This Week" for a date 6 days ago', () => {
expect(getTimeGroup("2025-07-09T12:00:00.000Z")).toBe("This Week");
it('returns "Past 7 days" for a date 6 days ago', () => {
expect(getTimeGroup("2025-07-09T12:00:00.000Z")).toBe("Past 7 days");
});
it('returns "This Week" for exactly 7 days ago at midnight', () => {
it('returns "Past 7 days" for exactly 7 days ago at midnight', () => {
// weekAgo = today - 7 days = 2025-07-08T00:00:00 local.
// A date at exactly that boundary should be "This Week"
// A date at exactly that boundary should be "Past 7 days"
// because the comparison is date >= weekAgo.
expect(getTimeGroup("2025-07-08T00:00:00.000Z")).toBe("This Week");
expect(getTimeGroup("2025-07-08T00:00:00.000Z")).toBe("Past 7 days");
});
it('returns "Older" for a date 8 days ago', () => {
@@ -1,11 +1,15 @@
/**
* Time-based grouping utility used by the sidebar to categorize
* chats into "Today", "Yesterday", "This Week", and "Older".
* chats into "Today", "Yesterday", "Past 7 days", and "Older".
*
* "Past 7 days" is a rolling window (today minus 7 days), not the
* current calendar week, so the label stays accurate on Mondays
* when calendar-week grouping would misfile items from last week.
*/
export const TIME_GROUPS = [
"Today",
"Yesterday",
"This Week",
"Past 7 days",
"Older",
] as const;
type TimeGroup = (typeof TIME_GROUPS)[number];
@@ -21,6 +25,6 @@ export function getTimeGroup(dateStr: string): TimeGroup {
if (date >= today) return "Today";
if (date >= yesterday) return "Yesterday";
if (date >= weekAgo) return "This Week";
if (date >= weekAgo) return "Past 7 days";
return "Older";
}