Skip to content

refactor(timetracking): deepen the Time Tracking modules (#331, #335, #336) - #351

Merged
mdiener21 merged 5 commits into
mainfrom
refactor/timetracking-deepen
Nov 21, 2026
Merged

mdiener21 merged 5 commits into
mainfrom
refactor/timetracking-deepen

Conversation

@mdiener21

@mdiener21 mdiener21 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Package 3 of #326: deepen Time Tracking. Behaviour-preserving refactor; no CHANGELOG line.

  • Pure Time Tracking model module #331 Pure model timetracking-model.js: lookups (projectById, customerById — now the only customer lookup), active/in-use rules, work-week rules, prefill. Imports nothing that touches storage, IDB or the emitter; model-imports.test.js guards that for the model and the pure consumers.
  • Time Tracking interface per page, starting with the tracker panel #335 One Time Tracking interface per page: createTimeTracking(port) in timetracking-api.js (state, settings, prefs, commands, subscribe), with a storage adapter (timetracking-api-storage.js) and a test adapter (tests/fixtures/time-tracking.js) that folds events through the real reducer. Tracker panel moved first; new DOM tests cover archive, restore and guarded delete through the tracker.
  • Move remaining Time Tracking panels to the injected interface #336 Settings, projects, reports panels and the page shell take the injected interface; mountTimeTracking creates it once. timetracking-crud.js and timetracking-references.js deleted. Time-tracking unit/DOM tests no longer vi.mock storage or the emitter.
  • Review fixes: CRUD_ERROR → TT_ERROR, emit/field-change helpers, rename folded into itemActions, CONTEXT.md §6 Time Tracking rows.

Deliberately left as-is:

  • settings.test.js and legacy-work-week.test.js run on the storage adapter + fake-indexeddb: they test persistence.
  • The legacy work-week migration (page entry, not a panel) still reads storage directly.

Local runs: lint clean; unit 998/998; DOM 805/805; all timetracking e2e pass. notifications.spec.ts:177 fails locally on this branch and its base alike (no notifications code touched) — CI is the verdict.

Closes #331
Closes #335
Closes #336
Closes #326

Checklist

  • Tests added or updated when behaviour changed
  • CHANGELOG.md [Unreleased]: one user-facing line, if users notice the change (none: internal)
  • CONTEXT.md or an ADR updated if architecture or a domain term changed
  • docs/spec/ touched up, if a described behaviour changed (never blocks merging)

🤖 Generated with Claude Code

mdiener21 and others added 5 commits November 20, 2026 13:08
Move lookups (projectById, customerById), the active / in-use rules,
validation, work-week rules and prefill into timetracking-model.js,
which imports nothing that touches storage, IndexedDB or the emitter.
Report, filter, entry fields, balance and settings now take lookups
from it, so importing them no longer loads storage. Commands stay in
timetracking-crud.js and timetracking-settings.js.

timetracking-references.js and timetracking-work-week-model.js merge
into the model; the duplicate customerOf lookup is gone. The model is
unit-tested without mocks, and an import-graph test keeps the pure
modules free of storage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… adapters; tracker takes it (#335)

createTimeTracking(port) in timetracking-api.js holds the commands, settings, display
and device prefs and change subscription without loading storage or the emitter.
createStorageTimeTracking() wraps the Read Model and emitter for the app; the test
fixture createTestTimeTracking() folds events through the real reducer. The page shell
creates one and passes it to the tracker panel (and the reports panel's getters).
timetracking-crud.js stays as a module-level facade until #336.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#335)

Drops the storage and emitter mocks and the hand-written reducer inside them. Adds
coverage for archive, unarchive, in-use guard, raced delete (archives instead) and
tombstone restore as seen in the tracker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…interface (#336)

Projects (incl. the Work week editor), Settings and Reports panels read, change and
subscribe through the interface the page shell creates once. The temporary
timetracking-crud.js facade and the shell's getPrefs option are gone. Time Tracking
tests use the test adapter instead of mocking storage and the emitter; an import-graph
guard keeps panels off storage. The tracker's live Work week test drives the Projects
editor again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…331, #335, #336)

- Rename CRUD_ERROR to TT_ERROR; fix the stale in-use comment.
- Legacy Work week migration uses customerById.
- timetracking-api: emitTT and fieldChange helpers; archive/delete use the model lookups.
- Projects panel: rename goes through itemActions; tracker reaches the interface one way.
- Trim banner and header comments; CONTEXT.md §6 lists the Time Tracking modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mdiener21
mdiener21 marked this pull request as ready for review November 20, 2026 16:18
@mdiener21
mdiener21 merged commit cd6b298 into main Nov 21, 2026
15 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

1 participant