feat: add random active contribution generator#87
Merged
zmrlft merged 1 commit intoMay 12, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new “Random Active” contribution generator to quickly populate the currently selected year with a realistic, streaky activity pattern (weekday/weekend bias + streak boost + mild seasonal variation), integrated into the existing editor/undo/export flows.
Changes:
- Added a random “frequent contributor” generation algorithm to the contribution editor hook.
- Added a new dock button to trigger the generator from the calendar UI.
- Added EN/ZH i18n strings for the new button and tooltip/title.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| frontend/src/i18n.tsx | Adds i18n keys/strings for the new generator button and tooltip/title. |
| frontend/src/hooks/useContributionEditor.ts | Implements the random active pattern generator and exposes it via the editor hook API. |
| frontend/src/components/ContributionCalendar.tsx | Wires a new dock button to call the generator and display localized text/tooltip. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7ec2ed7 to
58ae58b
Compare
58ae58b to
fb38332
Compare
Owner
|
great |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a "Random Active" generator for the current contribution calendar year. It helps users quickly create a realistic-looking contribution pattern that resembles a frequent GitHub contributor, instead of manually painting every day or filling the entire year uniformly.
How It Works
The generator creates contributions day by day for the selected year, skipping future dates in the current year.
The random model is designed to avoid flat noise:
Weekdays have a higher base activity probability than weekends.
If the previous day was active, the next day gets a small probability boost, which naturally creates contribution streaks.
A light monthly sine wave slightly changes activity density across the year, so the calendar does not look evenly distributed.
Active days are assigned contribution counts from


1,3,6, or9, matching the existing contribution intensity levels.Current probabilities:
Weekdays start around
87%active.Weekends start around
48%active.Consecutive active days add a
12%streak boost.Monthly variation adds up to
±8%.Contribution intensity also differs by weekday/weekend:
This produces a pattern with frequent workday activity, lighter weekend activity, natural streaks, and varied contribution strength.
UI Changes
Random Active.Testing
npm run buildgo test ./...概述
这个 PR 新增了一个「随机活跃」功能,可以为当前选中的年份快速生成一组更接近真实高频 GitHub 贡献者的 contribution 分布。相比手动绘制或一键全绿,它生成的图案更自然,不会像均匀噪声或机械填充。
实现原理
生成器会按日期逐天生成当前年份的贡献数据,并且会跳过当前年份中的未来日期。
随机模型不是完全独立地给每一天撒点,而是加入了几个模拟真实使用习惯的因素:
工作日的基础活跃概率高于周末。
如果前一天有贡献,第二天会获得额外概率加成,用来模拟连续贡献 streak。
使用轻微的月份周期波动,让一年中的活跃密度有自然起伏,避免全年看起来过于平均。
活跃日期会被分配到现有的贡献强度级别:


1、3、6、9。当前概率设计:
工作日基础活跃概率约为
87%。周末基础活跃概率约为
48%。前一天活跃会带来
12%的连续贡献加成。月份波动最多带来
±8%的活跃概率变化。贡献强度也区分工作日和周末:
最终效果是:工作日较密集,周末较轻,带有自然连续 streak,并且贡献强度有层次。
UI 变化
测试
npm run buildgo test ./...Summary by cubic
Adds a "Random Active" generator to quickly create a realistic frequent‑contributor pattern for the selected year, skipping future dates. Integrates with undo, export, and repo generation.
Written for commit fb38332. Summary will update on new commits.