From ca0f0086b472d554de3783eb299e998efa70b96b Mon Sep 17 00:00:00 2001
From: Dries Peeters
Date: Sun, 15 Nov 2026 16:54:34 +0100
Subject: [PATCH] feat(time-tracking): close remaining autotracker, Focus, and
Belgium gaps
Ship desktop activity capture with local storage and ActivityWatch bridge, make Solo Focus the default lean packaging across setup and clients, and add Belgium attendance history/corrections UI on desktop and mobile.
---
app/routes/setup.py | 9 +-
app/templates/admin/modules.html | 8 +-
app/templates/main/dashboard.html | 22 +-
app/templates/setup/initial_setup.html | 2 +-
app/utils/module_registry.py | 9 +-
desktop/src/main/activity-tracker.js | 444 +++++++++++++++++-
desktop/src/main/main.js | 70 ++-
desktop/src/main/preload.js | 7 +
desktop/src/renderer-react/src/i18n/en.json | 18 +-
desktop/src/renderer-react/src/main.jsx | 10 +-
.../src/renderer-react/src/services/api.js | 25 +
.../src/views/ComplianceView.jsx | 184 ++++++++
.../renderer-react/src/views/SettingsView.jsx | 164 ++++++-
.../src/renderer-react/src/views/Shell.jsx | 42 +-
.../renderer-react/src/views/WorkdayCard.jsx | 3 +
.../src/views/WorkforceView.jsx | 4 +-
desktop/test/activity_tracker.test.js | 68 +++
desktop/test/compliance_view.test.js | 21 +
desktop/test/react_parity.test.js | 3 +
docs/competitive-analysis/GAP_RUBRIC.md | 4 +-
docs/design/DESKTOP_ACTIVITY_AUTOTRACKER.md | 29 +-
.../mobile-desktop-apps/DESKTOP_WEBAPP_GAP.md | 4 +-
.../presentation/widgets/workday_card.dart | 9 +
tests/test_module_presets.py | 11 +-
24 files changed, 1113 insertions(+), 57 deletions(-)
create mode 100644 desktop/src/renderer-react/src/views/ComplianceView.jsx
create mode 100644 desktop/test/activity_tracker.test.js
create mode 100644 desktop/test/compliance_view.test.js
diff --git a/app/routes/setup.py b/app/routes/setup.py
index ed3cf0a23..f20829316 100644
--- a/app/routes/setup.py
+++ b/app/routes/setup.py
@@ -169,8 +169,11 @@ def _module_preset_choices():
choices = [
(
ModulePreset.SOLO.value,
- _("Just me"),
- _("Track time, organise it by project and client, and bill it. The leanest setup."),
+ _("Focus mode (just me)"),
+ _(
+ "Timer-first: track time, Focus/Pomodoro sessions, weekly goals, "
+ "projects, clients, and invoices. Hides CRM, inventory, and team tools."
+ ),
),
(
ModulePreset.TEAM.value,
@@ -209,7 +212,7 @@ def _render_setup(settings, timezones):
settings=settings,
timezones=timezones,
module_presets=_module_preset_choices(),
- default_module_preset=ModulePreset.TEAM.value,
+ default_module_preset=ModulePreset.SOLO.value,
rounding_methods=get_available_rounding_methods(),
rounding_minimums=get_available_minimum_durations(),
)
diff --git a/app/templates/admin/modules.html b/app/templates/admin/modules.html
index 0ddf91f82..22c2ee7e2 100644
--- a/app/templates/admin/modules.html
+++ b/app/templates/admin/modules.html
@@ -96,11 +96,17 @@ {{ _('Quick presets') }}
{{ _('Apply a module preset (e.g. Solo focus disables CRM, inventory, and other non-essential areas).') }}
+ {% set preset_labels = {
+ 'solo': _('Focus (Solo)'),
+ 'team': _('Team'),
+ 'compliance': _('Compliance'),
+ 'everything': _('Everything')
+ } %}
{% for preset in ['solo', 'team', 'compliance', 'everything'] %}
{% endfor %}
diff --git a/app/templates/main/dashboard.html b/app/templates/main/dashboard.html
index ad955465b..46ad84ecf 100644
--- a/app/templates/main/dashboard.html
+++ b/app/templates/main/dashboard.html
@@ -28,6 +28,23 @@
{% set dashboard_breadcrumbs = [{'text': _('Dashboard')}] %}
{{ page_header('fas fa-tachometer-alt', _('Dashboard'), _("Here's a quick overview of your work."), breadcrumbs=dashboard_breadcrumbs) }}
+{% if not is_module_enabled('deals') and not is_module_enabled('inventory') %}
+
@@ -148,6 +148,26 @@ export function AuthFlow(props) {
);
}
+/** Map desktop views to server module ids (any match keeps the item visible). */
+export const VIEW_MODULE_REQUIREMENTS = {
+ dashboard: ['main'],
+ projects: ['projects'],
+ entries: ['timer'],
+ kanban: ['kanban'],
+ reports: ['reports'],
+ crm: ['deals', 'contacts', 'leads'],
+ invoices: ['invoices'],
+ expenses: ['expenses'],
+ payments: ['payments'],
+ mileage: ['mileage'],
+ quotes: ['quotes'],
+ recurring: ['recurring_invoices'],
+ credit: ['invoices'],
+ // Workday / Belgium attendance is not a separate module; always offer Workforce.
+ workforce: null,
+ settings: null,
+};
+
export const NAV_GROUPS = [
{
labelKey: 'nav.groups.work',
@@ -185,7 +205,23 @@ export const NAV_GROUPS = [
},
];
-export function Sidebar({ activeView, onChange }) {
+export function isViewEnabled(viewId, enabledModules) {
+ const req = VIEW_MODULE_REQUIREMENTS[viewId];
+ if (req == null) return true;
+ if (!Array.isArray(enabledModules) || enabledModules.length === 0) return true;
+ const set = new Set(enabledModules);
+ return req.some((m) => set.has(m));
+}
+
+export function filterNavGroups(enabledModules) {
+ return NAV_GROUPS.map((group) => ({
+ ...group,
+ items: group.items.filter((item) => isViewEnabled(item.id, enabledModules)),
+ })).filter((group) => group.items.length > 0);
+}
+
+export function Sidebar({ activeView, onChange, enabledModules }) {
+ const groups = filterNavGroups(enabledModules);
return (
@@ -196,7 +232,7 @@ export function Sidebar({ activeView, onChange }) {
- {NAV_GROUPS.map((group) => (
+ {groups.map((group) => (
{t(group.labelKey)}
{group.items.map((view) => (
diff --git a/desktop/src/renderer-react/src/views/WorkdayCard.jsx b/desktop/src/renderer-react/src/views/WorkdayCard.jsx
index cd0bac8ba..80c644308 100644
--- a/desktop/src/renderer-react/src/views/WorkdayCard.jsx
+++ b/desktop/src/renderer-react/src/views/WorkdayCard.jsx
@@ -45,6 +45,9 @@ export function WorkdayCard({ attendance, loading, onAction }) {
{!attendance && !loading && }
+
+ History, corrections, and Belgium reports are under Workforce.
+
);
}
diff --git a/desktop/src/renderer-react/src/views/WorkforceView.jsx b/desktop/src/renderer-react/src/views/WorkforceView.jsx
index 5b6f6ed80..81f273a81 100644
--- a/desktop/src/renderer-react/src/views/WorkforceView.jsx
+++ b/desktop/src/renderer-react/src/views/WorkforceView.jsx
@@ -1,6 +1,7 @@
import React from 'react';
import { classifyAxiosError } from '../services/api.js';
import { Panel, SkeletonGrid, StatCard, ViewHeader } from '../components/ui.jsx';
+import { CompliancePanel } from './ComplianceView.jsx';
export function WorkforceView({
workforce,
@@ -31,13 +32,14 @@ export function WorkforceView({
Refresh
}
/>
+
{loading ? (
) : (
diff --git a/desktop/test/activity_tracker.test.js b/desktop/test/activity_tracker.test.js
new file mode 100644
index 000000000..e78bbe256
--- /dev/null
+++ b/desktop/test/activity_tracker.test.js
@@ -0,0 +1,68 @@
+'use strict';
+
+const { describe, it } = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('fs');
+const os = require('os');
+const path = require('path');
+
+const tracker = require('../src/main/activity-tracker');
+
+describe('activity-tracker helpers', () => {
+ it('isExcluded matches app or title substrings case-insensitively', () => {
+ assert.equal(tracker.isExcluded('Chrome', 'Inbox', ['bank']), false);
+ assert.equal(tracker.isExcluded('1Password', 'Vault', ['password']), true);
+ assert.equal(tracker.isExcluded('Code', 'secret-notes.md', ['SECRET']), true);
+ assert.equal(tracker.isExcluded('Slack', 'general', []), false);
+ });
+
+ it('pruneSamples drops entries older than retention', () => {
+ const now = Date.now();
+ const samples = [
+ { timestamp: new Date(now - 20 * 86400000).toISOString(), app: 'old' },
+ { timestamp: new Date(now - 2 * 86400000).toISOString(), app: 'recent' },
+ ];
+ const kept = tracker.pruneSamples(samples, 7);
+ assert.equal(kept.length, 1);
+ assert.equal(kept[0].app, 'recent');
+ });
+
+ it('purgeLocal clears the sample file under userDataPath', () => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tt-activity-'));
+ const fakeStore = {
+ data: { activity_tracker_enabled: false },
+ get(key, def) {
+ return Object.prototype.hasOwnProperty.call(this.data, key) ? this.data[key] : def;
+ },
+ set(key, value) {
+ this.data[key] = value;
+ },
+ };
+ tracker.start({ store: fakeStore, userDataPath: dir });
+ const file = path.join(dir, 'activity-samples.json');
+ fs.writeFileSync(
+ file,
+ JSON.stringify({
+ samples: [{ timestamp: new Date().toISOString(), app: 'x', title: 'y', duration: 1 }],
+ })
+ );
+ const result = tracker.purgeLocal();
+ assert.equal(result.purged, true);
+ const raw = JSON.parse(fs.readFileSync(file, 'utf8'));
+ assert.deepEqual(raw.samples, []);
+ tracker.stop();
+ });
+
+ it('start respects feature flag off', () => {
+ const fakeStore = {
+ get(key, def) {
+ if (key === 'activity_tracker_enabled') return false;
+ return def;
+ },
+ };
+ const result = tracker.start({ store: fakeStore, userDataPath: os.tmpdir() });
+ assert.equal(result.started, false);
+ assert.equal(result.reason, 'feature_flag_off');
+ assert.equal(tracker.isEnabled(), false);
+ });
+});
diff --git a/desktop/test/compliance_view.test.js b/desktop/test/compliance_view.test.js
new file mode 100644
index 000000000..993704595
--- /dev/null
+++ b/desktop/test/compliance_view.test.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const { test } = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('fs');
+const path = require('path');
+
+test('desktop ComplianceView and Workforce wire Belgium attendance APIs', () => {
+ const root = path.join(__dirname, '..');
+ const compliance = fs.readFileSync(path.join(root, 'src/renderer-react/src/views/ComplianceView.jsx'), 'utf8');
+ const workforce = fs.readFileSync(path.join(root, 'src/renderer-react/src/views/WorkforceView.jsx'), 'utf8');
+ const api = fs.readFileSync(path.join(root, 'src/renderer-react/src/services/api.js'), 'utf8');
+
+ assert.match(compliance, /getBelgiumAttendanceReport/);
+ assert.match(compliance, /requestAttendanceCorrection/);
+ assert.match(compliance, /getAttendanceHistory/);
+ assert.match(workforce, /CompliancePanel/);
+ assert.match(api, /\/api\/v1\/attendance\/history/);
+ assert.match(api, /\/api\/v1\/attendance\/corrections/);
+ assert.match(api, /belgium-attendance/);
+});
diff --git a/desktop/test/react_parity.test.js b/desktop/test/react_parity.test.js
index ad38a4737..5fe9d8661 100644
--- a/desktop/test/react_parity.test.js
+++ b/desktop/test/react_parity.test.js
@@ -19,6 +19,9 @@ test('React API client exposes pause/resume timer methods', () => {
test('React API client exposes attendance/workday methods', () => {
assert.match(apiSource, /getAttendanceStatus/);
assert.match(apiSource, /\/api\/v1\/attendance\/status/);
+ assert.match(apiSource, /getAttendanceHistory/);
+ assert.match(apiSource, /requestAttendanceCorrection/);
+ assert.match(apiSource, /getBelgiumAttendanceReport/);
assert.match(apiSource, /startWorkday/);
assert.match(apiSource, /\/api\/v1\/workday\/start/);
assert.match(apiSource, /endWorkday/);
diff --git a/docs/competitive-analysis/GAP_RUBRIC.md b/docs/competitive-analysis/GAP_RUBRIC.md
index a2ba5f4bc..b1400b493 100644
--- a/docs/competitive-analysis/GAP_RUBRIC.md
+++ b/docs/competitive-analysis/GAP_RUBRIC.md
@@ -134,7 +134,7 @@ This document scores each missing or underpowered capability from the Competitiv
| Rank | Capability | Priority | Phase suggestion | Status (2026-11) |
|------|------------|----------|------------------|------------------|
-| 1 | Focus mode packaging for solo users | 7.00 | Phase 1 (quick) | Partial — Pomodoro/focus exists; solo packaging polish remains |
+| 1 | Focus mode packaging for solo users | 7.00 | Phase 1 (quick) | Done — Solo default + Focus copy; weekly goals/templates in Solo; desktop nav respects enabled_modules |
| 2 | Mileage GPS UI/routes (backend done) | 5.00 | Phase 1 (quick) | **Done** — web + API GPS mileage |
| 3 | Payroll-ready exports and payroll connectors | 4.50 | Phase 1 | **Done** — templates, CSV/XLSX, Gusto/ADP; API template-aware export in Phase 6 |
| 4 | Mobile/desktop parity (invoicing, expenses, reporting) | 3.00 | Phase 1 | Partial — desktop strong; mobile hubs expanding (Phase 6 polish) |
@@ -142,7 +142,7 @@ This document scores each missing or underpowered capability from the Competitiv
| 6 | Recurring cost engine | 2.50 | Phase 1 or 2 | **Done** |
| 7 | PTO/leave and time-off workflow | 2.33 | Phase 2 | **Done** — accrual, holidays, approvals |
| 8 | Native accounting depth | 1.50 | Backlog | Partial — QBO/Xero outbound; bank reconciliation in Phase 6 |
-| 9 | Automated activity capture parity | 1.40 | Backlog | Partial — ActivityWatch import; native desktop agent in Phase 6 |
+| 9 | Automated activity capture parity | 1.40 | Backlog | Done — ActivityWatch import + desktop agent Phases B–D (opt-in local capture + AW bridge) |
| 10 | Field workforce controls | 0.80 | Backlog | Substantial — geofencing + workday enforcement shipped |
---
diff --git a/docs/design/DESKTOP_ACTIVITY_AUTOTRACKER.md b/docs/design/DESKTOP_ACTIVITY_AUTOTRACKER.md
index 960f5c285..384c129fe 100644
--- a/docs/design/DESKTOP_ACTIVITY_AUTOTRACKER.md
+++ b/docs/design/DESKTOP_ACTIVITY_AUTOTRACKER.md
@@ -1,6 +1,6 @@
# Desktop activity autotracker
-Privacy-first local activity sampling for the Electron desktop client. Design only in Phase 6; capture implementation is a follow-up.
+Privacy-first local activity sampling for the Electron desktop client. Phase A stub shipped in Phase 6; Phases B–D (capture, AW bridge, settings UI) are implemented in the desktop client.
## Goals
@@ -54,27 +54,27 @@ The server already maps window/app events through `activitywatch_rule.py` into `
- Wired from `main.js` behind store flag `activity_tracker_enabled` (default false).
- **No** OS window capture yet; `start` is a no-op sampler placeholder.
-### Phase B — Local capture
+### Phase B — Local capture (done)
-- Implement platform-specific active-window readers (e.g. Windows UI Automation / `GetForegroundWindow`, macOS Accessibility, Linux X11/Wayland best-effort).
-- Persist samples locally with interval, app, title, idle flag.
-- Exclusion list + purge APIs via IPC.
+- Platform-specific active-window readers: Windows (`GetForegroundWindow` via PowerShell), macOS (Accessibility via `osascript`), Linux X11 (`xdotool`/`xprop`; Wayland best-effort / no-op when unavailable).
+- Persist samples under Electron `userData` (`activity-samples.json`) with interval, app, title, idle flag.
+- Exclusion list + purge APIs via IPC (`activity-tracker:*`).
-### Phase C — ActivityWatch bridge
+### Phase C — ActivityWatch bridge (done)
-- Map local samples to AW bucket/event JSON.
-- Optional push into configured ActivityWatch HTTP API **on localhost**, or direct export file the existing connector can import.
+- Map local samples to AW bucket/event JSON (`timestamp`, `duration`, `data.app`/`title`/`url`).
+- Optional push into configured ActivityWatch HTTP API **on localhost** (default `127.0.0.1:5600`).
- Prefer localhost AW so the server path remains unchanged.
-### Phase D — Product polish
+### Phase D — Product polish (done)
-- Desktop settings UI for opt-in, interval, exclusions, purge, sync status.
-- Telemetry only for aggregate “enabled/disabled” counts if product telemetry is already consented—never titles/apps.
+- Desktop Settings panel: opt-in, interval, exclusions, retention, AW sync, purge, sync-now, status.
+- Titles/apps are never logged in production; debug only with `TIMETRACKER_DEBUG_ACTIVITY=1`.
## Feature flag
- Store key: `activity_tracker_enabled` (boolean, default `false`).
-- Additional keys (later): `activity_tracker_interval_sec`, `activity_tracker_exclusions`.
+- Additional keys: `activity_tracker_interval_sec`, `activity_tracker_exclusions`, `activity_tracker_retention_days`, `activity_tracker_aw_sync`, `activity_tracker_aw_host`, `activity_tracker_aw_port`.
## Security notes
@@ -84,6 +84,5 @@ The server already maps window/app events through `activitywatch_rule.py` into `
## Follow-ups
-- Actual window capture bindings per OS.
-- Settings UI strings and privacy help article.
-- Tests for local retention/purge and exclusion matching.
+- Wayland-native capture when APIs stabilize.
+- Optional privacy help article in docs site.
diff --git a/docs/mobile-desktop-apps/DESKTOP_WEBAPP_GAP.md b/docs/mobile-desktop-apps/DESKTOP_WEBAPP_GAP.md
index f13506c63..a3b94bbde 100644
--- a/docs/mobile-desktop-apps/DESKTOP_WEBAPP_GAP.md
+++ b/docs/mobile-desktop-apps/DESKTOP_WEBAPP_GAP.md
@@ -30,7 +30,7 @@ Living checklist for bringing the Electron desktop client up to speed with the F
| Timer pause/resume | Yes | Yes | Done |
| Reports summary UI | Yes | Partial | Done |
| Workday clock in/out + breaks | Yes | Yes | Done |
-| Belgium compliance / corrections UI | Yes | Partial | Deferred |
+| Belgium compliance / corrections UI | Yes | Yes (history/corrections + report) | Done (Workforce panel) |
| Kanban board | Yes | Yes | Done |
| CRM (leads/deals/contacts/notes) | Yes | Yes (hub) | Done |
| Payments, mileage, quotes, recurring, credit notes | Yes | Partial | Done |
@@ -50,4 +50,4 @@ Living checklist for bringing the Electron desktop client up to speed with the F
## Explicitly out of scope
-OIDC/LDAP in-app auth, auto-update, Peppol/PDF designer, AI helper, client portal, kiosk, Slack slash commands, inventory, team chat, live mileage GPS tracking, Belgium compliance report / correction UIs.
+OIDC/LDAP in-app auth, auto-update, Peppol/PDF designer, AI helper, client portal, kiosk, Slack slash commands, inventory, team chat, live mileage GPS tracking. Belgium compliance report / correction UIs are available on web, mobile, and desktop.
diff --git a/mobile/lib/presentation/widgets/workday_card.dart b/mobile/lib/presentation/widgets/workday_card.dart
index 5601fc28d..c484306f1 100644
--- a/mobile/lib/presentation/widgets/workday_card.dart
+++ b/mobile/lib/presentation/widgets/workday_card.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:timetracker_mobile/core/theme/app_tokens.dart';
import '../providers/attendance_provider.dart';
+import '../screens/belgium_report_screen.dart';
/// Workday clock-in/out controls shared between Home and Timer screens.
class WorkdayCard extends ConsumerWidget {
@@ -242,6 +243,14 @@ class WorkdayCard extends ConsumerWidget {
Expanded(
child: Text('Workday', style: theme.textTheme.titleMedium),
),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(builder: (_) => const BelgiumReportScreen()),
+ );
+ },
+ child: const Text('Belgium'),
+ ),
TextButton(
onPressed: () => _showHistory(context, ref),
child: const Text('History'),
diff --git a/tests/test_module_presets.py b/tests/test_module_presets.py
index 59946799d..12b681d42 100644
--- a/tests/test_module_presets.py
+++ b/tests/test_module_presets.py
@@ -49,7 +49,16 @@ def test_solo_preset_meaningfully_reduces_surface(self):
def test_solo_preset_keeps_the_core_workflow(self):
"""Track time -> project/client -> invoice -> report must survive."""
disabled = set(ModuleRegistry.get_disabled_ids_for_preset(ModulePreset.SOLO.value))
- for essential in ("timer", "projects", "clients", "invoices", "reports", "tasks"):
+ for essential in (
+ "timer",
+ "projects",
+ "clients",
+ "invoices",
+ "reports",
+ "tasks",
+ "weekly_goals",
+ "time_entry_templates",
+ ):
assert essential not in disabled, essential