Skip to content

feat: show a half-year activity grid on profiles under six months old - #1657

Merged
nunomaduro merged 10 commits into
dev-null-sh:productionfrom
shanesmithdev:feat/activity-graph-intermediate-ranges
Nov 21, 2026
Merged

nunomaduro merged 10 commits into
dev-null-sh:productionfrom
shanesmithdev:feat/activity-graph-intermediate-ranges

Conversation

@shanesmithdev

@shanesmithdev shanesmithdev commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A profile's commit activity graph shows a 30-day strip until the person's first visible commit is 30 days old. After that it switches to the full 53-week year grid. For anyone between one and six months in, that grid is mostly empty weeks, with their whole history squeezed into the last few columns.

Profiles whose first visible commit is 30 days to 6 months old now get a 26-week grid instead. It's laid out like the year grid, with fewer, larger squares. The header reads "N commits in the last 6 months". Under 30 days and over 6 months are unchanged.

I first tried a 3-month grid as well as the 6-month one. The 3-month grid didn't look good next to the wider views, so I added only the 6-month option.

Changes

  • New scale: ActivityScale::Half ('half') starts at subWeeks(25)->startOfWeek(SUNDAY), giving 26 columns and mirroring Year's 52/53. since() now tries Day, Week, Month, Half, then falls back to Year, so the choice is still based on the viewer's earliest visible commit.
  • Shared grid: the year grid component becomes WeekGrid, used for both half and year. The half grid is capped at 26 × 1.5rem plus the weekday labels, so its squares can't balloon on a wide card. It has no min-w-136, so it fits phone widths without scrolling.
  • Month labels: the last column of a week grid no longer gets a month label. Before, a month starting in the current week put its label in a column too narrow for it. The label spilled past the grid, made it scroll, and clipped the weekday labels. The year grid already had this problem at some widths. The change applies to the year grid too: in a week where a month starts on a Sunday, that month's label no longer appears over the year grid's last column.
  • Empty profiles: a profile with no visible commits whose signup was over 30 days ago shows the empty half grid and "0 commits in the last 6 months", as the year grid does today.
  • API unchanged: GET /api/v1/users/{handle} still returns year for anyone past 30 days, exactly as before. Apps and TUIs read activity.scale and may not handle a new value, so Api\UserController asks UserActivityQuery to choose only from day, week and month, falling back to year. half reaches API clients in a separate follow-up PR, which drops that argument once they support it.
  • Operations page: ShowSiteActivityRequest now rejects half. The moderation bulk page was already limited to day, week and month.
  • README embed: the SVG embed (CreateUserActivityGraph) still draws the full year.

Validation

All run locally. Hosted CI hasn't run yet: GitHub is holding the tests and Lint pull request title workflows until a maintainer approves running them on a PR from a fork.

  • At 391c2f92:
    • composer test:unit: 6514/6514 passed, with 100% line coverage.
    • composer test:types, composer test:type-coverage and composer test:lint: passed.
  • At e3b1cce4 (the head), which keeps the API on year:
    • composer test:unit: Pest 6515/6515 passed, with 100% line coverage. The Node unit tests passed 331/331.
    • composer test:lint, composer test:types and composer test:type-coverage (100%): passed.
  • New and updated tests:
    • Scale selection at the 30-day and 26-week boundaries, including the signup-date fallback.
    • 26-week buckets from a Sunday through today.
    • The API still returns year (369 daily buckets) for a 2-month-old profile.
    • The query falls back to the year when half isn't among the scales offered.
    • The operations page rejects half.
    • The half-year summary text.
    • Week-grid column counts.
    • The last-week month label.

Visual evidence

Local dev server with seeded profiles, base production (90f528e) against this branch. Captured with headless Chrome, 1280px and 390px viewports, light and dark. Each image shows before on the left and after on the right.

Profile First commit Before → After
@shot-10d 10 days ago 30-day strip → unchanged
@shot-2mo ~2 months ago year grid → 26-week grid
@shot-4mo ~4 months ago year grid → 26-week grid
@shot-14mo ~14 months ago year grid → unchanged
@nunomaduro (local copy) 37 days ago year grid → 26-week grid

2 months in, 1280px, dark

Before and after, profile 2 months in, 1280px, dark

4 months in, 1280px, light

Before and after, profile 4 months in, 1280px, light

2 months in, 390px, dark

Before and after, profile 2 months in, 390px, dark

Unchanged: under 30 days and over 6 months

Before and after, profile 10 days in (unchanged), 1280px, dark

Before and after, profile 14 months in (unchanged), 1280px, dark

Real-world example (a local copy of @nunomaduro's profile, 1280px, dark)

Before and after, local copy of @nunomaduro 37 days in, 1280px, dark

Device verification

Phone width was checked only with viewport emulation (headless Chrome at 390px), not on a real device or simulator. At 390px the 26-week grid fits the card with no horizontal scroll. The change has no inputs or touch interactions. The graph is display-only, apart from the existing hover tooltips.

Independent review

Separate reviewers, not the implementer, ran read-only reviews of two revisions.

90f528e2..391c2f92 (the full net diff): the reviewer checked the captures above, plus fresh captures and DOM measurements from a running preview of the head.

  • Code: PASS, no blockers.
  • Visual: PASS, no blockers. At 390px there's no horizontal page scroll and no clipped or overlapping labels. The unchanged states (under 30 days and over 6 months) match before and after.
  • Non-blocking notes:
    • Tooltips: half-grid tooltips omit the year, so they can be ambiguous when the 26 weeks span New Year. The 30-day strip has the same ambiguity.
    • Year grid label: the last-week month label change also affects the year grid.
    • Desktop cell size: at desktop width the half grid's cells are much larger than the year grid's, so the section is taller.

391c2f92..e3b1cce4 (keeping the API on year), checked against the net diff from 90f528e2:

  • Code: PASS, no blockers. The API returns the same scale and buckets as production for every profile age, including the signup-date fallback, and never returns half. The web profile and the README embed are unchanged.
  • Visual: N/A. No frontend, page or web controller files changed, and the web profile's props are identical to the visually-passed 391c2f92.
  • Non-blocking notes:
    • Scale order: $scales must be smallest first. Only the FITTING docblock says so.
    • Test gap: no API feature test covers the signup-date fallback. That path is shared with the web profile and covered by unit tests.

Limitations

  • API clients: apps and TUIs keep showing the full year for profiles 30 days to 6 months old until the follow-up PR exposes half through /api/v1. I excluded it here because app behaviour is unknown if it's not designed to handle the half option yet, so I want to make sure app developers have time to prepare for it.
  • README embed: the SVG embed still draws the full year, no change there.

Summary by CodeRabbit

  • New Features
    • Added a half-year activity view, displayed as a 26-week grid with daily counts.
    • Activity views now select a fitting time scale based on visible activity, falling back to a yearly view when needed.
  • Bug Fixes
    • Adjusted grid labels and empty-activity summaries for half-year and yearly views.
    • API activity responses continue to use supported time scales.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The activity scale model now supports a half-year scale and configurable fitting scales. User activity queries use fitting scales by default, while the signed-in API profile requests day, week, and month scales. Site validation excludes half. The activity graph renders half-year activity in a 26-week grid.

Changes: Activity scale support

Layer / File(s) Summary
Scale selection and bucket windows
app/Enums/ActivityScale.php, app/Queries/UserActivityQuery.php, tests/Unit/Queries/UserActivityQueryTest.php
ActivityScale adds Half and configurable fitting scales. UserActivityQuery passes the available scales to selection. Half-year and year windows use whole weeks. Tests cover scale boundaries, year fallback, and half-year buckets.
API scale choices
app/Http/Controllers/Api/UserController.php, app/Http/Requests/ShowSiteActivityRequest.php, tests/Feature/Controllers/Api/UserControllerTest.php, tests/Feature/Controllers/SiteActivityControllerTest.php
The signed-in profile query requests day, week, and month scales. Site activity validation accepts day, week, month, or year. Tests cover the API’s year fallback and rejection of the half-year scale.
Half-year activity grid
resources/js/types/activity.ts, resources/js/components/activity-graph.tsx, tests/Unit/ActivityCells.test.tsx, KNOWLEDGE_BASE.md
The activity scale type includes half. The graph displays half-year activity in a 26-column, seven-row week grid. Tests cover the grid, summary text, and month labels. Documentation describes six-month display periods and the full-year public SVG.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Possibly related PRs

  • dev-null-sh/dev-null.sh#1658: Adds the half-year scale to the user profile API, building on the scale and 26-week bucket definition in this PR.

Suggested reviewers: xheaven, simonhamp

Merge Risk: Minimal · up to 1b334

This change adds a six-month activity grid for mid-age profiles on the web, while the API and the SVG embed keep their current scales. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: a new half-year (26-week) activity grid shown on profiles whose first visible commit is under six months old. The raw summary and objectives confirm this is the prima…
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 states the main change: a new half-year (26-week) activity grid shown on profiles whose first visible commit is under six months old. The raw summary and objectives confirm this is the primary change, with supporting edits to scale selection, the activity graph component, and tests. The title is specific and concise, and it uses the conventional prefix.

Finishing Touches

Generate unit tests (beta)

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

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 26acfb3b-b002-493f-b0e9-2ea0e568b468
Commits

Reviewing files that changed from the base of the PR and between e3b1cce and 1b33408.

Files selected for processing: 1

  • KNOWLEDGE_BASE.md

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

@shanesmithdev
shanesmithdev marked this pull request as ready for review November 21, 2026 04:10
@shanesmithdev

Copy link
Copy Markdown
Contributor Author

Updated KNOWLEDGE_BASE.md so @tom knows what's going on. This is still ready for review.

@nunomaduro
nunomaduro merged commit e131205 into dev-null-sh:production Nov 21, 2026
1 check passed
@shanesmithdev
shanesmithdev deleted the feat/activity-graph-intermediate-ranges branch November 21, 2026 17:02
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