Summary
#1657 (merged) added a half-year activity scale (half, 26 weeks) for web profiles 30 days to 6 months old, and kept it out of the API. This PR adds half to the API.
This PR stays a draft until the app and TUI developers confirm they handle half.
IMPORTANT
For app and TUI developers:
GET /api/v1/users/{handle}can return"scale": "half"when the earliest commit the viewer can see (or the signup date, if there's none) is more than 30 days and up to 26 weeks old. Its buckets are daily, from a Sunday through today: 26 week columns, 176–182 buckets depending on the weekday. Drawing it likeyearworks. All other ages are unchanged.
For a profile whose first visible commit is about 2 months old:
"activity": {
- "scale": "year", // 371 daily buckets, 2025-11-16 → 2026-11-21
+ "scale": "half", // 182 daily buckets, 2026-05-24 → 2026-11-21
"buckets": [{ "date": "2026-05-24", "count": 0 }, …]
}Apps & TUI compatibility checklist
The goal is to make sure apps don't crash or show unexpected output when the API starts returning the new half scale.
- https://github.com/NativePHP/dev-null-app/pull/199
- https://github.com/WendellAdriel/dev-null-tui (doesn't accept PRs, I'll contact him about it)
- https://github.com/offskip-dave/devnull-desktop/pull/12
Changes
Api\UserController@showdrops thescales:argument #1657 added, so the API picks from the same scales as the web profile (ActivityScale::FITTING).- The API test now expects
half, with 180 buckets starting on Sunday 2026-04-19, for a profile whose first visible commit is two months old. KNOWLEDGE_BASE.md: the signed API section now says a profile's activity graph covers the same range as the web (24 hours, 7 days, 30 days, 6 months, or a year).
Validation
- Targeted, after rebasing onto
productionwith #1657 merged:tests/Feature/Controllers/Api/UserControllerTest.phpandtests/Unit/Queries/UserActivityQueryTest.php, 45/45 passed. PHPStan: no errors. - Full
composer test:unit,test:lint,test:typesandtest:type-coveragebefore the rebase: all passed. Pest 6515/6515 with 100% line coverage, Node unit tests 331/331, and 100% type coverage. - Hosted CI: waiting for a maintainer to approve workflows
- Independent review (read-only, by someone other than the implementer) of the API change: Code: PASS, no blockers. Visual: N/A, because no frontend or web files changed. Non-blocking note:
$scalesis now only passed by a unit test, and it's kept deliberately. - Limitations: apps and TUIs that don't handle
halfmay fail to draw the graph for profiles 30 days to 6 months old, hence the draft status for this PR.
I will check with the app and TUI developers that they know about this before taking the PR out of draft, because most of the apps I've seen would handle this badly right now. The checklist above shows which apps have been fixed.
Activity
3This pull request is a draft
Merging is unavailable until it is marked ready for review.
No actionable comments were generated in the recent review.
Walkthrough
Activity scale selection now includes a half-year window. The API can return that scale for activity within its range. The frontend renders half-year activity as a week grid, with updated summaries and month labels.
Changes: Half-year activity scale
app/Enums/ActivityScale.php,app/Queries/UserActivityQuery.php,app/Http/Requests/ShowSiteActivityRequest.php,tests/Feature/Controllers/Api/UserControllerTest.php,tests/Feature/Controllers/SiteActivityControllerTest.php,tests/Unit/Queries/UserActivityQueryTest.phpresources/js/types/activity.ts,resources/js/components/activity-graph.tsx,tests/Unit/ActivityCells.test.tsxEstimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Possibly related PRs
Suggested reviewers:
xheaven,jubianchiMerge Risk: Low · previous review
e1a8bThe API now returns a new "half" activity scale for profiles between 30 days and 6 months old. Any app or TUI client that does not recognise it may fail to draw the activity graph for those profiles. Confirm client support before merging; the web profile is already handled.
Pre-merge checks: 4
Full details: Title check
Explanation
The title "feat: add the half-year activity scale to the API" matches the main change. The diff adds the Half case to ActivityScale, extends the query and the API profile response so profiles 30 days to 26 weeks old return the half scale, and adds the matching tests. The title names the feature and the surface it touches, so it describes the primary change without listing files.
Finishing Touches
Generate unit tests (beta)
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
6ee8c048-8ca1-4fde-bc9e-04cff218a56eReviewing files that changed from the base of the PR and between 90f528e2143885ab36e93bbb26e755d1f3648d44 and e1a8b0d98741d95f186fbd2dbd378c18d5f1921f.
app/Enums/ActivityScale.phpapp/Http/Requests/ShowSiteActivityRequest.phpapp/Queries/UserActivityQuery.phpresources/js/components/activity-graph.tsxresources/js/types/activity.tstests/Feature/Controllers/Api/UserControllerTest.phptests/Feature/Controllers/SiteActivityControllerTest.phptests/Unit/ActivityCells.test.tsxtests/Unit/Queries/UserActivityQueryTest.phpIncluded review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.