Skip to content

feat: add Activity Report with heatmap and statistics - #23

Merged
drugoi merged 2 commits into
mainfrom
activity-report
Apr 5, 2026
Merged

drugoi merged 2 commits into
mainfrom
activity-report

Conversation

@maximgorbatyuk

Copy link
Copy Markdown
Collaborator

Summary

  • Add Activity Report feature to interactive TUI with GitHub-style commit heatmap, top active weekdays, avg files/commit, avg commits/day, and top repositories
  • New period selection screen (1/3/6/12 months) with colored terminal heatmap (ANSI colors) and fill-character markdown heatmap
  • Export to markdown support (E key) with structured filename format diddo_activity_N_month_YYYY-MM-DD.md
  • After export, automatically navigates back to main menu

Original prompt

I want to add Activity report. What should be in the activity report:

  • activity heatmap (like github shows)
  • Top3 active days of the week
  • average files per commit
  • average commits per day
  • Top3 repositories committed

The report should show data for last year by default.

User flow is the following:

  • user calls 'diddo' in console
  • user selects 'Activity Report'
  • user selects one of following options: Last year, 6 months, 3 months, 1 month
  • user sees the report. There should be lists, tables, and activity heatmap
  • user chooses one of two options: 'Esc to back to main menu', or 'Press E to export to markdown'. After exporting, user should be navigated back to main menu. The export file should be put to the same folder where the app was called, and filename format is diddo_activity_N_month_<current_date_YYYY-MM-DD>.md, where N - count of months

Output example (markdown export)

# Activity Report — Last year

**Period:** 2025-04-05 to 2026-04-05  
**Total commits:** 847  
**Total days:** 365  

## Activity Heatmap

     Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr
Mon  ░ · ▒ · ░ · █ ▒ ░ · ░ ▒ ░ ░ · ▓ ░ · ▒ ░ ░ · · ░ ▒ ░ · ░ ▒ · · ▒ ░ · ▒ ░ ░ ▒ ░ · ░ ░ · ▒ ░ ░ ░ ·
     · ░ · · · · ░ · · · · · · · · ░ · · · · · · · · ░ · · · · · · · · · · · · · · ░ · · · · · · · · · ·
Wed  ▒ ░ ▓ ░ ▒ ░ █ ▓ ▒ ░ ▒ ▓ ▒ ▒ ░ █ ▒ ░ ▓ ▒ ▒ ░ · ▒ ▓ ▒ ░ ▒ ▓ ░ · ▓ ▒ ░ ▓ ▒ ▒ ▓ ▒ · ▒ ▒ ░ ▓ ▒ ▒ ▒ ·
     · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Fri  ░ · ▒ · ░ · ▓ ▒ ░ · ░ ▒ ░ ░ · ▓ ░ · ▒ ░ ░ · · ░ ▒ ░ · ░ ▒ · · ▒ ░ · ▒ ░ ░ ▒ ░ · ░ ░ · ▒ ░ ░ ░ ·
     · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Sun  · · · · · · · ░ · · · · · · · ░ · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·

     · none  ░ 1-2  ▒ 3-5  ▓ 6-9  █ 10+

## Top Active Days of Week

| Day | Commits |
| --- | ---: |
| Wed | 312 |
| Mon | 198 |
| Fri | 187 |

## Statistics

- **Avg files per commit:** 3.2
- **Avg commits per day:** 2.3

## Top Repositories

| Repository | Commits |
| --- | ---: |
| diddo-hooks | 423 |
| repolyze | 298 |
| api-service | 126 |

Terminal version uses ANSI colors instead of fill characters: gray · for none, green/yellow/magenta/red █ for increasing intensity levels.

Test plan

  • Run cargo test — 219 tests pass
  • Run cargo clippy and cargo fmt -- --check — clean
  • Launch diddo interactively, select Activity Report
  • Test all 4 period options render correctly
  • Verify colored heatmap displays correctly in terminal
  • Press E to export, verify markdown file created in CWD with correct filename and fill-character heatmap
  • Press Esc from report view, verify return to main menu
  • Verify existing menu items still work (no regressions)

Add interactive Activity Report feature with GitHub-style commit heatmap,
top active weekdays, avg files/commit, avg commits/day, and top repositories.
Includes period selection (1/3/6/12 months), colored terminal heatmap,
scrollable report view, and markdown export with fill-character heatmap.
@drugoi

drugoi commented Apr 5, 2026

Copy link
Copy Markdown
Owner

@cursor let's check it out, anything to improve?

@cursor

cursor Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

Here is what stood out from a quick review of the Activity Report work and what I changed.

Findings (things worth improving)

  • Period screen + number keys: The main menu maps 9 → jump to index 8 and 0 → index 9. The period picker only has four rows but reused the same helper, so 9/0 could move the highlight past the last row (undefined UI).
  • Export overwrite: export_markdown always wrote the same filename, so re-running export the same day replaced the file with no warning.
  • Markdown edge case: Repo names with | break pipe tables unless the cell is escaped.

What I shipped (commit 798e339 on activity-report)

  1. apply_action: JumpTo is clamped with index.min(item_count.saturating_sub(1)) so short lists (period menu) stay valid. New unit test in interactive.rs.
  2. export_markdown: If the default path exists, pick diddo_activity_N_month_DATE_2.md, _3, … (fallback uses PID after many collisions). New test in activity_report.rs.
  3. render_markdown: Escape | in repository cells (proj|wiki → proj\|wiki). New test.

cargo test (222 tests), cargo clippy -D warnings, and cargo fmt -- --check all pass. Changes are pushed to origin/activity-report.

Optional follow-ups (not implemented)

  • Avg commits per day: Currently uses calendar span (to - from); you could instead use distinct days with commits if you want “active-day average” semantics.
  • Heatmap: Very small terminals may still wrap; horizontal scroll or capping columns would be a larger UX change.
  • NO_COLOR: Respect the env var to strip ANSI in the TUI heatmap.

I could not update the PR description from here (tool reported the body is not agent-managed); the summary above is suitable to paste into the review thread on PR #23 if you want it documented there.

Open in Web Open in Cursor 

…pipes

- Clamp digit jump targets to list length so 9/0 on 4-item period select
  no longer overshoots selection
- Export writes diddo_activity_*_2.md etc. when default filename exists
  instead of overwriting; matches user expectation of non-destructive export
- Escape | in repository names in markdown table cells

Co-authored-by: Nikita Bayev <nikita@bayev.kz>
@drugoi
drugoi merged commit 2c9ab09 into main Apr 5, 2026
1 check passed
@drugoi
drugoi deleted the activity-report branch April 5, 2026 09:26
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