Skip to content

feat(views): add WorkReport view with fixed date range handling#774

Closed
TimeToBuildBob wants to merge 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:bob/work-report-fix
Closed

feat(views): add WorkReport view with fixed date range handling#774
TimeToBuildBob wants to merge 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:bob/work-report-fix

Conversation

@TimeToBuildBob
Copy link
Contributor

@TimeToBuildBob TimeToBuildBob commented Feb 27, 2026

Continuation of #742 (taking over as requested by @ErikBjare).

Adds the Work Report view with two critical bugs fixed:

Fixes

1. startOfDay offset parsing bug (fixes Greptile finding)

The startOfDay setting returns a string like "04:00" but was passed directly to moment().add(offset), which expects a number+unit pair. This caused a runtime error when calculating timeperiods.

Fix: Parse the "HH:MM" string into hours and minutes, then apply separately:

const [offsetHours, offsetMinutes] = offsetStr.split(':').map(Number);
const start = m.add(offsetHours, 'hours').add(offsetMinutes, 'minutes');

2. Missing date range implementations (fixes Greptile finding)

thisWeek, thisMonth, and custom were shown in the dropdown but fell through to an empty array in getTimeperiods().

Fix: All five date ranges are now implemented. The custom option also gets proper date picker inputs (with defaults of last 7 days).

Changes

  • src/views/WorkReport.vue — new view (fixes from feat: added workreport view #742)
  • src/components/Header.vue — adds "Work Report" to Tools dropdown
  • src/route.js — adds /work-report route

Closes #742 (supersedes it with bug fixes applied).


Important

Adds WorkReport.vue with fixed date range handling, integrates it into the app, and fixes critical bugs.

  • Behavior:
    • Adds WorkReport.vue for work time reporting with fixed date range handling.
    • Fixes startOfDay offset parsing bug by parsing "HH:MM" into hours and minutes.
    • Implements missing date ranges thisWeek, thisMonth, and custom in getTimeperiods().
  • Integration:
    • Adds "Work Report" to Tools dropdown in Header.vue.
    • Adds /work-report route in route.js.

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

Fixes two bugs from the initial implementation in ActivityWatch#742:

- Fix startOfDay offset parsing: the settings value is "HH:MM" string
  but was passed raw to moment().add(), which expects a number+unit.
  Now parsed as [hours, minutes] and added separately.

- Implement all date range options: thisWeek, thisMonth, and custom
  were advertised in the UI but not implemented in getTimeperiods().
  All five options now work correctly.

Also adds date picker inputs for the custom range, with sensible
defaults (last 7 days).

Co-Authored-By: Bob <timetobuildbob@gmail.com>
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 6745a6b in 12 seconds. Click for details.
  • Reviewed 425 lines of code in 3 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_7CvNIBV2HwVdEq3V

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 27, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 25.69%. Comparing base (1db85aa) to head (6745a6b).

Files with missing lines Patch % Lines
src/route.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #774      +/-   ##
==========================================
- Coverage   25.71%   25.69%   -0.02%     
==========================================
  Files          30       30              
  Lines        1750     1751       +1     
  Branches      307      320      +13     
==========================================
  Hits          450      450              
- Misses       1278     1279       +1     
  Partials       22       22              

☔ 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 27, 2026

Greptile Summary

This PR successfully adds a Work Report view that allows users to track work time across multiple devices with flexible date range filtering and export capabilities. The implementation fixes two critical bugs from the previous attempt:

Fixes Applied:

  • Fixed startOfDay offset parsing - now correctly parses "HH:MM" format into hours and minutes before applying to moment objects
  • Implemented all missing date ranges (thisWeek, thisMonth, custom) that were previously unhandled

Key Features:

  • Multi-host querying with automatic device selection
  • Category-based filtering with multi-select support
  • Configurable break time for session flooding (gaps shorter than break time are counted as continuous work)
  • Five date range options including custom date picker
  • Daily breakdown table with session statistics
  • CSV and JSON export functionality

Minor Issue:

  • The startOfDay parsing on line 259 could crash if the setting is undefined (though the default is '04:00'). Consider adding defensive null check or using existing utility functions from ~/util/time.ts.

Confidence Score: 4/5

  • Safe to merge with one minor defensive programming suggestion
  • The code is well-structured and fixes the critical bugs mentioned in the PR description. All date range implementations are correct, the query building logic properly handles multiple hosts, and the UI provides good user experience. Score of 4 (not 5) due to the potential crash on line 259 if startOfDay is undefined, though this is unlikely given the default value.
  • Pay attention to src/views/WorkReport.vue line 259 - add null check for startOfDay setting

Important Files Changed

Filename Overview
src/views/WorkReport.vue New work report view with multi-host querying, date range filtering, and CSV/JSON export. Fixes critical bugs from #742 including startOfDay parsing and missing date range implementations.
src/components/Header.vue Adds Work Report menu item to Tools dropdown with briefcase icon
src/route.js Registers /work-report route with lazy-loaded WorkReport component

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User Opens Work Report] --> B[Load Stores: Categories, Buckets, Settings]
    B --> C[Auto-select All Available Hosts]
    C --> D[User Configures Filters]
    D --> E{User Clicks Calculate}
    E --> F[Validate Inputs]
    F --> G{Hosts Selected?}
    G -->|No| H[Show Error: Select Host]
    G -->|Yes| I[Get Timeperiods with startOfDay Offset]
    I --> J{Valid Date Range?}
    J -->|No| K[Show Error: Invalid Range]
    J -->|Yes| L[Build Query for Each Host]
    L --> M[Query: flood → categorize → filter_keyvals]
    M --> N[Combine Events with union_no_overlap]
    N --> O[Execute Query for Each Day]
    O --> P[Process Results into Daily Data]
    P --> Q[Display Daily Breakdown Table]
    Q --> R{User Action}
    R -->|Export CSV| S[Generate CSV File]
    R -->|Export JSON| T[Generate JSON File]
    R -->|Recalculate| E
    S --> U[Download File]
    T --> U
Loading

Last reviewed commit: 6745a6b

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.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +259 to +260
const offsetStr = this.settingsStore.startOfDay as string;
const [offsetHours, offsetMinutes] = offsetStr.split(':').map(Number);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add null check before parsing startOfDay. If the setting is undefined, this will crash. Consider using the existing utility functions like get_day_start_with_offset() from ~/util/time or add a fallback:

Suggested change
const offsetStr = this.settingsStore.startOfDay as string;
const [offsetHours, offsetMinutes] = offsetStr.split(':').map(Number);
const offsetStr = (this.settingsStore.startOfDay as string) || '04:00';
const [offsetHours, offsetMinutes] = offsetStr.split(':').map(Number);

Copy link
Member

Choose a reason for hiding this comment

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

Probably use get_day_start_with_offset

@ErikBjare ErikBjare mentioned this pull request Feb 27, 2026
5 tasks
@TimeToBuildBob
Copy link
Contributor Author

Closing in favor of #775, which is the proper takeover of Erik's #742 with the same changes plus my improvements (implemented thisWeek/thisMonth ranges, removed debug logs, consistent safeHost usage).

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.

2 participants