Skip to content

fix(sunburst-clock): respect startOfDay offset when rendering the clock#766

Merged
ErikBjare merged 2 commits intoActivityWatch:masterfrom
TimeToBuildBob:fix/sunburst-midnight-data
Feb 22, 2026
Merged

fix(sunburst-clock): respect startOfDay offset when rendering the clock#766
ErikBjare merged 2 commits intoActivityWatch:masterfrom
TimeToBuildBob:fix/sunburst-midnight-data

Conversation

@TimeToBuildBob
Copy link
Contributor

@TimeToBuildBob TimeToBuildBob commented Feb 22, 2026

Problem

Fixes #358 — the sunburst clock visualization shows no data for the period between midnight (00:00) and the user's "Start of day" setting (default 04:00).

Root Cause

The bug was a mismatch between two separate 24-hour windows:

  1. Query window (correct): SunburstClock.vue uses this.starttime = moment(date) where date is the timeperiod start, already offset-aware (e.g. 2024-01-15T04:00:00). The query correctly fetches events from 04:00 to next-day 04:00.

  2. Visualization window (wrong): sunburst-clock.ts's update() function ignored the queried range and instead called startOf('day') which resets to calendar midnight (00:00), then endOf('day') for 23:59:59. So the clock tried to display a midnight–midnight window, but only had data from 04:00 onward. Events between midnight and 04:00 were simply never fetched.

Fix

  • Pass this.starttime (the offset-aware start moment) from SunburstClock.vue into sunburst-clock.ts's update() as an optional third parameter.
  • In update(), use the provided startOfDay moment as root_start instead of resetting to calendar midnight. root_end becomes exactly 24 hours later — matching the query window.
  • Also fix the clock tick labels: instead of hard-coding ticks at hours 0, 6, 12, 18, compute them at 6-hour intervals relative to the actual start-of-day hour. With default startOfDay=04:00, ticks appear at 04:00, 10:00, 16:00, 22:00.

Backward Compatibility

If no startOfDay is passed (future callers of the update() API), behavior falls back to the original startOf('day') logic. The default startOfDay=00:00 case is also unchanged (midnight is still midnight).

Testing

  • All 34 existing tests pass (npm test)
  • Setting startOfDay to 04:00 (default) now shows activity data from midnight to 04:00 if any exists, and the clock ticks align to the correct hours
  • Setting startOfDay to 00:00 is unchanged (workaround no longer needed)

Important

Fixes sunburst clock visualization to respect user's start of day setting by adjusting start and end times in sunburst-clock.ts.

  • Behavior:
    • Pass this.starttime from SunburstClock.vue to sunburst-clock.ts's update() as an optional parameter.
    • In update(), use startOfDay for root_start and set root_end 24 hours later, matching the query window.
    • Adjust clock tick labels to compute at 6-hour intervals relative to startOfDay.
  • Backward Compatibility:
    • If startOfDay is not provided, default to startOf('day') logic.
    • Default startOfDay=00:00 behavior remains unchanged.
  • Testing:
    • All 34 existing tests pass.
    • Verified correct data display and tick alignment for startOfDay=04:00 and startOfDay=00:00.

This description was created by Ellipsis for 3432f0b. You can customize this summary. It will automatically update as commits are pushed.

The sunburst clock was ignoring the user's "Start of day" setting and
always using calendar midnight (00:00) as the start of the visualization
window. This meant the queried time range (e.g. 04:00-04:00 next day)
didn't align with the clock's visual range (00:00-23:59), causing events
between midnight and the startOfDay offset to appear missing.

Pass the starttime (already offset-aware) from SunburstClock.vue into
sunburst-clock.ts so both the data query and the visualization use the
same 24h window. Also adjust the clock tick labels to be placed at
6-hour intervals relative to the actual start-of-day hour rather than
hard-coded at 0/6/12/18.

Fixes ActivityWatch#358
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 3432f0b in 8 seconds. Click for details.
  • Reviewed 61 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_cohlSwGiHh6xW7vf

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.60%. Comparing base (934daca) to head (3f97f87).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/visualizations/sunburst-clock.ts 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #766      +/-   ##
==========================================
- Coverage   25.67%   25.60%   -0.08%     
==========================================
  Files          30       30              
  Lines        1741     1746       +5     
  Branches      316      319       +3     
==========================================
  Hits          447      447              
+ Misses       1272     1233      -39     
- Partials       22       66      +44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 22, 2026

Greptile Summary

Fixes sunburst clock to correctly display activity data when using a non-midnight startOfDay setting. Previously, the visualization queried the correct offset-aware 24-hour window but rendered it against a midnight-to-midnight timeline, causing data between midnight and the start-of-day offset to appear missing. The fix passes the offset-aware start time through to the rendering function and dynamically positions clock ticks at 6-hour intervals relative to the actual start-of-day.

Key changes:

  • Pass starttime (offset-aware moment) from SunburstClock.vue to the update() function
  • Use the provided startOfDay parameter instead of always resetting to calendar midnight
  • Calculate clock ticks dynamically based on the actual start hour rather than hardcoding 0, 6, 12, 18
  • Maintain backward compatibility with optional parameter and fallback behavior

Confidence Score: 5/5

  • Safe to merge - clean bug fix with correct implementation
  • The changes correctly address the root cause by aligning the visualization window with the query window. The implementation handles edge cases properly (minutes in start time, modulo for wraparound), maintains backward compatibility, and passes existing tests. The fix is minimal, focused, and well-explained.
  • No files require special attention

Important Files Changed

Filename Overview
src/visualizations/SunburstClock.vue Passes offset-aware starttime to visualization update function - straightforward and correct
src/visualizations/sunburst-clock.ts Implements offset-aware clock rendering with proper fallback, correctly calculates tick positions at 6-hour intervals

Last reviewed commit: 3432f0b

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@TimeToBuildBob
Copy link
Contributor Author

The Test (node-20, py-3.9, aw-server-rust master) check failure is a pre-existing upstream issue — the cleanup step tries to glob ~/.cache/activitywatch/log/*/*.log but aw-server-rust master doesn't write logs to that path. All actual test steps (unit tests, e2e) pass. Unrelated to this PR's changes.

@ErikBjare
Copy link
Member

Also fix the clock tick labels: instead of hard-coding ticks at hours 0, 6, 12, 18, compute them at 6-hour intervals relative to the actual start-of-day hour. With default startOfDay=04:00, ticks appear at 04:00, 10:00, 16:00, 22:00.

I think this will look weird, ticks should be at "normal" tick positions for analog clocks, not relative to the startOfDay. But maybe add a special tick for "start of day"/"previous day"/"next day"? Idk what would look best here, but clearly some indication is needed to not confuse users.

…ay marker

Keep 6-hour ticks at standard positions (00:00, 06:00, 12:00, 18:00) for
analog-clock familiarity. Add a special ☀ marker for the start-of-day
boundary when it differs from midnight (e.g. 04:00 ☀ for the default setting).
@TimeToBuildBob
Copy link
Contributor Author

Good call — updated in 3f97f87: ticks now stay at standard 24h positions (00:00, 06:00, 12:00, 18:00) like a normal analog clock, while the start-of-day boundary gets a special ☀ label (e.g. 04:00 ☀ with the default setting). That way the clock stays navigable while still showing where the day boundary is.

@ErikBjare ErikBjare merged commit 86a71c8 into ActivityWatch:master Feb 22, 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.

Sunburst clock is not showing data after midnight

2 participants