Skip to content

fix(versions): group this week's versions correctly on Sundays - #4993

Open
vishalhabib99 wants to merge 1 commit into
box:masterfrom
vishalhabib99:fix/versions-menu-sunday-headings
Open

vishalhabib99 wants to merge 1 commit into
box:masterfrom
vishalhabib99:fix/versions-menu-sunday-headings

Conversation

@vishalhabib99

@vishalhabib99 vishalhabib99 commented Nov 30, 2026 •

Copy link
Copy Markdown

VersionsMenu groups versions under headings with getHeading. The existing test shows the intended weeks start on Monday: on Thursday 2019-06-20, Monday and Tuesday get weekday headings and Sunday 2019-06-16 falls under "Last Week".

On a Sunday this breaks. currentSunday is getDate() - getDay(), and getDay() is 0 on Sunday, so currentSunday becomes today. Every version from earlier in the current week then matches getDate() <= currentSunday and is labeled "Last Week". The real previous week matches <= currentSunday - 7 and is labeled "This Month". The headings jump back to the right values on Monday.

Fix

Count days since Monday ((getDay() + 6) % 7) and step back one more day to reach the Sunday that ended the previous week. Monday to Saturday give the same value as before. Only Sunday changes.

Before / after

New test: today is Sunday 2019-06-23, with versions from Sunday the 23rd back to June 1.

Before (master):

- Expected  - 2
+ Received  + 0

  Array [
    "Today",
    "Yesterday",
-   "Friday",
-   "Monday",
    "Last Week",
    "This Month",
  ]

After: Today, Yesterday, Friday, Monday, Last Week (16th and 10th), This Month (9th and 1st), which matches how a Thursday groups the same days.

Tests

  • yarn test src/elements/content-sidebar/versions/: 13 suites, 158 tests pass. The new test fails on master.
  • eslint and prettier --check pass on the changed files.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected version history’s weekly grouping on Sundays. Week headings now follow a Monday-start week, so Sunday is grouped with the week that ended that day.
  • Tests

    • Added coverage for version grouping and displayed headings when the current day is Sunday.

On Sundays, getHeading treated today as the Sunday that ends the previous
week. Versions from Monday to Friday of the current week were labeled
"Last Week", and versions from the previous week were labeled
"This Month". Count back to the previous Sunday from Monday instead.
@vishalhabib99
vishalhabib99 requested review from a team as code owners November 30, 2026 23:54
@CLAassistant

CLAassistant commented Nov 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mergify

mergify Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The version menu now treats Sunday as the end of the previous week when calculating version group headings. A test checks the resulting headings and counts for a fixed Sunday date.

Changes

Version Grouping

Layer / File(s) Summary
Week boundary and Sunday test
src/elements/content-sidebar/versions/VersionsMenu.js, src/elements/content-sidebar/versions/__tests__/VersionsMenu.test.js
getHeading uses Monday-based weekday numbering to calculate the previous Sunday. A test checks version group headings and counts for June 23, 2019.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: rafalmaksymiuk, greg-in-a-box

Merge Risk: Minimal · up to b99c9

This fixes version headings on Sundays so that current-week versions no longer appear under "Last Week". Other days of the week behave as before. The change is small, has a regression test, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (grouping this week's versions correctly on Sundays) and the affected component (versions). The raw summary and PR objectives confirm the change in VersionsMenu getHeading only…
Description check Passed The description covers the problem, the cause in the currentSunday calculation, the fix, a before/after test output, and the test and lint results. It does not use the repository template's ready-to-m…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (grouping this week's versions correctly on Sundays) and the affected component (versions). The raw summary and PR objectives confirm the change in VersionsMenu getHeading only alters Sunday behavior. The title is specific and matches the main change.

Full details: Description check

Explanation

The description covers the problem, the cause in the currentSunday calculation, the fix, a before/after test output, and the test and lint results. It does not use the repository template's ready-to-merge checklist, but that block is a reviewer guide, not required content for the author. The description is complete for the change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Biome (2.6.5)

src/elements/content-sidebar/versions/VersionsMenu.js

File contains syntax errors that prevent linting: Line 13: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 14: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 17: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 27: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 29: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 29: return type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 57: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 61: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 61: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 61: return type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the Sunday date,
And moves the week boundary back.
“Last Week” gets its versions counted,
The test confirms each heading’s track.
Then hops away, content with the change.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7b41656-166f-4f47-823a-b6181fba7747
Commits

Reviewing files that changed from the base of the PR and between bb5f976 and b99c90e.

Files selected for processing: 2

  • src/elements/content-sidebar/versions/VersionsMenu.js
  • src/elements/content-sidebar/versions/__tests__/VersionsMenu.test.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants