Skip to content

feat: add work time report view#775

Open
TimeToBuildBob wants to merge 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:feat/work-report-view
Open

feat: add work time report view#775
TimeToBuildBob wants to merge 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:feat/work-report-view

Conversation

@TimeToBuildBob
Copy link
Contributor

@TimeToBuildBob TimeToBuildBob commented Feb 27, 2026

Summary

  • Adds a Work Report view with daily work time breakdowns, multi-device support, category filtering, configurable break time (flood-based gap merging), and CSV/JSON export
  • Accessible from the Tools dropdown menu in the header
  • Based on feat: added workreport view #742 by @ErikBjare, taken over per request

Changes from #742

  • Implemented thisWeek and thisMonth date ranges (were TODO)
  • Removed debug console.log statements
  • Used safeHost consistently in find_bucket queries (Ellipsis review suggestion)
  • ESLint auto-formatting applied

How it works

The view queries aw-watcher-window buckets per host, applies flood() to merge gaps shorter than the configured break time, categorizes events, filters by selected categories, and combines results across devices using union_no_overlap. Results are displayed as a daily breakdown table with totals.

Test plan

  • Open Work Report from Tools dropdown
  • Select hosts and categories, click Calculate
  • Verify daily breakdown shows correct data
  • Test CSV and JSON export
  • Test different date ranges (last 7d, last 30d, this week, this month)

Closes #742


Important

Adds a Work Report view with detailed work time breakdowns, multi-device support, and export options, accessible from the Tools dropdown.

  • Feature:
    • Adds WorkReport.vue for a detailed work time report view with daily breakdowns, multi-device support, category filtering, configurable break time, and CSV/JSON export.
    • Accessible from Tools dropdown in Header.vue.
  • Routing:
    • Adds route /work-report in route.js.
  • Improvements from feat: added workreport view #742:
    • Implements thisWeek and thisMonth date ranges.
    • Removes debug console.log statements.
    • Consistent use of safeHost in queries.
    • Applies ESLint auto-formatting.

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

Add a new Work Report view that provides daily work time breakdowns
with multi-device support, category filtering, configurable break time
(gap merging via flood), and CSV/JSON export.

Based on ActivityWatch#742 by @ErikBjare. Changes from original:
- Implemented thisWeek and thisMonth date ranges
- Removed debug console.log statements
- Used safeHost consistently in find_bucket queries

Closes ActivityWatch#742
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 88123f9 in 14 seconds. Click for details.
  • Reviewed 373 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_dYhmm0zRl5puWjmN

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 (88123f9).

Files with missing lines Patch % Lines
src/route.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #775      +/-   ##
==========================================
- Coverage   25.71%   25.69%   -0.02%     
==========================================
  Files          30       30              
  Lines        1750     1751       +1     
  Branches      307      307              
==========================================
  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 adds a comprehensive Work Time Report feature that provides daily work time breakdowns across multiple devices with configurable break times and category filtering. The implementation includes CSV/JSON export capabilities and supports various date ranges (last 7/30 days, this week, this month).

Major Changes:

  • Added Work Report view accessible from Tools dropdown menu
  • Implemented multi-device query aggregation using union_no_overlap
  • Applied flood-based gap merging to count short breaks as work time
  • Added category filtering to focus on specific work types
  • Implemented CSV and JSON export functionality

Critical Issue Found:

  • Line 184: Bucket lookup uses sanitized hostname (safeHost) instead of original hostname, which will fail for hosts with special characters like hyphens (e.g., "my-laptop" → "mylaptop")

Code Quality:

  • Clean implementation with proper TypeScript interfaces
  • Good separation of concerns between UI and data processing
  • Follows existing patterns in the codebase

Confidence Score: 2/5

  • This PR has a critical bug that will break functionality for common hostname patterns
  • While the overall implementation is well-structured, the bucket lookup bug on line 184 is critical and will cause the feature to fail for any hostname containing special characters (very common with hyphens). This must be fixed before merge.
  • Pay close attention to src/views/WorkReport.vue - the bucket lookup logic must be corrected before merging

Important Files Changed

Filename Overview
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
src/views/WorkReport.vue New work time report view with multi-device support, category filtering, and export - contains critical bucket lookup bug

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User Selects Hosts & Categories] --> B[Click Calculate Work Time]
    B --> C[Get Time Periods Based on Date Range]
    C --> D{For Each Host}
    D --> E[Query aw-watcher-window Bucket]
    E --> F[Apply flood to Merge Gaps < Break Time]
    F --> G[Categorize Events]
    G --> H[Filter by Selected Categories]
    H --> I[Store as events_hostname]
    I --> D
    D --> J[Combine All Host Events via union_no_overlap]
    J --> K[Calculate Duration & Session Count]
    K --> L[Map to Daily Breakdown]
    L --> M[Display Table with Totals]
    M --> N{User Action}
    N -->|Export CSV| O[Generate CSV File]
    N -->|Export JSON| P[Generate JSON File]
    N -->|Done| Q[End]
    O --> Q
    P --> Q
Loading

Last reviewed commit: 88123f9

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

for (const hostname of this.selectedHosts) {
const safeHost = hostname.replace(/[^a-zA-Z0-9_]/g, '');
query += `
events_${safeHost} = flood(query_bucket(find_bucket("aw-watcher-window_${safeHost}")), ${breakTimeSeconds});
Copy link
Contributor

Choose a reason for hiding this comment

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

safeHost used in find_bucket() won't match actual bucket IDs when hostnames contain special characters (e.g., "my-laptop" becomes "mylaptop"). Use original hostname variable instead.

Suggested change
events_${safeHost} = flood(query_bucket(find_bucket("aw-watcher-window_${safeHost}")), ${breakTimeSeconds});
events_${safeHost} = flood(query_bucket(find_bucket("aw-watcher-window_${hostname}")), ${breakTimeSeconds});

@ErikBjare
Copy link
Member

Duplicate of #774, decide which to keep and which to close. Figure out if any differences should be transferred.

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