Skip to content

fix(timeline): bound Daily Timeline scrolling to the queried day - #998

Open
0xbrayo wants to merge 2 commits into
ActivityWatch:masterfrom
0xbrayo:fix/daily-timeline-scroll-bounds
Open

0xbrayo wants to merge 2 commits into
ActivityWatch:masterfrom
0xbrayo:fix/daily-timeline-scroll-bounds

Conversation

@0xbrayo

@0xbrayo 0xbrayo commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Fixes #996.

Problem

The "Daily Timeline (Chronological)" visualization on /#/activity can be scrolled far past the start and end of the day it shows, where there's nothing to see.

VisTimeline.update() only set vis-timeline's min/max options when updateTimelineWindow was passed. Only Timeline.vue passes it; SelectableVisualization.vue passes queriedInterval but not the flag. So once events loaded, the Activity page's timeline had no scroll limits. (The empty-data branch did set min/max from queriedInterval, so the bounds depended on which branch happened to run last.)

Change

  • Set options.min/options.max from queriedInterval whenever it is provided (as well as when updateTimelineWindow is set, same as before).
  • Reset the visible window with setWindow() when updateTimelineWindow is set (as before) or when the bounds actually change. vis-timeline's Range.setOptions stores new min/max without re-applying the current range, so without this a view zoomed into one day would stay there after switching days. Re-rendering the same interval (e.g. a data refresh) keeps the user's zoom.

Callers without a queriedInterval (Bucket view, Report, search results) behave the same as before.

Tests

Added regression tests to test/unit/VisTimeline.test.js for update():

  • bounds get set from queriedInterval without updateTimelineWindow (fails before this change)
  • re-rendering the same interval keeps the zoomed window
  • changing the queried day moves the window to the new day
  • with updateTimelineWindow, bounds are set and the window is reset
  • without a queriedInterval, no bounds are set

VisTimeline only set the vis-timeline min/max options when
updateTimelineWindow was passed, which only the Timeline view does. The
Daily Timeline visualization on the Activity page passes a queried
interval but not that flag, so once events loaded it could be scrolled
far outside the day it renders.

Set min/max from the queried interval whenever one is provided, and keep
only the setWindow() reset behind updateTimelineWindow.

Fixes ActivityWatch#996
@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.66%. Comparing base (23c95ed) to head (fdccd01).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #998   +/-   ##
=======================================
  Coverage   57.66%   57.66%           
=======================================
  Files          51       51           
  Lines        3231     3231           
  Branches      794      794           
=======================================
  Hits         1863     1863           
- Misses       1291     1352   +61     
+ Partials       77       16   -61     

☔ View full report in Codecov by Harness.
📢 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

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no outstanding finding or new actionable issue was identified.

Summary

The PR bounds the Daily Timeline to its queried day and resets the visible window when those bounds change.

  • Same-day updates preserve the user’s zoom.
  • Unit tests cover initial bounds, same-day updates, day changes, and callers without a queried interval.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Timeline update] --> B{Queried interval or window update?}
  B -- No --> C[Leave bounds unchanged]
  B -- Yes --> D[Set min and max]
  D --> E{Window update requested or bounds changed?}
  E -- Yes --> F[Show the new interval]
  E -- No --> G[Preserve the current zoom]
Loading

Reviews (2) · Last reviewed commit: "fix(timeline): reset the visible window ..."

Comment thread test/unit/VisTimeline.test.js
vis-timeline doesn't re-clamp the visible window when min/max change, so
a Daily Timeline left zoomed into one day would stay on it after
switching days. Reset the window whenever the bounds move, and keep the
user's zoom when the same interval is re-rendered.
@0xbrayo

0xbrayo commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

🤖 Claude, on behalf of @0xbrayo

@greptile review

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.

"Daily Timeline" visualization allows useless scrolling beyond day boundaries until /#/timeline is visited

1 participant