From befd3ff3847866fc5d15cceac82bcc0969e0868d Mon Sep 17 00:00:00 2001 From: PacketByte Date: Wed, 11 Nov 2026 22:05:13 -0200 Subject: [PATCH 01/14] feat: wrap the year in review for every profile Public story pages at @handle/wrapped with commits, stars, streaks and growth, GitHub-styled card with brand orange accents and confetti on the finale. --- .../Controllers/YearInReviewController.php | 38 +++ app/Queries/YearInReviewQuery.php | 84 +++++ resources/js/pages/wrapped/show.tsx | 300 ++++++++++++++++++ routes/web.php | 3 + .../YearInReviewControllerTest.php | 37 +++ 5 files changed, 462 insertions(+) create mode 100644 app/Http/Controllers/YearInReviewController.php create mode 100644 app/Queries/YearInReviewQuery.php create mode 100644 resources/js/pages/wrapped/show.tsx create mode 100644 tests/Feature/Controllers/YearInReviewControllerTest.php diff --git a/app/Http/Controllers/YearInReviewController.php b/app/Http/Controllers/YearInReviewController.php new file mode 100644 index 0000000000..81d6a71a21 --- /dev/null +++ b/app/Http/Controllers/YearInReviewController.php @@ -0,0 +1,38 @@ +user; + $year = (int) now()->year; + + abort_unless($user instanceof User, 404); + + $stats = $review->get($user, $currentUser, $year); + + return Inertia::render('wrapped/show', [ + 'handle' => $profile->handle, + 'name' => $user->name, + 'avatarUrl' => $user->avatar_url, + 'stats' => $stats, + 'shareUrl' => route('wrapped.show', ['profile' => $profile->handle]), + ])->withViewData(['preview' => $metadata->page( + "{$profile->handle}'s {$year} in review - /dev/null", + "What @{$profile->handle} shipped in {$year}: {$stats['commits']} commits, {$stats['starsEarned']} stars and a {$stats['longestStreak']}-day streak.", + route('wrapped.show', ['profile' => $profile->handle]), + )]); + } +} diff --git a/app/Queries/YearInReviewQuery.php b/app/Queries/YearInReviewQuery.php new file mode 100644 index 0000000000..b7f50b87e4 --- /dev/null +++ b/app/Queries/YearInReviewQuery.php @@ -0,0 +1,84 @@ +, topCommit: array{id: string, body: string, stars: int}|null} + */ +final readonly class YearInReviewQuery +{ + /** + * @return YearInReview + */ + public function get(User $user, ?User $viewer, int $year): array + { + $start = CarbonImmutable::create($year, 1, 1)->startOfDay(); + $end = $start->endOfYear(); + + $commits = $user->commits()->visibleTo($viewer)->whereBetween('commits.created_at', [$start, $end]); + + $starsEarned = (int) DB::table('stars') + ->join('commits', 'commits.id', '=', 'stars.commit_id') + ->where('commits.user_id', $user->id) + ->whereBetween('stars.created_at', [$start, $end]) + ->count(); + + $top = (clone $commits)->withCount('stars')->orderByDesc('stars_count')->orderBy('commits.created_at')->first(); + + /** @var list $days */ + $days = (clone $commits) + ->selectRaw('date(commits.created_at) as day') + ->distinct() + ->orderBy('day') + ->pluck('day') + ->all(); + + $months = array_fill(0, 12, 0); + + foreach ((clone $commits)->selectRaw('extract(month from commits.created_at) as month, count(*) as total')->groupBy('month')->pluck('total', 'month') as $month => $total) { + $months[(int) $month - 1] = (int) $total; + } + + return [ + 'year' => $year, + 'commits' => (clone $commits)->whereNull('commits.parent_id')->count(), + 'replies' => (clone $commits)->whereNotNull('commits.parent_id')->count(), + 'starsEarned' => $starsEarned, + 'followersGained' => $user->followers()->wherePivot('follows.created_at', '>=', $start)->wherePivot('follows.created_at', '<=', $end)->count(), + 'activeDays' => count($days), + 'longestStreak' => $this->longestRun($days), + 'months' => $months, + 'topCommit' => $top === null ? null : [ + 'id' => $top->id, + 'body' => mb_strimwidth($top->body, 0, 140, '…'), + 'stars' => (int) $top->stars_count, + ], + ]; + } + + /** + * @param list $days Ordered Y-m-d dates with at least one commit. + */ + private function longestRun(array $days): int + { + $longest = 0; + $run = 0; + $previous = null; + + foreach ($days as $day) { + $run = $previous !== null && CarbonImmutable::parse($day)->diffInDays($previous) === 1 ? $run + 1 : 1; + $longest = max($longest, $run); + $previous = CarbonImmutable::parse($day); + } + + return $longest; + } +} diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx new file mode 100644 index 0000000000..15e3d57593 --- /dev/null +++ b/resources/js/pages/wrapped/show.tsx @@ -0,0 +1,300 @@ +import { Head } from '@inertiajs/react'; +import { + useCallback, + useEffect, + useRef, + useState, + type ReactNode, +} from 'react'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { Button } from '@/components/ui/button'; +import { useClipboard } from '@/hooks/use-clipboard'; +import AppLayout from '@/layouts/app-layout'; +import { dropConfetti } from '@/lib/confetti'; + +type WrappedStats = { + year: number; + commits: number; + replies: number; + starsEarned: number; + followersGained: number; + activeDays: number; + longestStreak: number; + months: number[]; + topCommit: { id: string; body: string; stars: number } | null; +}; + +type WrappedProps = { + handle: string; + name: string; + avatarUrl: string | null; + stats: WrappedStats; + shareUrl: string; +}; + +function BigNumber({ value, label }: { value: number; label: string }) { + return ( +
+

+ {value.toLocaleString()} +

+

{label}

+
+ ); +} + +function MonthBars({ months }: { months: number[] }) { + const peak = Math.max(1, ...months); + const level = (total: number): number => + total === 0 ? 0 : 1 + Math.min(3, Math.floor((total / peak) * 4)); + + return ( +
+ {months.map((total, index) => ( +
+ ))} +
+ ); +} + +function Eyebrow({ children }: { children: ReactNode }) { + return ( +

+ {children} +

+ ); +} + +export default function Show({ + handle, + name, + avatarUrl, + stats, + shareUrl, +}: WrappedProps) { + const [slide, setSlide] = useState(0); + const [copied, copy] = useClipboard(); + const celebrated = useRef(false); + + const last = 5; + const go = useCallback( + (next: number) => setSlide(Math.min(last, Math.max(0, next))), + [last], + ); + + useEffect(() => { + if (slide === last && !celebrated.current) { + celebrated.current = true; + dropConfetti(); + } + }, [slide, last]); + + useEffect(() => { + const onKey = (event: KeyboardEvent): void => { + if (event.key === 'ArrowRight') { + go(slide + 1); + } else if (event.key === 'ArrowLeft') { + go(slide - 1); + } + }; + + window.addEventListener('keydown', onKey); + + return () => window.removeEventListener('keydown', onKey); + }, [slide, go]); + + return ( + <> + +
+
+
+
+ +
+ {slide === 0 && ( +
+ + {stats.commits.toLocaleString()} contributions + in {stats.year} + + + + + {handle.slice(0, 2).toUpperCase()} + + +

+ @{handle} +

+

+ {stats.year} in review +

+

+ {stats.commits === 0 + ? 'A quiet year. Next one ships more.' + : `${stats.commits.toLocaleString()} commits shipped. Here is how they landed.`} +

+
+ )} + {slide === 1 && ( +
+ 01 · Output +
+ +
+

+ plus {stats.replies.toLocaleString()} replies in + other people's threads +

+ +
+ )} + {slide === 2 && ( +
+ 02 · Impact +
+ +
+ {stats.topCommit !== null && ( +
+
+ {stats.topCommit.body} +
+
+ Your top commit ·{' '} + {stats.topCommit.stars.toLocaleString()}{' '} + stars +
+
+ )} +
+ )} + {slide === 3 && ( +
+ 03 · Consistency +
+ +
+

+ active on {stats.activeDays.toLocaleString()}{' '} + days this year +

+
+ )} + {slide === 4 && ( +
+ 04 · Community +
+ +
+

+ people who want to read what you ship next +

+
+ )} + {slide === 5 && ( +
+ 05 · Share +

+ Take it with you +

+

+ This page is public. Send it anywhere. +

+

+ {shareUrl} +

+ +
+ )} +
+ +
+ {slide > 0 ? ( + + ) : ( +
+
+ + ); +} + +Show.layout = AppLayout; diff --git a/routes/web.php b/routes/web.php index 13b13548d1..b16e950aef 100644 --- a/routes/web.php +++ b/routes/web.php @@ -157,6 +157,7 @@ use App\Http\Controllers\UserTimeoutController; use App\Http\Controllers\UserTimezoneController; use App\Http\Controllers\UserTranslationLanguageController; +use App\Http\Controllers\YearInReviewController; use App\Http\Middleware\PreventPostingInTimeout; use App\Http\Middleware\RedirectToHandleCase; use App\Http\Middleware\RememberIntendedUrl; @@ -307,6 +308,8 @@ ->name('user-preview.show'); Route::get('@{profile:handle}/og.png', [ProfileOpenGraphImageController::class, 'show']) ->name('user-open-graph-image.show'); +Route::get('@{profile:handle}/wrapped', [YearInReviewController::class, 'show']) + ->name('wrapped.show'); Route::get('@{user:handle}/feed.atom', [UserFeedController::class, 'show']) ->middleware('cache.headers:public;max_age=300;etag') ->name('user-feed.show'); diff --git a/tests/Feature/Controllers/YearInReviewControllerTest.php b/tests/Feature/Controllers/YearInReviewControllerTest.php new file mode 100644 index 0000000000..e91c2c8a7c --- /dev/null +++ b/tests/Feature/Controllers/YearInReviewControllerTest.php @@ -0,0 +1,37 @@ +create(); + $year = (int) now()->year; + + $top = Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 3, 10)]); + $top->stars()->attach(User::factory()->count(2)->create(), ['created_at' => now()->setDate($year, 4, 1)]); + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 5, 20)]); + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year - 1, 6, 15)]); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->component('wrapped/show') + ->where('handle', $user->profile->handle) + ->where('stats.year', $year) + ->where('stats.commits', 2) + ->where('stats.starsEarned', 2) + ->where('stats.topCommit.stars', 2) + ->where('stats.months.2', 1) + ->where('stats.months.4', 1)); +}); + +it('describes the review to search engines and link previews', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertSee("{$user->profile->handle}'s {$year} in review - /dev/null", false); +}); From 2888ee7b616ed1e78db5989b7f68cb1a10f89359 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Wed, 11 Nov 2026 23:49:05 -0200 Subject: [PATCH 02/14] feat: monthly breakdown, heatmap, archetype and share summary for wrapped --- app/Queries/YearInReviewQuery.php | 23 ++- resources/js/pages/wrapped/show.tsx | 282 +++++++++++++++++++++++++--- 2 files changed, 273 insertions(+), 32 deletions(-) diff --git a/app/Queries/YearInReviewQuery.php b/app/Queries/YearInReviewQuery.php index b7f50b87e4..103bf43d3d 100644 --- a/app/Queries/YearInReviewQuery.php +++ b/app/Queries/YearInReviewQuery.php @@ -11,7 +11,7 @@ /** * A profile's year in numbers: posts, stars, streaks and community growth. * - * @phpstan-type YearInReview array{year: int, commits: int, replies: int, starsEarned: int, followersGained: int, activeDays: int, longestStreak: int, months: list, topCommit: array{id: string, body: string, stars: int}|null} + * @phpstan-type YearInReview array{year: int, commits: int, replies: int, starsEarned: int, followersGained: int, activeDays: int, longestStreak: int, months: list, weekdays: list, dayCounts: array, topCommit: array{id: string, body: string, stars: int}|null} */ final readonly class YearInReviewQuery { @@ -33,20 +33,29 @@ public function get(User $user, ?User $viewer, int $year): array $top = (clone $commits)->withCount('stars')->orderByDesc('stars_count')->orderBy('commits.created_at')->first(); - /** @var list $days */ - $days = (clone $commits) - ->selectRaw('date(commits.created_at) as day') - ->distinct() + /** @var array $dayCounts */ + $dayCounts = (clone $commits) + ->selectRaw('date(commits.created_at) as day, count(*) as total') + ->groupBy('day') ->orderBy('day') - ->pluck('day') + ->pluck('total', 'day') + ->map(fn ($total) => (int) $total) ->all(); + $days = array_keys($dayCounts); + $months = array_fill(0, 12, 0); foreach ((clone $commits)->selectRaw('extract(month from commits.created_at) as month, count(*) as total')->groupBy('month')->pluck('total', 'month') as $month => $total) { $months[(int) $month - 1] = (int) $total; } + $weekdays = array_fill(0, 7, 0); + + foreach ((clone $commits)->selectRaw('extract(dow from commits.created_at) as dow, count(*) as total')->groupBy('dow')->pluck('total', 'dow') as $dow => $total) { + $weekdays[(int) $dow] = (int) $total; + } + return [ 'year' => $year, 'commits' => (clone $commits)->whereNull('commits.parent_id')->count(), @@ -56,6 +65,8 @@ public function get(User $user, ?User $viewer, int $year): array 'activeDays' => count($days), 'longestStreak' => $this->longestRun($days), 'months' => $months, + 'weekdays' => $weekdays, + 'dayCounts' => $dayCounts, 'topCommit' => $top === null ? null : [ 'id' => $top->id, 'body' => mb_strimwidth($top->body, 0, 140, '…'), diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 15e3d57593..3d39f789a9 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -21,6 +21,8 @@ type WrappedStats = { activeDays: number; longestStreak: number; months: number[]; + weekdays: number[]; + dayCounts: Record; topCommit: { id: string; body: string; stars: number } | null; }; @@ -81,6 +83,144 @@ function Eyebrow({ children }: { children: ReactNode }) { ); } +const MONTHS = [ + 'Jan', + 'Feb', + 'Mar', + 'Apr', + 'May', + 'Jun', + 'Jul', + 'Aug', + 'Sep', + 'Oct', + 'Nov', + 'Dec', +]; + +function archetype(stats: WrappedStats): { name: string; quip: string } { + if (stats.commits === 0) { + return { + name: 'Ghost in the Machine', + quip: 'Present in spirit. The commits will come.', + }; + } + if (stats.longestStreak >= 30) { + return { + name: 'Streak Machine', + quip: 'A month straight of shipping without blinking.', + }; + } + if (stats.starsEarned >= 100) { + return { + name: 'Star Magnet', + quip: 'People keep starring whatever you touch.', + }; + } + if (stats.replies > stats.commits) { + return { + name: 'Conversation Starter', + quip: 'Your best work happens in other people\u2019s threads.', + }; + } + if (stats.followersGained >= 25) { + return { + name: 'Rising Star', + quip: 'The follower graph noticed before you did.', + }; + } + if (stats.commits >= 100) { + return { + name: 'Ship-it Machine', + quip: 'Triple digits. Rest, then keep shipping.', + }; + } + return { + name: 'Steady Builder', + quip: 'Brick by brick. That is how codebases get built.', + }; +} + +function buildInsights(stats: WrappedStats): string[] { + const total = stats.months.reduce((sum, count) => sum + count, 0); + + if (total === 0) { + return ['No commits this year. The graph is a blank canvas.']; + } + + const best = stats.months.indexOf(Math.max(...stats.months)); + const weekend = (stats.weekdays[0] ?? 0) + (stats.weekdays[6] ?? 0); + + return [ + `Most productive month: ${MONTHS[best]} with ${stats.months[best]} commits.`, + weekend / total >= 0.4 + ? 'Weekend warrior: nearly half your commits land on Sat/Sun.' + : 'Weekday grinder: evenings and weekends stay yours.', + stats.replies > stats.commits + ? 'You reply more than you post. Threads love you.' + : 'You post more than you reply. A builder first.', + ]; +} + +function YearHeatmap({ + year, + dayCounts, +}: { + year: number; + dayCounts: Record; +}) { + const peak = Math.max(1, ...Object.values(dayCounts)); + + return ( +
+
+ {MONTHS.map((label, month) => { + const total = new Date(year, month + 1, 0).getDate(); + return ( +
+ + {label} + +
+ {Array.from({ length: total }, (_, day) => { + const key = `${year}-${String(month + 1).padStart(2, '0')}-${String(day + 1).padStart(2, '0')}`; + const count = dayCounts[key] ?? 0; + return ( + + ); + })} +
+
+ ); + })} +
+
+ ); +} + export default function Show({ handle, name, @@ -89,10 +229,16 @@ export default function Show({ shareUrl, }: WrappedProps) { const [slide, setSlide] = useState(0); - const [copied, copy] = useClipboard(); + const [copiedLink, copyLink] = useClipboard(); + const [copiedSummary, copySummary] = useClipboard(); const celebrated = useRef(false); - const last = 5; + const last = 6; + const hasCommits = stats.commits > 0; + const bestMonth = stats.months.indexOf(Math.max(...stats.months)); + const craft = archetype(stats); + const insightList = buildInsights(stats); + const summary = `My ${stats.year} on /dev/null - @${handle}: ${stats.commits} commits, ${stats.starsEarned} stars, best streak ${stats.longestStreak} days. ${shareUrl}`; const go = useCallback( (next: number) => setSlide(Math.min(last, Math.max(0, next))), [last], @@ -140,7 +286,7 @@ export default function Show({
{slide === 0 && ( @@ -185,6 +331,40 @@ export default function Show({ other people's threads

+ {hasCommits && ( + <> +

+ Best month: {MONTHS[bestMonth]} with{' '} + {stats.months[bestMonth]} commits +

+
+ {stats.months.map((total, index) => ( +
+

+ {MONTHS[index]} +

+

+ {total} +

+
+ ))} +
+ + )}
)} {slide === 2 && ( @@ -223,6 +403,10 @@ export default function Show({ active on {stats.activeDays.toLocaleString()}{' '} days this year

+
)} {slide === 4 && ( @@ -241,7 +425,28 @@ export default function Show({ )} {slide === 5 && (
- 05 · Share + 05 · Archetype +

+ {craft.name} +

+

+ {craft.quip} +

+
    + {insightList.map((insight) => ( +
  • + {insight} +
  • + ))} +
+
+ )} + {slide === 6 && ( +
+ 06 · Share

Take it with you

@@ -251,25 +456,39 @@ export default function Show({

{shareUrl}

- +

+ {summary} +

+
+ + +
)} -
- {slide > 0 ? ( - - ) : ( -
); From 480d5b75397b79f49e9783af257d5da57bdcc3fc Mon Sep 17 00:00:00 2001 From: PacketByte Date: Thu, 12 Nov 2026 05:01:43 -0200 Subject: [PATCH 03/14] feat: fireworks finale and team sign-off for wrapped --- resources/js/lib/confetti.ts | 122 ++++++++++++++++++++++++++++ resources/js/pages/wrapped/show.tsx | 18 ++-- 2 files changed, 135 insertions(+), 5 deletions(-) diff --git a/resources/js/lib/confetti.ts b/resources/js/lib/confetti.ts index 55fd049b94..dfa669bcd6 100644 --- a/resources/js/lib/confetti.ts +++ b/resources/js/lib/confetti.ts @@ -135,3 +135,125 @@ export function dropConfetti(): void { frame = window.requestAnimationFrame(tick); } } + +type Spark = { + x: number; + y: number; + vx: number; + vy: number; + color: string; + life: number; + maxLife: number; +}; + +export function dropFireworks(): void { + if (typeof document === 'undefined') return; + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; + + const show = document.createElement('canvas'); + show.setAttribute('aria-hidden', 'true'); + show.style.position = 'fixed'; + show.style.inset = '0'; + show.style.width = '100%'; + show.style.height = '100%'; + show.style.pointerEvents = 'none'; + show.style.zIndex = '60'; + document.body.appendChild(show); + + const ctx = show.getContext('2d'); + if (!ctx) { + show.remove(); + return; + } + + const ratio = Math.min(window.devicePixelRatio || 1, 2); + show.width = Math.floor(window.innerWidth * ratio); + show.height = Math.floor(window.innerHeight * ratio); + ctx.setTransform(ratio, 0, 0, ratio, 0, 0); + + const width = window.innerWidth; + const height = window.innerHeight; + const rockets: Spark[] = []; + const sparks: Spark[] = []; + let frames = 0; + + const launch = (): void => { + rockets.push({ + x: width * (0.08 + Math.random() * 0.84), + y: height + 8, + vx: (Math.random() - 0.5) * 1.5, + vy: -(height / 90 + Math.random() * 2), + color: '#ffd166', + life: 0, + maxLife: 1000, + }); + }; + + launch(); + window.setTimeout(launch, 300); + window.setTimeout(launch, 600); + window.setTimeout(launch, 900); + + const explode = (rocket: Spark): void => { + const count = 46 + Math.floor(Math.random() * 20); + for (let index = 0; index < count; index++) { + const angle = (index / count) * Math.PI * 2 + Math.random() * 0.3; + const speed = 1.4 + Math.random() * 3.6; + sparks.push({ + x: rocket.x, + y: rocket.y, + vx: Math.cos(angle) * speed, + vy: Math.sin(angle) * speed, + color: colors[Math.floor(Math.random() * colors.length)], + life: 0, + maxLife: 55 + Math.floor(Math.random() * 30), + }); + } + }; + + const step = (): void => { + frames += 1; + ctx.clearRect(0, 0, width, height); + + for (let index = rockets.length - 1; index >= 0; index--) { + const rocket = rockets[index]; + rocket.vy += 0.12; + rocket.x += rocket.vx; + rocket.y += rocket.vy; + ctx.fillStyle = rocket.color; + ctx.beginPath(); + ctx.arc(rocket.x, rocket.y, 2, 0, Math.PI * 2); + ctx.fill(); + if (rocket.vy >= -2.2) { + explode(rocket); + rockets.splice(index, 1); + } + } + + for (let index = sparks.length - 1; index >= 0; index--) { + const spark = sparks[index]; + spark.life += 1; + spark.vx *= 0.985; + spark.vy = spark.vy * 0.985 + 0.05; + spark.x += spark.vx; + spark.y += spark.vy; + ctx.globalAlpha = Math.max(0, 1 - spark.life / spark.maxLife); + ctx.fillStyle = spark.color; + ctx.beginPath(); + ctx.arc(spark.x, spark.y, 1.6, 0, Math.PI * 2); + ctx.fill(); + ctx.globalAlpha = 1; + if (spark.life >= spark.maxLife) { + sparks.splice(index, 1); + } + } + + if (rockets.length > 0 || sparks.length > 0 || frames < 280) { + window.requestAnimationFrame(step); + } else { + show.remove(); + } + }; + + window.requestAnimationFrame(step); +} diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 3d39f789a9..3194b5cf25 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -6,11 +6,12 @@ import { useState, type ReactNode, } from 'react'; +import AppLogo from '@/components/app-logo'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Button } from '@/components/ui/button'; import { useClipboard } from '@/hooks/use-clipboard'; import AppLayout from '@/layouts/app-layout'; -import { dropConfetti } from '@/lib/confetti'; +import { dropFireworks } from '@/lib/confetti'; type WrappedStats = { year: number; @@ -247,7 +248,7 @@ export default function Show({ useEffect(() => { if (slide === last && !celebrated.current) { celebrated.current = true; - dropConfetti(); + dropFireworks(); } }, [slide, last]); @@ -446,11 +447,18 @@ export default function Show({ )} {slide === 6 && (
- 06 · Share -

- Take it with you + 06 · Happy New Year +
+ +
+

+ See you next year, nuller

+ Thank you, nullers, for every commit, reply, and + star this year. From the team, happy New Year. +

+

This page is public. Send it anywhere.

From 8702458c9551b1e244347e82be2d47a677ac6b16 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Thu, 12 Nov 2026 06:41:47 -0200 Subject: [PATCH 04/14] feat: github-themed archetypes with night, weekend and comeback detection --- app/Queries/YearInReviewQuery.php | 41 ++++++- resources/js/pages/wrapped/show.tsx | 110 +++++++++++++++--- .../YearInReviewControllerTest.php | 4 +- 3 files changed, 134 insertions(+), 21 deletions(-) diff --git a/app/Queries/YearInReviewQuery.php b/app/Queries/YearInReviewQuery.php index 103bf43d3d..afc54a67a0 100644 --- a/app/Queries/YearInReviewQuery.php +++ b/app/Queries/YearInReviewQuery.php @@ -11,7 +11,7 @@ /** * A profile's year in numbers: posts, stars, streaks and community growth. * - * @phpstan-type YearInReview array{year: int, commits: int, replies: int, starsEarned: int, followersGained: int, activeDays: int, longestStreak: int, months: list, weekdays: list, dayCounts: array, topCommit: array{id: string, body: string, stars: int}|null} + * @phpstan-type YearInReview array{year: int, commits: int, replies: int, starsEarned: int, followersGained: int, activeDays: int, longestStreak: int, months: list, weekdays: list, hourCounts: list, comeback: bool, dayCounts: array, topCommit: array{id: string, body: string, stars: int}|null} */ final readonly class YearInReviewQuery { @@ -56,6 +56,12 @@ public function get(User $user, ?User $viewer, int $year): array $weekdays[(int) $dow] = (int) $total; } + $hourCounts = array_fill(0, 24, 0); + + foreach ((clone $commits)->selectRaw('extract(hour from commits.created_at) as hour, count(*) as total')->groupBy('hour')->pluck('total', 'hour') as $hour => $total) { + $hourCounts[(int) $hour] = (int) $total; + } + return [ 'year' => $year, 'commits' => (clone $commits)->whereNull('commits.parent_id')->count(), @@ -66,6 +72,8 @@ public function get(User $user, ?User $viewer, int $year): array 'longestStreak' => $this->longestRun($days), 'months' => $months, 'weekdays' => $weekdays, + 'hourCounts' => $hourCounts, + 'comeback' => $this->hasComeback($days), 'dayCounts' => $dayCounts, 'topCommit' => $top === null ? null : [ 'id' => $top->id, @@ -75,6 +83,37 @@ public function get(User $user, ?User $viewer, int $year): array ]; } + /** + * A 7-plus day streak that starts after a 30-plus day silence. + * + * @param list $days Ordered Y-m-d dates with at least one commit. + */ + private function hasComeback(array $days): bool + { + $run = 0; + $gap = 0; + $previous = null; + + foreach ($days as $day) { + $current = CarbonImmutable::parse($day); + + if ($previous !== null && $current->diffInDays($previous) === 1) { + $run++; + } else { + $gap = $previous === null ? 0 : $current->diffInDays($previous); + $run = 1; + } + + if ($run >= 7 && $gap >= 30) { + return true; + } + + $previous = $current; + } + + return false; + } + /** * @param list $days Ordered Y-m-d dates with at least one commit. */ diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 3194b5cf25..9b083b55d8 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -23,6 +23,8 @@ type WrappedStats = { longestStreak: number; months: number[]; weekdays: number[]; + hourCounts: number[]; + comeback: boolean; dayCounts: Record; topCommit: { id: string; body: string; stars: number } | null; }; @@ -102,40 +104,89 @@ const MONTHS = [ function archetype(stats: WrappedStats): { name: string; quip: string } { if (stats.commits === 0) { return { - name: 'Ghost in the Machine', - quip: 'Present in spirit. The commits will come.', + name: 'The Ghost', + quip: 'You were here. Git remembers.', }; } - if (stats.longestStreak >= 30) { + + const total = stats.commits + stats.replies; + const night = + (stats.hourCounts[22] ?? 0) + + (stats.hourCounts[23] ?? 0) + + stats.hourCounts.slice(0, 6).reduce((sum, count) => sum + count, 0); + + if (night / total >= 0.4) { + return { + name: 'Night Owl', + quip: 'Your best ideas apparently do not believe in business hours.', + }; + } + + const weekend = (stats.weekdays[0] ?? 0) + (stats.weekdays[6] ?? 0); + + if (weekend / total >= 0.45) { + return { + name: 'Weekend Warrior', + quip: 'While everyone else logged off, you logged commits.', + }; + } + + if (stats.comeback) { + return { + name: 'The Comeback Kid', + quip: 'Quiet periods are just intermissions.', + }; + } + + if (stats.starsEarned >= 100 || stats.followersGained >= 25) { + return { + name: 'Main Character Energy', + quip: 'Somehow, your repositories are the plot.', + }; + } + + if (stats.replies > stats.commits && stats.replies >= 5) { return { - name: 'Streak Machine', - quip: 'A month straight of shipping without blinking.', + name: 'Merge Overlord', + quip: 'Nothing gets merged without your blessing.', }; } - if (stats.starsEarned >= 100) { + + if (stats.activeDays >= 200) { return { - name: 'Star Magnet', - quip: 'People keep starring whatever you touch.', + name: 'The Green Square Addict', + quip: 'Those contribution squares are not going to fill themselves.', }; } - if (stats.replies > stats.commits) { + + if (stats.longestStreak >= 14) { return { - name: 'Conversation Starter', - quip: 'Your best work happens in other people\u2019s threads.', + name: 'One More Commit', + quip: 'You said that three hours ago.', }; } - if (stats.followersGained >= 25) { + + if (stats.activeDays >= 100) { return { - name: 'Rising Star', - quip: 'The follower graph noticed before you did.', + name: 'The Infinite Loop', + quip: 'Start coding. Forget time. Repeat.', }; } + if (stats.commits >= 100) { return { - name: 'Ship-it Machine', - quip: 'Triple digits. Rest, then keep shipping.', + name: '404: Free Time Not Found', + quip: 'Your calendar has been replaced by commits.', }; } + + if (stats.replies <= 2) { + return { + name: 'The Silent Shipper', + quip: 'No noise. Just output.', + }; + } + return { name: 'Steady Builder', quip: 'Brick by brick. That is how codebases get built.', @@ -143,7 +194,7 @@ function archetype(stats: WrappedStats): { name: string; quip: string } { } function buildInsights(stats: WrappedStats): string[] { - const total = stats.months.reduce((sum, count) => sum + count, 0); + const total = stats.commits + stats.replies; if (total === 0) { return ['No commits this year. The graph is a blank canvas.']; @@ -151,16 +202,37 @@ function buildInsights(stats: WrappedStats): string[] { const best = stats.months.indexOf(Math.max(...stats.months)); const weekend = (stats.weekdays[0] ?? 0) + (stats.weekdays[6] ?? 0); + const night = + (stats.hourCounts[22] ?? 0) + + (stats.hourCounts[23] ?? 0) + + stats.hourCounts.slice(0, 6).reduce((sum, count) => sum + count, 0); - return [ + const insights = [ `Most productive month: ${MONTHS[best]} with ${stats.months[best]} commits.`, weekend / total >= 0.4 ? 'Weekend warrior: nearly half your commits land on Sat/Sun.' : 'Weekday grinder: evenings and weekends stay yours.', + ]; + + if (night / total >= 0.25) { + insights.push( + `Night shift: ${Math.round((night / total) * 100)} percent of commits landed between 10pm and 6am.`, + ); + } + + if (stats.comeback) { + insights.push( + 'Comeback season: a 7-plus day streak after a month away.', + ); + } + + insights.push( stats.replies > stats.commits ? 'You reply more than you post. Threads love you.' : 'You post more than you reply. A builder first.', - ]; + ); + + return insights; } function YearHeatmap({ diff --git a/tests/Feature/Controllers/YearInReviewControllerTest.php b/tests/Feature/Controllers/YearInReviewControllerTest.php index e91c2c8a7c..90b22d41f0 100644 --- a/tests/Feature/Controllers/YearInReviewControllerTest.php +++ b/tests/Feature/Controllers/YearInReviewControllerTest.php @@ -24,7 +24,9 @@ ->where('stats.starsEarned', 2) ->where('stats.topCommit.stars', 2) ->where('stats.months.2', 1) - ->where('stats.months.4', 1)); + ->where('stats.months.4', 1) + ->where('stats.comeback', false) + ->has('stats.hourCounts', 24)); }); it('describes the review to search engines and link previews', function (): void { From 9571a3b91096c22836816527fc2431cb055d6091 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Thu, 12 Nov 2026 07:18:17 -0200 Subject: [PATCH 05/14] feat: top-level counts everywhere, top commit link, zero-state copy for wrapped --- app/Queries/YearInReviewQuery.php | 8 +++---- resources/js/pages/wrapped/show.tsx | 35 ++++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/app/Queries/YearInReviewQuery.php b/app/Queries/YearInReviewQuery.php index afc54a67a0..83f1e1d8ec 100644 --- a/app/Queries/YearInReviewQuery.php +++ b/app/Queries/YearInReviewQuery.php @@ -34,7 +34,7 @@ public function get(User $user, ?User $viewer, int $year): array $top = (clone $commits)->withCount('stars')->orderByDesc('stars_count')->orderBy('commits.created_at')->first(); /** @var array $dayCounts */ - $dayCounts = (clone $commits) + $dayCounts = (clone $commits)->whereNull('commits.parent_id') ->selectRaw('date(commits.created_at) as day, count(*) as total') ->groupBy('day') ->orderBy('day') @@ -46,19 +46,19 @@ public function get(User $user, ?User $viewer, int $year): array $months = array_fill(0, 12, 0); - foreach ((clone $commits)->selectRaw('extract(month from commits.created_at) as month, count(*) as total')->groupBy('month')->pluck('total', 'month') as $month => $total) { + foreach ((clone $commits)->whereNull('commits.parent_id')->selectRaw('extract(month from commits.created_at) as month, count(*) as total')->groupBy('month')->pluck('total', 'month') as $month => $total) { $months[(int) $month - 1] = (int) $total; } $weekdays = array_fill(0, 7, 0); - foreach ((clone $commits)->selectRaw('extract(dow from commits.created_at) as dow, count(*) as total')->groupBy('dow')->pluck('total', 'dow') as $dow => $total) { + foreach ((clone $commits)->whereNull('commits.parent_id')->selectRaw('extract(dow from commits.created_at) as dow, count(*) as total')->groupBy('dow')->pluck('total', 'dow') as $dow => $total) { $weekdays[(int) $dow] = (int) $total; } $hourCounts = array_fill(0, 24, 0); - foreach ((clone $commits)->selectRaw('extract(hour from commits.created_at) as hour, count(*) as total')->groupBy('hour')->pluck('total', 'hour') as $hour => $total) { + foreach ((clone $commits)->whereNull('commits.parent_id')->selectRaw('extract(hour from commits.created_at) as hour, count(*) as total')->groupBy('hour')->pluck('total', 'hour') as $hour => $total) { $hourCounts[(int) $hour] = (int) $total; } diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 9b083b55d8..13beb734b7 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -399,10 +399,12 @@ export default function Show({ label="commits shipped" />

-

- plus {stats.replies.toLocaleString()} replies in - other people's threads -

+ {stats.replies > 0 && ( +

+ plus {stats.replies.toLocaleString()}{' '} + replies in threads +

+ )} {hasCommits && ( <> @@ -449,17 +451,25 @@ export default function Show({ label="stars earned" /> + {stats.starsEarned === 0 && ( +

+ No stars yet. The work still counted. +

+ )} {stats.topCommit !== null && ( -
+
{stats.topCommit.body}
-
+

Your top commit ·{' '} {stats.topCommit.stars.toLocaleString()}{' '} stars -

-
+

+
)} )} @@ -469,7 +479,7 @@ export default function Show({

@@ -492,7 +502,9 @@ export default function Show({ />

- people who want to read what you ship next + {stats.followersGained === 0 + ? 'Quiet on the follower front. The work comes first.' + : 'people who want to read what you ship next'}

)} @@ -530,9 +542,6 @@ export default function Show({ Thank you, nullers, for every commit, reply, and star this year. From the team, happy New Year.

-

- This page is public. Send it anywhere. -

{shareUrl}

From 2200cfa3a6d69216dd1112e6927a53ab1b1ff501 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Thu, 12 Nov 2026 12:06:45 -0200 Subject: [PATCH 06/14] feat: swipe sideways to move through wrapped on touch devices --- resources/js/pages/wrapped/show.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 13beb734b7..17adb5ec57 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -305,6 +305,7 @@ export default function Show({ const [copiedLink, copyLink] = useClipboard(); const [copiedSummary, copySummary] = useClipboard(); const celebrated = useRef(false); + const touchStart = useRef<{ x: number; y: number } | null>(null); const last = 6; const hasCommits = stats.commits > 0; @@ -361,6 +362,31 @@ export default function Show({
{ + const touch = event.touches[0]; + touchStart.current = + event.touches.length === 1 && touch + ? { x: touch.clientX, y: touch.clientY } + : null; + }} + onTouchEnd={(event) => { + const touch = event.changedTouches[0]; + const from = touchStart.current; + touchStart.current = null; + + if (!touch || !from) { + return; + } + + const dx = touch.clientX - from.x; + const dy = touch.clientY - from.y; + + if (Math.abs(dx) < 48 || Math.abs(dx) < Math.abs(dy)) { + return; + } + + go(slide + (dx < 0 ? 1 : -1)); + }} > {slide === 0 && (
From bcbe99c67cfbb4b15cf4347566ace78edc836686 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Fri, 13 Nov 2026 08:04:19 -0200 Subject: [PATCH 07/14] feat: top 3 tech stack slide for wrapped from fence tags --- app/Queries/YearInReviewQuery.php | 73 ++++++++++++++++++- resources/js/pages/wrapped/show.tsx | 62 +++++++++++++++- .../YearInReviewControllerTest.php | 1 + 3 files changed, 131 insertions(+), 5 deletions(-) diff --git a/app/Queries/YearInReviewQuery.php b/app/Queries/YearInReviewQuery.php index 83f1e1d8ec..e2bf9a4e1b 100644 --- a/app/Queries/YearInReviewQuery.php +++ b/app/Queries/YearInReviewQuery.php @@ -11,10 +11,47 @@ /** * A profile's year in numbers: posts, stars, streaks and community growth. * - * @phpstan-type YearInReview array{year: int, commits: int, replies: int, starsEarned: int, followersGained: int, activeDays: int, longestStreak: int, months: list, weekdays: list, hourCounts: list, comeback: bool, dayCounts: array, topCommit: array{id: string, body: string, stars: int}|null} + * @phpstan-type YearInReview array{year: int, commits: int, replies: int, starsEarned: int, followersGained: int, activeDays: int, longestStreak: int, months: list, weekdays: list, hourCounts: list, comeback: bool, languages: array, dayCounts: array, topCommit: array{id: string, body: string, stars: int}|null} */ final readonly class YearInReviewQuery { + /** + * Fence tags authors already wrote, so no API calls and no new tables. + */ + private const FENCE_EXCLUDED = ['ansi', 'diff', 'fix', 'log', 'output', 'plaintext', 'terminal', 'text', 'txt']; + + /** @var array */ + private const LANGUAGE_DISPLAY = [ + 'bash' => 'Shell', + 'blade' => 'Blade', + 'c#' => 'C#', + 'c++' => 'C++', + 'css' => 'CSS', + 'go' => 'Go', + 'html' => 'HTML', + 'java' => 'Java', + 'javascript' => 'JavaScript', + 'js' => 'JavaScript', + 'json' => 'JSON', + 'jsx' => 'JSX', + 'kotlin' => 'Kotlin', + 'php' => 'PHP', + 'python' => 'Python', + 'ruby' => 'Ruby', + 'rust' => 'Rust', + 'sh' => 'Shell', + 'shell' => 'Shell', + 'sql' => 'SQL', + 'swift' => 'Swift', + 'ts' => 'TypeScript', + 'tsx' => 'TSX', + 'typescript' => 'TypeScript', + 'vue' => 'Vue', + 'xml' => 'XML', + 'yaml' => 'YAML', + 'yml' => 'YAML', + ]; + /** * @return YearInReview */ @@ -74,6 +111,7 @@ public function get(User $user, ?User $viewer, int $year): array 'weekdays' => $weekdays, 'hourCounts' => $hourCounts, 'comeback' => $this->hasComeback($days), + 'languages' => $this->topLanguages((clone $commits)->whereNull('commits.parent_id')->pluck('commits.body')), 'dayCounts' => $dayCounts, 'topCommit' => $top === null ? null : [ 'id' => $top->id, @@ -114,6 +152,39 @@ private function hasComeback(array $days): bool return false; } + /** + * Top 3 fence-tagged languages across the year's posts. Each post counts + * once per language, no matter how many blocks it holds. + * + * @return array + */ + private function topLanguages(iterable $bodies): array + { + $counts = []; + + foreach ($bodies as $body) { + preg_match_all('/```([a-zA-Z0-9_+#-]+)/', (string) $body, $matches); + + foreach (array_unique(array_map(strtolower(...), $matches[1])) as $tag) { + if (in_array($tag, self::FENCE_EXCLUDED, true)) { + continue; + } + + $counts[$tag] = ($counts[$tag] ?? 0) + 1; + } + } + + arsort($counts); + + $top = []; + + foreach (array_slice($counts, 0, 3, true) as $tag => $commits) { + $top[] = ['language' => self::LANGUAGE_DISPLAY[$tag] ?? ucfirst($tag), 'commits' => $commits]; + } + + return $top; + } + /** * @param list $days Ordered Y-m-d dates with at least one commit. */ diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 17adb5ec57..b64d4b0b96 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -25,6 +25,7 @@ type WrappedStats = { weekdays: number[]; hourCounts: number[]; comeback: boolean; + languages: Array<{ language: string; commits: number }>; dayCounts: Record; topCommit: { id: string; body: string; stars: number } | null; }; @@ -226,6 +227,14 @@ function buildInsights(stats: WrappedStats): string[] { ); } + const [stackTop] = stats.languages; + + if (stackTop) { + insights.push( + `${stackTop.language} tops your stack with ${stackTop.commits} code posts.`, + ); + } + insights.push( stats.replies > stats.commits ? 'You reply more than you post. Threads love you.' @@ -307,7 +316,7 @@ export default function Show({ const celebrated = useRef(false); const touchStart = useRef<{ x: number; y: number } | null>(null); - const last = 6; + const last = 7; const hasCommits = stats.commits > 0; const bestMonth = stats.months.indexOf(Math.max(...stats.months)); const craft = archetype(stats); @@ -536,7 +545,52 @@ export default function Show({ )} {slide === 5 && (
- 05 · Archetype + 05 · Your stack +

+ Your tech stack +

+ {stats.languages.length > 0 ? ( + <> +

+ Top 3 languages from your tagged code + blocks. +

+
+ {stats.languages.map((entry, index) => ( +
+
+

+ {index + 1}.{' '} + {entry.language} +

+

+ {entry.commits.toLocaleString()}{' '} + code posts +

+
+
+
+
+
+ ))} +
+ + ) : ( +

+ No tagged code blocks this year. Tag a fence + and it lands here. +

+ )} +
+ )} + {slide === 6 && ( +
+ 06 · Archetype

{craft.name}

@@ -555,9 +609,9 @@ export default function Show({
)} - {slide === 6 && ( + {slide === 7 && (
- 06 · Happy New Year + 07 · Happy New Year
diff --git a/tests/Feature/Controllers/YearInReviewControllerTest.php b/tests/Feature/Controllers/YearInReviewControllerTest.php index 90b22d41f0..e27e69d2ee 100644 --- a/tests/Feature/Controllers/YearInReviewControllerTest.php +++ b/tests/Feature/Controllers/YearInReviewControllerTest.php @@ -25,6 +25,7 @@ ->where('stats.topCommit.stars', 2) ->where('stats.months.2', 1) ->where('stats.months.4', 1) + ->where('stats.languages', []) ->where('stats.comeback', false) ->has('stats.hourCounts', 24)); }); From 66143bc3aa4ab2c61c20004c1a36938a59963a0d Mon Sep 17 00:00:00 2001 From: PacketByte Date: Sun, 15 Nov 2026 14:47:08 -0200 Subject: [PATCH 08/14] feat: notify handles when their Year in Review is ready --- app/Actions/CreateWrappedNotifications.php | 62 +++++++++++++++++++ app/Console/Commands/NotifyWrappedCommand.php | 26 ++++++++ app/Enums/NotificationType.php | 1 + app/Queries/NotificationBuilder.php | 2 +- resources/js/pages/notification/index.tsx | 30 +++++++-- resources/js/types/notification.ts | 6 ++ routes/console.php | 1 + tests/Feature/Commands/NotifyWrappedTest.php | 31 ++++++++++ tests/Unit/Enums/NotificationTypeTest.php | 1 + 9 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 app/Actions/CreateWrappedNotifications.php create mode 100644 app/Console/Commands/NotifyWrappedCommand.php create mode 100644 tests/Feature/Commands/NotifyWrappedTest.php diff --git a/app/Actions/CreateWrappedNotifications.php b/app/Actions/CreateWrappedNotifications.php new file mode 100644 index 0000000000..94c785193d --- /dev/null +++ b/app/Actions/CreateWrappedNotifications.php @@ -0,0 +1,62 @@ +whereNotIn('github_id', User::BOT_GITHUB_IDS) + ->whereHas( + 'commits', + fn (Builder $commits): Builder => $commits + ->where('status', CommitStatus::Approved) + ->whereYear('created_at', $year), + ) + ->pluck('users.id'); + + $now = now(); + + $notifications = []; + + foreach ($recipientIds as $recipientId) { + $notifications[] = [ + 'id' => Str::uuid7()->toString(), + 'recipient_id' => $recipientId, + 'actor_id' => $recipientId, + 'type' => NotificationType::WrappedReady->value, + 'commit_id' => null, + 'key' => 'wrapped:'.$year, + 'created_at' => $now, + 'updated_at' => $now, + ]; + } + + foreach (array_chunk($notifications, 500) as $chunk) { + Notification::query()->insertOrIgnore($chunk); + } + + if ($recipientIds->isNotEmpty()) { + event(new UsersUpdated($recipientIds->all(), UserUpdate::Notifications)); + } + + return count($notifications); + } +} diff --git a/app/Console/Commands/NotifyWrappedCommand.php b/app/Console/Commands/NotifyWrappedCommand.php new file mode 100644 index 0000000000..c16ff5a108 --- /dev/null +++ b/app/Console/Commands/NotifyWrappedCommand.php @@ -0,0 +1,26 @@ +option('year') ?? date('Y')); + + $count = $createWrappedNotifications->handle($year); + + $this->components->info("Wrapped notifications queued for {$count} handles for {$year}."); + + return self::SUCCESS; + } +} diff --git a/app/Enums/NotificationType.php b/app/Enums/NotificationType.php index 665df2a78c..96398e8da9 100644 --- a/app/Enums/NotificationType.php +++ b/app/Enums/NotificationType.php @@ -15,4 +15,5 @@ enum NotificationType: string case Starred = 'starred'; case LeveledUp = 'leveled_up'; case FirstCommit = 'first_commit'; + case WrappedReady = 'wrapped_ready'; } diff --git a/app/Queries/NotificationBuilder.php b/app/Queries/NotificationBuilder.php index 15c1a6bed0..b33310ce68 100644 --- a/app/Queries/NotificationBuilder.php +++ b/app/Queries/NotificationBuilder.php @@ -48,7 +48,7 @@ public function relevant(): self ->whereColumn('organization_members.organization_id', 'notifications.organization_id') ->whereColumn('organization_members.user_id', 'notifications.recipient_id'))) ->offset(0))) - ->orWhere('type', NotificationType::LeveledUp)) + ->orWhereIn('type', [NotificationType::LeveledUp, NotificationType::WrappedReady])) ->withoutSilencedActors(); } diff --git a/resources/js/pages/notification/index.tsx b/resources/js/pages/notification/index.tsx index ddacc8d9f4..bda54e9e15 100644 --- a/resources/js/pages/notification/index.tsx +++ b/resources/js/pages/notification/index.tsx @@ -16,6 +16,7 @@ import { ChevronsUp, GitCommitVertical, MessageSquareReply, + PartyPopper, Quote, Star, UserPlus, @@ -1176,6 +1177,10 @@ export function NotificationContent({ notification.type === 'mentioned' || notification.type === 'first_commit'; const level = notification.type === 'leveled_up' ? notification : null; + const wrappedYear = + notification.type === 'wrapped_ready' + ? new Date(notification.created_at).getFullYear() + : null; const Icon = { followed: UserPlus, leveled_up: ChevronsUp, @@ -1186,6 +1191,7 @@ export function NotificationContent({ first_commit: GitCommitVertical, approved: Check, rejected: X, + wrapped_ready: PartyPopper, }[notification.type]; const icon = ( {notification.rank_description} @@ -1617,6 +1627,14 @@ export function NotificationContent({ ) )} + ) : notification.type === + 'wrapped_ready' ? ( + + {`@${user.handle}`} + ) : ( <> ; + }) + | (BaseNotification & { + type: 'wrapped_ready'; + commit_id: null; + subject_id: null; + commit: null; }); diff --git a/routes/console.php b/routes/console.php index 28f126fa5d..8e71bcd391 100644 --- a/routes/console.php +++ b/routes/console.php @@ -14,6 +14,7 @@ Schedule::job(new EndLiveStreams())->everyFiveMinutes(); Schedule::job(new GenerateHotHeadlineSummaries())->everyFifteenMinutes(); Schedule::command('model:prune', ['--model' => [Headline::class]])->hourly()->withoutOverlapping(); +Schedule::command('wrapped:notify')->yearlyOn(12, 3, '9:00')->withoutOverlapping(); Schedule::call(function (): void { DB::table('pending_file_deletions')->orderBy('id')->chunkById(100, function (Collection $pending): void { diff --git a/tests/Feature/Commands/NotifyWrappedTest.php b/tests/Feature/Commands/NotifyWrappedTest.php new file mode 100644 index 0000000000..4211dc7267 --- /dev/null +++ b/tests/Feature/Commands/NotifyWrappedTest.php @@ -0,0 +1,31 @@ +create(); + Commit::factory()->create(['author_id' => $withCommit->id, 'created_at' => now()]); + $withoutCommit = User::factory()->create(); + + $this->artisan('wrapped:notify', ['--year' => (string) $year])->assertSuccessful(); + + $this->assertDatabaseHas('notifications', [ + 'recipient_id' => $withCommit->id, + 'actor_id' => $withCommit->id, + 'type' => 'wrapped_ready', + 'key' => 'wrapped:'.$year, + ]); + $this->assertDatabaseMissing('notifications', [ + 'recipient_id' => $withoutCommit->id, + 'type' => 'wrapped_ready', + ]); + + $this->artisan('wrapped:notify', ['--year' => (string) $year])->assertSuccessful(); + + $this->assertDatabaseCount('notifications', 1); +}); diff --git a/tests/Unit/Enums/NotificationTypeTest.php b/tests/Unit/Enums/NotificationTypeTest.php index 864490e378..7ecd76ff45 100644 --- a/tests/Unit/Enums/NotificationTypeTest.php +++ b/tests/Unit/Enums/NotificationTypeTest.php @@ -15,5 +15,6 @@ 'Starred' => 'starred', 'LeveledUp' => 'leveled_up', 'FirstCommit' => 'first_commit', + 'WrappedReady' => 'wrapped_ready', ]); }); From dc0f7f127f3a3a221d0ed3d414d68c3536a25237 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Sun, 15 Nov 2026 15:35:18 -0200 Subject: [PATCH 09/14] feat: lock wrapped behind a December 3rd countdown teaser --- .../Controllers/YearInReviewController.php | 25 +++++- resources/js/pages/wrapped/show.tsx | 83 ++++++++++++++++++- .../YearInReviewControllerTest.php | 32 +++++++ 3 files changed, 138 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/YearInReviewController.php b/app/Http/Controllers/YearInReviewController.php index 81d6a71a21..11e880a173 100644 --- a/app/Http/Controllers/YearInReviewController.php +++ b/app/Http/Controllers/YearInReviewController.php @@ -21,6 +21,27 @@ public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearIn abort_unless($user instanceof User, 404); + $shareUrl = route('wrapped.show', ['profile' => $profile->handle]); + + // Wrapped drops with the notification, every December 3rd at 09:00. + $unlocksAt = now()->setDate($year, 12, 3)->setTime(9, 0); + + if (now()->lt($unlocksAt)) { + return Inertia::render('wrapped/show', [ + 'handle' => $profile->handle, + 'name' => $user->name, + 'avatarUrl' => $user->avatar_url, + 'stats' => null, + 'shareUrl' => $shareUrl, + 'locked' => true, + 'unlocksAt' => $unlocksAt->toIso8601String(), + ])->withViewData(['preview' => $metadata->page( + "{$profile->handle}'s {$year} Wrapped - /dev/null", + "The {$year} Wrapped for @{$profile->handle} unwraps December 3rd.", + $shareUrl, + )]); + } + $stats = $review->get($user, $currentUser, $year); return Inertia::render('wrapped/show', [ @@ -28,7 +49,9 @@ public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearIn 'name' => $user->name, 'avatarUrl' => $user->avatar_url, 'stats' => $stats, - 'shareUrl' => route('wrapped.show', ['profile' => $profile->handle]), + 'shareUrl' => $shareUrl, + 'locked' => false, + 'unlocksAt' => null, ])->withViewData(['preview' => $metadata->page( "{$profile->handle}'s {$year} in review - /dev/null", "What @{$profile->handle} shipped in {$year}: {$stats['commits']} commits, {$stats['starsEarned']} stars and a {$stats['longestStreak']}-day streak.", diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index b64d4b0b96..691d26b319 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -2,6 +2,7 @@ import { Head } from '@inertiajs/react'; import { useCallback, useEffect, + useMemo, useRef, useState, type ReactNode, @@ -34,10 +35,56 @@ type WrappedProps = { handle: string; name: string; avatarUrl: string | null; - stats: WrappedStats; + stats: WrappedStats | null; shareUrl: string; + locked: boolean; + unlocksAt: string | null; }; +function Countdown({ to }: { to: string }) { + const target = useMemo(() => new Date(to).getTime(), [to]); + const [now, setNow] = useState(() => Date.now()); + + useEffect(() => { + const id = window.setInterval(() => setNow(Date.now()), 1000); + + return () => window.clearInterval(id); + }, []); + + const remaining = Math.max(0, target - now); + const units: Array<{ value: number; label: string }> = [ + { value: Math.floor(remaining / 86_400_000), label: 'days' }, + { + value: Math.floor(remaining / 3_600_000) % 24, + label: 'hours', + }, + { value: Math.floor(remaining / 60_000) % 60, label: 'mins' }, + { value: Math.floor(remaining / 1000) % 60, label: 'secs' }, + ]; + + return ( +
+ {units.map((unit) => ( +
+

+ {String(unit.value).padStart(2, '0')} +

+

+ {unit.label} +

+
+ ))} +
+ ); +} + function BigNumber({ value, label }: { value: number; label: string }) { return (
@@ -309,6 +356,8 @@ export default function Show({ avatarUrl, stats, shareUrl, + locked, + unlocksAt, }: WrappedProps) { const [slide, setSlide] = useState(0); const [copiedLink, copyLink] = useClipboard(); @@ -316,6 +365,38 @@ export default function Show({ const celebrated = useRef(false); const touchStart = useRef<{ x: number; y: number } | null>(null); + if (locked) { + const year = unlocksAt + ? new Date(unlocksAt).getFullYear() + : new Date().getFullYear(); + + return ( + <> + +
+
+ Wrapped · {year} +
+ +
+

+ Your {year} Wrapped is still being prepared. +

+

+ It unwraps on December 3rd, and we’ll notify you + when it’s ready. +

+ {unlocksAt && } +
+
+ + ); + } + + if (!stats) { + return null; + } + const last = 7; const hasCommits = stats.commits > 0; const bestMonth = stats.months.indexOf(Math.max(...stats.months)); diff --git a/tests/Feature/Controllers/YearInReviewControllerTest.php b/tests/Feature/Controllers/YearInReviewControllerTest.php index e27e69d2ee..2b27b570ec 100644 --- a/tests/Feature/Controllers/YearInReviewControllerTest.php +++ b/tests/Feature/Controllers/YearInReviewControllerTest.php @@ -4,10 +4,12 @@ use App\Models\Commit; use App\Models\User; +use Carbon\Carbon; it('renders the year in review for guests', function (): void { $user = User::factory()->create(); $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); $top = Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 3, 10)]); $top->stars()->attach(User::factory()->count(2)->create(), ['created_at' => now()->setDate($year, 4, 1)]); @@ -33,8 +35,38 @@ it('describes the review to search engines and link previews', function (): void { $user = User::factory()->create(); $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) ->assertOk() ->assertSee("{$user->profile->handle}'s {$year} in review - /dev/null", false); }); + +it('locks wrapped behind a countdown until December 3rd at 09:00', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 2, 23, 59)); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->component('wrapped/show') + ->where('handle', $user->profile->handle) + ->where('locked', true) + ->where('stats', null) + ->where('unlocksAt', Carbon::create($year, 12, 3, 9)->toIso8601String())); +}); + +it('opens wrapped once the unlock moment passes', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 3, 9)); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->component('wrapped/show') + ->where('locked', false) + ->where('unlocksAt', null) + ->where('stats.year', $year)); +}); From 5889f19df81f91015f78232b920c9efec32749a1 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Sun, 15 Nov 2026 15:58:42 -0200 Subject: [PATCH 10/14] feat: auto-open wrapped when the countdown hits zero --- resources/js/pages/wrapped/show.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 691d26b319..a538e9eab5 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -44,12 +44,21 @@ type WrappedProps = { function Countdown({ to }: { to: string }) { const target = useMemo(() => new Date(to).getTime(), [to]); const [now, setNow] = useState(() => Date.now()); + const reloaded = useRef(false); useEffect(() => { - const id = window.setInterval(() => setNow(Date.now()), 1000); + const id = window.setInterval(() => { + const left = target - Date.now(); + setNow(Date.now()); + + if (left <= 0 && !reloaded.current) { + reloaded.current = true; + window.setTimeout(() => window.location.reload(), 1500); + } + }, 1000); return () => window.clearInterval(id); - }, []); + }, [target]); const remaining = Math.max(0, target - now); const units: Array<{ value: number; label: string }> = [ From 2dcc67318fe0c13ea304bdfed128e3688578b885 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Sun, 15 Nov 2026 17:30:57 -0200 Subject: [PATCH 11/14] fix: address review findings on wrapped notifications, stats, and unlock --- app/Console/Commands/NotifyWrappedCommand.php | 6 ++ .../Controllers/YearInReviewController.php | 7 +- app/Queries/YearInReviewQuery.php | 26 ++++-- resources/js/pages/notification/index.tsx | 2 +- resources/js/pages/wrapped/show.tsx | 20 +++-- tests/Feature/Commands/NotifyWrappedTest.php | 9 +++ .../YearInReviewControllerTest.php | 80 +++++++++++++++++++ 7 files changed, 136 insertions(+), 14 deletions(-) diff --git a/app/Console/Commands/NotifyWrappedCommand.php b/app/Console/Commands/NotifyWrappedCommand.php index c16ff5a108..ef065c6046 100644 --- a/app/Console/Commands/NotifyWrappedCommand.php +++ b/app/Console/Commands/NotifyWrappedCommand.php @@ -17,6 +17,12 @@ public function handle(CreateWrappedNotifications $createWrappedNotifications): { $year = (int) ($this->option('year') ?? date('Y')); + if ($year !== (int) date('Y')) { + $this->components->error('Wrapped notifications can only be queued for the current year.'); + + return self::FAILURE; + } + $count = $createWrappedNotifications->handle($year); $this->components->info("Wrapped notifications queued for {$count} handles for {$year}."); diff --git a/app/Http/Controllers/YearInReviewController.php b/app/Http/Controllers/YearInReviewController.php index 11e880a173..3ac5ebf3e1 100644 --- a/app/Http/Controllers/YearInReviewController.php +++ b/app/Http/Controllers/YearInReviewController.php @@ -9,15 +9,18 @@ use App\Queries\YearInReviewQuery; use App\Services\PageMetadata; use Illuminate\Container\Attributes\CurrentUser; +use Illuminate\Http\Request; use Inertia\Inertia; use Inertia\Response; final readonly class YearInReviewController { - public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearInReviewQuery $review, PageMetadata $metadata): Response + public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearInReviewQuery $review, PageMetadata $metadata, Request $request): Response { $user = $profile->user; - $year = (int) now()->year; + $currentYear = (int) now()->year; + $requestedYear = $request->integer('year'); + $year = $requestedYear > 0 && $requestedYear <= $currentYear ? $requestedYear : $currentYear; abort_unless($user instanceof User, 404); diff --git a/app/Queries/YearInReviewQuery.php b/app/Queries/YearInReviewQuery.php index e2bf9a4e1b..4246ee1aca 100644 --- a/app/Queries/YearInReviewQuery.php +++ b/app/Queries/YearInReviewQuery.php @@ -20,6 +20,15 @@ */ private const FENCE_EXCLUDED = ['ansi', 'diff', 'fix', 'log', 'output', 'plaintext', 'terminal', 'text', 'txt']; + /** @var array */ + private const LANGUAGE_CANONICAL = [ + 'js' => 'javascript', + 'sh' => 'bash', + 'shell' => 'bash', + 'ts' => 'typescript', + 'yml' => 'yaml', + ]; + /** @var array */ private const LANGUAGE_DISPLAY = [ 'bash' => 'Shell', @@ -64,7 +73,7 @@ public function get(User $user, ?User $viewer, int $year): array $starsEarned = (int) DB::table('stars') ->join('commits', 'commits.id', '=', 'stars.commit_id') - ->where('commits.user_id', $user->id) + ->where('commits.author_id', $user->id) ->whereBetween('stars.created_at', [$start, $end]) ->count(); @@ -135,10 +144,10 @@ private function hasComeback(array $days): bool foreach ($days as $day) { $current = CarbonImmutable::parse($day); - if ($previous !== null && $current->diffInDays($previous) === 1) { + if ($previous !== null && $current->toDateString() === $previous->addDay()->toDateString()) { $run++; } else { - $gap = $previous === null ? 0 : $current->diffInDays($previous); + $gap = $previous === null ? 0 : (int) $previous->diffInDays($current); $run = 1; } @@ -165,7 +174,10 @@ private function topLanguages(iterable $bodies): array foreach ($bodies as $body) { preg_match_all('/```([a-zA-Z0-9_+#-]+)/', (string) $body, $matches); - foreach (array_unique(array_map(strtolower(...), $matches[1])) as $tag) { + $tags = array_map(strtolower(...), $matches[1]); + $tags = array_map(fn ($tag) => self::LANGUAGE_CANONICAL[$tag] ?? $tag, $tags); + + foreach (array_unique($tags) as $tag) { if (in_array($tag, self::FENCE_EXCLUDED, true)) { continue; } @@ -179,6 +191,7 @@ private function topLanguages(iterable $bodies): array $top = []; foreach (array_slice($counts, 0, 3, true) as $tag => $commits) { + $tag = (string) $tag; $top[] = ['language' => self::LANGUAGE_DISPLAY[$tag] ?? ucfirst($tag), 'commits' => $commits]; } @@ -195,9 +208,10 @@ private function longestRun(array $days): int $previous = null; foreach ($days as $day) { - $run = $previous !== null && CarbonImmutable::parse($day)->diffInDays($previous) === 1 ? $run + 1 : 1; + $current = CarbonImmutable::parse($day); + $run = $previous !== null && $current->toDateString() === $previous->addDay()->toDateString() ? $run + 1 : 1; $longest = max($longest, $run); - $previous = CarbonImmutable::parse($day); + $previous = $current; } return $longest; diff --git a/resources/js/pages/notification/index.tsx b/resources/js/pages/notification/index.tsx index b325f6ac9a..8278bcd0fc 100644 --- a/resources/js/pages/notification/index.tsx +++ b/resources/js/pages/notification/index.tsx @@ -1219,7 +1219,7 @@ export function NotificationContent({ (!summary && notification.type === 'starred') ? show(actor) : notification.type === 'wrapped_ready' - ? `/@${user.handle}/wrapped` + ? `/@${user.handle}/wrapped${wrappedYear ? `?year=${wrappedYear}` : ''}` : CommitController.show({ profile: isOwnCommit ? (notification.organization ?? user) diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index a538e9eab5..1210b11ad2 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -45,6 +45,7 @@ function Countdown({ to }: { to: string }) { const target = useMemo(() => new Date(to).getTime(), [to]); const [now, setNow] = useState(() => Date.now()); const reloaded = useRef(false); + const reloadTimeout = useRef(null); useEffect(() => { const id = window.setInterval(() => { @@ -53,11 +54,20 @@ function Countdown({ to }: { to: string }) { if (left <= 0 && !reloaded.current) { reloaded.current = true; - window.setTimeout(() => window.location.reload(), 1500); + reloadTimeout.current = window.setTimeout( + () => window.location.reload(), + 1500, + ); } }, 1000); - return () => window.clearInterval(id); + return () => { + window.clearInterval(id); + + if (reloadTimeout.current !== null) { + window.clearTimeout(reloadTimeout.current); + } + }; }, [target]); const remaining = Math.max(0, target - now); @@ -166,7 +176,7 @@ function archetype(stats: WrappedStats): { name: string; quip: string } { }; } - const total = stats.commits + stats.replies; + const total = stats.commits > 0 ? stats.commits : 1; const night = (stats.hourCounts[22] ?? 0) + (stats.hourCounts[23] ?? 0) + @@ -251,9 +261,9 @@ function archetype(stats: WrappedStats): { name: string; quip: string } { } function buildInsights(stats: WrappedStats): string[] { - const total = stats.commits + stats.replies; + const total = stats.commits > 0 ? stats.commits : 1; - if (total === 0) { + if (stats.commits === 0) { return ['No commits this year. The graph is a blank canvas.']; } diff --git a/tests/Feature/Commands/NotifyWrappedTest.php b/tests/Feature/Commands/NotifyWrappedTest.php index 4211dc7267..263efa2c62 100644 --- a/tests/Feature/Commands/NotifyWrappedTest.php +++ b/tests/Feature/Commands/NotifyWrappedTest.php @@ -29,3 +29,12 @@ $this->assertDatabaseCount('notifications', 1); }); + +it('rejects years other than the current year', function (): void { + $user = User::factory()->create(); + Commit::factory()->create(['author_id' => $user->id, 'created_at' => now()->subYear()]); + + $this->artisan('wrapped:notify', ['--year' => (string) ((int) date('Y') - 1)])->assertFailed(); + + $this->assertDatabaseCount('notifications', 0); +}); diff --git a/tests/Feature/Controllers/YearInReviewControllerTest.php b/tests/Feature/Controllers/YearInReviewControllerTest.php index 2b27b570ec..dc0450d8e6 100644 --- a/tests/Feature/Controllers/YearInReviewControllerTest.php +++ b/tests/Feature/Controllers/YearInReviewControllerTest.php @@ -70,3 +70,83 @@ ->where('unlocksAt', null) ->where('stats.year', $year)); }); + +it('counts consecutive calendar days as a streak', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); + + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 1, 5)]); + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 1, 6)]); + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 1, 7)]); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->where('stats.longestStreak', 3) + ->where('stats.comeback', false)); +}); + +it('flags a 7-day run after a month of silence as a comeback', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); + + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 1, 1)]); + + foreach (range(1, 7) as $day) { + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year, 3, $day)]); + } + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->where('stats.longestStreak', 7) + ->where('stats.comeback', true)); +}); + +it('merges language aliases into one entry per post', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); + + Commit::factory()->for($user)->create(['body' => "Note\n```js\nconst a = 1;\n```", 'created_at' => now()->setDate($year, 2, 1)]); + Commit::factory()->for($user)->create(['body' => "Note\n```javascript\nconst b = 2;\n```\n```php\necho 1;\n```", 'created_at' => now()->setDate($year, 2, 2)]); + Commit::factory()->for($user)->create(['body' => "Note\n```js\nconst c = 3;\n```\n```javascript\nconst d = 4;\n```", 'created_at' => now()->setDate($year, 2, 3)]); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->where('stats.languages', [ + ['language' => 'JavaScript', 'commits' => 3], + ['language' => 'PHP', 'commits' => 1], + ])); +}); + +it('opens a past year from a notification link', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); + + Commit::factory()->for($user)->create(['created_at' => now()->setDate($year - 1, 6, 15)]); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle, 'year' => $year - 1])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->component('wrapped/show') + ->where('locked', false) + ->where('stats.year', $year - 1) + ->where('stats.commits', 1)); +}); + +it('falls back to the current year for a future year', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle, 'year' => $year + 5])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->where('locked', false) + ->where('stats.year', $year)); +}); From c751ba88756d33e79d652724555c8b0cc39829d7 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Sun, 15 Nov 2026 17:48:22 -0200 Subject: [PATCH 12/14] fix: year-aware wrapped share urls and numeric fence regression test --- .../Controllers/YearInReviewController.php | 10 ++++++++-- .../YearInReviewControllerTest.php | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/YearInReviewController.php b/app/Http/Controllers/YearInReviewController.php index 3ac5ebf3e1..6a12e77cfd 100644 --- a/app/Http/Controllers/YearInReviewController.php +++ b/app/Http/Controllers/YearInReviewController.php @@ -24,7 +24,13 @@ public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearIn abort_unless($user instanceof User, 404); - $shareUrl = route('wrapped.show', ['profile' => $profile->handle]); + $parameters = ['profile' => $profile->handle]; + + if ($year !== $currentYear) { + $parameters['year'] = $year; + } + + $shareUrl = route('wrapped.show', $parameters); // Wrapped drops with the notification, every December 3rd at 09:00. $unlocksAt = now()->setDate($year, 12, 3)->setTime(9, 0); @@ -58,7 +64,7 @@ public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearIn ])->withViewData(['preview' => $metadata->page( "{$profile->handle}'s {$year} in review - /dev/null", "What @{$profile->handle} shipped in {$year}: {$stats['commits']} commits, {$stats['starsEarned']} stars and a {$stats['longestStreak']}-day streak.", - route('wrapped.show', ['profile' => $profile->handle]), + $shareUrl, )]); } } diff --git a/tests/Feature/Controllers/YearInReviewControllerTest.php b/tests/Feature/Controllers/YearInReviewControllerTest.php index dc0450d8e6..0755133dce 100644 --- a/tests/Feature/Controllers/YearInReviewControllerTest.php +++ b/tests/Feature/Controllers/YearInReviewControllerTest.php @@ -23,6 +23,7 @@ ->where('handle', $user->profile->handle) ->where('stats.year', $year) ->where('stats.commits', 2) + ->where('shareUrl', route('wrapped.show', ['profile' => $user->profile->handle])) ->where('stats.starsEarned', 2) ->where('stats.topCommit.stars', 2) ->where('stats.months.2', 1) @@ -123,6 +124,21 @@ ])); }); +it('renders numeric fence tags without failing', function (): void { + $user = User::factory()->create(); + $year = (int) now()->year; + $this->travelTo(Carbon::create($year, 12, 4, 9, 1)); + + Commit::factory()->for($user)->create(['body' => "Note\n```123\n456\n```", 'created_at' => now()->setDate($year, 2, 1)]); + + $this->get(route('wrapped.show', ['profile' => $user->profile->handle])) + ->assertOk() + ->assertInertia(fn ($page) => $page + ->where('stats.languages', [ + ['language' => '123', 'commits' => 1], + ])); +}); + it('opens a past year from a notification link', function (): void { $user = User::factory()->create(); $year = (int) now()->year; @@ -136,7 +152,8 @@ ->component('wrapped/show') ->where('locked', false) ->where('stats.year', $year - 1) - ->where('stats.commits', 1)); + ->where('stats.commits', 1) + ->where('shareUrl', route('wrapped.show', ['profile' => $user->profile->handle, 'year' => $year - 1]))); }); it('falls back to the current year for a future year', function (): void { From 988ce389562661b5851abd12f6ff32e06626317a Mon Sep 17 00:00:00 2001 From: PacketByte Date: Sun, 15 Nov 2026 18:45:51 -0200 Subject: [PATCH 13/14] feat: browse previous Year in Review recaps --- .../Controllers/YearInReviewController.php | 13 ++++ resources/js/pages/wrapped/show.tsx | 73 ++++++++++++++++++- .../YearInReviewControllerTest.php | 7 ++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/YearInReviewController.php b/app/Http/Controllers/YearInReviewController.php index 6a12e77cfd..835fd6f4ec 100644 --- a/app/Http/Controllers/YearInReviewController.php +++ b/app/Http/Controllers/YearInReviewController.php @@ -35,6 +35,13 @@ public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearIn // Wrapped drops with the notification, every December 3rd at 09:00. $unlocksAt = now()->setDate($year, 12, 3)->setTime(9, 0); + $hasPreviousYear = $user->commits() + ->whereBetween('commits.created_at', [ + now()->setDate($year - 1, 1, 1)->startOfDay(), + now()->setDate($year - 1, 12, 31)->endOfDay(), + ]) + ->exists(); + if (now()->lt($unlocksAt)) { return Inertia::render('wrapped/show', [ 'handle' => $profile->handle, @@ -44,6 +51,9 @@ public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearIn 'shareUrl' => $shareUrl, 'locked' => true, 'unlocksAt' => $unlocksAt->toIso8601String(), + 'year' => $year, + 'currentYear' => $currentYear, + 'hasPreviousYear' => $hasPreviousYear, ])->withViewData(['preview' => $metadata->page( "{$profile->handle}'s {$year} Wrapped - /dev/null", "The {$year} Wrapped for @{$profile->handle} unwraps December 3rd.", @@ -61,6 +71,9 @@ public function show(#[CurrentUser] ?User $currentUser, Profile $profile, YearIn 'shareUrl' => $shareUrl, 'locked' => false, 'unlocksAt' => null, + 'year' => $year, + 'currentYear' => $currentYear, + 'hasPreviousYear' => $hasPreviousYear, ])->withViewData(['preview' => $metadata->page( "{$profile->handle}'s {$year} in review - /dev/null", "What @{$profile->handle} shipped in {$year}: {$stats['commits']} commits, {$stats['starsEarned']} stars and a {$stats['longestStreak']}-day streak.", diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index 1210b11ad2..cd67f51a17 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -1,4 +1,5 @@ -import { Head } from '@inertiajs/react'; +import { Head, Link } from '@inertiajs/react'; +import { ChevronLeft, ChevronRight } from 'lucide-react'; import { useCallback, useEffect, @@ -7,6 +8,7 @@ import { useState, type ReactNode, } from 'react'; +import { show as showWrapped } from '@/actions/App/Http/Controllers/YearInReviewController'; import AppLogo from '@/components/app-logo'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Button } from '@/components/ui/button'; @@ -39,6 +41,9 @@ type WrappedProps = { shareUrl: string; locked: boolean; unlocksAt: string | null; + year: number; + currentYear: number; + hasPreviousYear: boolean; }; function Countdown({ to }: { to: string }) { @@ -377,6 +382,9 @@ export default function Show({ shareUrl, locked, unlocksAt, + year, + currentYear, + hasPreviousYear, }: WrappedProps) { const [slide, setSlide] = useState(0); const [copiedLink, copyLink] = useClipboard(); @@ -448,6 +456,10 @@ export default function Show({ return () => window.removeEventListener('keydown', onKey); }, [slide, go]); + useEffect(() => { + setSlide(0); + }, [year]); + return ( <> @@ -515,6 +527,54 @@ export default function Show({

@{handle}

+ {(hasPreviousYear || year < currentYear) && ( + + )}

{stats.year} in review

@@ -716,7 +776,9 @@ export default function Show({

- See you next year, nuller + {year < currentYear + ? `That was ${year}, nuller` + : 'See you next year, nuller'}

Thank you, nullers, for every commit, reply, and @@ -742,6 +804,13 @@ export default function Show({ > {copiedSummary ? 'Copied' : 'Copy summary'} + {year < currentYear && ( + + )}

)} diff --git a/tests/Feature/Controllers/YearInReviewControllerTest.php b/tests/Feature/Controllers/YearInReviewControllerTest.php index 0755133dce..4aaa275045 100644 --- a/tests/Feature/Controllers/YearInReviewControllerTest.php +++ b/tests/Feature/Controllers/YearInReviewControllerTest.php @@ -30,6 +30,10 @@ ->where('stats.months.4', 1) ->where('stats.languages', []) ->where('stats.comeback', false) + ->where('stats.year', $year) + ->where('year', $year) + ->where('currentYear', $year) + ->where('hasPreviousYear', true) ->has('stats.hourCounts', 24)); }); @@ -153,6 +157,9 @@ ->where('locked', false) ->where('stats.year', $year - 1) ->where('stats.commits', 1) + ->where('year', $year - 1) + ->where('currentYear', $year) + ->where('hasPreviousYear', false) ->where('shareUrl', route('wrapped.show', ['profile' => $user->profile->handle, 'year' => $year - 1]))); }); From 330bee0d8fc8f08c854f01225ea5a7509e6681e7 Mon Sep 17 00:00:00 2001 From: PacketByte Date: Sun, 15 Nov 2026 19:16:12 -0200 Subject: [PATCH 14/14] feat: always show the Wrapped year switcher --- resources/js/pages/wrapped/show.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/pages/wrapped/show.tsx b/resources/js/pages/wrapped/show.tsx index cd67f51a17..2880e2c619 100644 --- a/resources/js/pages/wrapped/show.tsx +++ b/resources/js/pages/wrapped/show.tsx @@ -527,7 +527,7 @@ export default function Show({

@{handle}

- {(hasPreviousYear || year < currentYear) && ( + { - )} + }

{stats.year} in review