feat(wip): started working on category sets#369
Conversation
Codecov ReportBase: 25.58% // Head: 25.23% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #369 +/- ##
==========================================
- Coverage 25.58% 25.23% -0.36%
==========================================
Files 26 26
Lines 1442 1474 +32
Branches 226 233 +7
==========================================
+ Hits 369 372 +3
- Misses 1020 1048 +28
- Partials 53 54 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
This pull request introduces 1 alert when merging 03f310f into 1980a40 - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert when merging 8b9d085 into 1980a40 - view on LGTM.com new alerts:
|
…lti-set combining Implements category sets from ActivityWatch#369 (Erik's 2022 WIP) with an extended data model supporting priority-ordered combining of multiple active sets. ## What's new - **CategorySet type** (`src/util/classes.ts`): `{ id: string; categories: Category[] }` - **mergeCategorySets()**: merges sets in priority order (first = highest); more specific rules still win within a set, set order breaks ties - **Settings store**: new `category_sets: CategorySet[]` + `active_set_ids: string[]` fields persisted alongside the legacy `classes` field (backwards compatible) - **Categories store**: full CRUD for sets (`createSet`, `deleteSet`, `switchToSet`, `setActiveSets`, `renameSet`); `classes` always reflects the merged effective categories from all active sets; migration path for existing users (wraps legacy `classes` in a "default" set on first load) - **CategorizationSettings UI**: set switcher dropdown, New/Delete buttons, per-set export ## Design notes - `active_set_ids: string[]` data model supports combining; UI v1 exposes single-set switching — multi-set combining UI can follow in a subsequent PR - Legacy `classes` field kept in sync for backwards compat with external readers - `save()` syncs edits back to the primary active set before persisting all sets - Import handles both legacy `{ categories: [] }` and new `{ id, categories }` formats Closes / supersedes ActivityWatch#369
…lti-set combining (#804) * feat(categorization): add category sets — named rule profiles with multi-set combining Implements category sets from #369 (Erik's 2022 WIP) with an extended data model supporting priority-ordered combining of multiple active sets. ## What's new - **CategorySet type** (`src/util/classes.ts`): `{ id: string; categories: Category[] }` - **mergeCategorySets()**: merges sets in priority order (first = highest); more specific rules still win within a set, set order breaks ties - **Settings store**: new `category_sets: CategorySet[]` + `active_set_ids: string[]` fields persisted alongside the legacy `classes` field (backwards compatible) - **Categories store**: full CRUD for sets (`createSet`, `deleteSet`, `switchToSet`, `setActiveSets`, `renameSet`); `classes` always reflects the merged effective categories from all active sets; migration path for existing users (wraps legacy `classes` in a "default" set on first load) - **CategorizationSettings UI**: set switcher dropdown, New/Delete buttons, per-set export ## Design notes - `active_set_ids: string[]` data model supports combining; UI v1 exposes single-set switching — multi-set combining UI can follow in a subsequent PR - Legacy `classes` field kept in sync for backwards compat with external readers - `save()` syncs edits back to the primary active set before persisting all sets - Import handles both legacy `{ categories: [] }` and new `{ id, categories }` formats Closes / supersedes #369 * fix(categorization): remove unused loadClasses import * fix(categorization): fix P1 bugs found in Greptile review - syncToPrimarySet: skip when multiple sets are active When active_set_ids.length > 1, state.classes is the merged result of all active sets. Writing it back to only the primary set would absorb all secondary sets' categories into it (data corruption). Now a no-op in multi-set mode until proper de-merge logic is added. - onSetChange discard bypass: call discardChanges() before switchToSet() Without this, confirming "discard" still called switchToSet() which called syncToPrimarySet() first, writing the unsaved edits back into the primary set's in-memory state. Now we explicitly reset in-memory classes from the stored sets before switching. - Add discardChanges() action to categories store Resets state.classes from stored sets without syncing back. Separates the "reload from sets" operation from "switch to set", enabling clean discard semantics. * fix(categorization): fix P2 bugs in import/export identified by Greptile - exportClasses: use classes_clean instead of activeSet.categories so unsaved in-memory edits are included in the export (was silently omitting any edits made since last save/switch) - importCategories (active-set case): call discardChanges() instead of switchToSet() when importing into the currently active set. switchToSet calls syncToPrimarySet first which overwrites the just-imported categories with stale in-memory classes, making the import a silent no-op. discardChanges recomputes classes from the updated set data without the destructive sync.
TODO