Skip to content

feat: add random active contribution generator#87

Merged
zmrlft merged 1 commit into
zmrlft:mainfrom
somnus0917:feature/random-active-contributions
May 12, 2026
Merged

feat: add random active contribution generator#87
zmrlft merged 1 commit into
zmrlft:mainfrom
somnus0917:feature/random-active-contributions

Conversation

@somnus0917

@somnus0917 somnus0917 commented May 12, 2026

Copy link
Copy Markdown
Contributor

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, or 9, 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:

  • Weekends are more likely to produce low-intensity contributions.
  • Weekdays are more likely to produce medium or high-intensity contributions.

This produces a pattern with frequent workday activity, lighter weekend activity, natural streaks, and varied contribution strength.

UI Changes

  • Adds a new dock button: Random Active.
  • Adds English and Chinese translations.
  • The generated pattern works with the existing editor state, undo history, export flow, and repository generation flow.

Testing

  • Ran npm run build
  • Ran go test ./...

概述

这个 PR 新增了一个「随机活跃」功能,可以为当前选中的年份快速生成一组更接近真实高频 GitHub 贡献者的 contribution 分布。相比手动绘制或一键全绿,它生成的图案更自然,不会像均匀噪声或机械填充。

实现原理

生成器会按日期逐天生成当前年份的贡献数据,并且会跳过当前年份中的未来日期。

随机模型不是完全独立地给每一天撒点,而是加入了几个模拟真实使用习惯的因素:

  • 工作日的基础活跃概率高于周末。

  • 如果前一天有贡献,第二天会获得额外概率加成,用来模拟连续贡献 streak。

  • 使用轻微的月份周期波动,让一年中的活跃密度有自然起伏,避免全年看起来过于平均。

  • 活跃日期会被分配到现有的贡献强度级别:1369


    当前概率设计:

  • 工作日基础活跃概率约为 87%

  • 周末基础活跃概率约为 48%

  • 前一天活跃会带来 12% 的连续贡献加成。

  • 月份波动最多带来 ±8% 的活跃概率变化。

贡献强度也区分工作日和周末:

  • 周末更容易生成低强度贡献。
  • 工作日更容易生成中高强度贡献。

最终效果是:工作日较密集,周末较轻,带有自然连续 streak,并且贡献强度有层次。

UI 变化

  • 新增底部工具栏按钮:「随机活跃」。
  • 补充英文和中文翻译。
  • 生成结果接入现有编辑状态,支持撤销、导出和生成仓库流程。

测试

  • 已运行 npm run build
  • 已运行 go 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.

  • New Features
    • Adds a dock button: Random Active (with tooltip).
    • Probabilistic model: weekday/weekend bias, small streak boost, light monthly wave.
    • Assigns counts 1/3/6/9; weekends favor lower intensity.
    • Skips future dates and respects the filtered range.
    • Adds English and Chinese translations for the button and tooltip.

Written for commit fb38332. Summary will update on new commits.

Copilot AI review requested due to automatic review settings May 12, 2026 01:40

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread frontend/src/hooks/useContributionEditor.ts
Comment thread frontend/src/i18n.tsx
@somnus0917 somnus0917 force-pushed the feature/random-active-contributions branch from 7ec2ed7 to 58ae58b Compare May 12, 2026 01:46
Copilot AI review requested due to automatic review settings May 12, 2026 01:47
@somnus0917 somnus0917 force-pushed the feature/random-active-contributions branch from 58ae58b to fb38332 Compare May 12, 2026 01:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@zmrlft

zmrlft commented May 12, 2026

Copy link
Copy Markdown
Owner

great

@zmrlft zmrlft merged commit 1f9a579 into zmrlft:main May 12, 2026
7 of 8 checks passed
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.

3 participants