Skip to content

feat(categories): expose category rule priority - #968

Merged
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/category-rule-priority-editor
Sep 6, 2026
Merged

feat(categories): expose category rule priority#968
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/category-rule-priority-editor

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Companion UI for ActivityWatch/aw-server-rust#663 and ActivityWatch/aw-core#153.

Adds the optional integer priority field to the category rule editor so users can override depth-based categorization order without manually editing exported JSON.

What changed:

  • Add an optional Priority input for regex category rules.
  • Save canonical priority values and normalize existing weight aliases on edit.
  • Preserve integer priority values in preset category sets.
  • Make aw-webui's local category helpers rank by explicit priority, falling back to depth.

Verification:

  • npm run test -- --selectProjects node --runTestsByPath test/unit/classes.test.node.ts test/unit/presetCategories.test.node.ts
  • npm run test -- --selectProjects jsdom --runTestsByPath test/unit/CategoryEditModal.test.js
  • npm run lint (passes; existing config warnings only)
  • npm run build (passes; existing Browserslist/Sass/Babel/asset-size warnings only)

Related: ActivityWatch/aw-server-rust#597. Do not close that issue until this PR merges.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.25%. Comparing base (a2ca625) to head (473e74c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #968      +/-   ##
==========================================
+ Coverage   51.99%   52.25%   +0.26%     
==========================================
  Files          48       48              
  Lines        2927     2943      +16     
  Branches      652      692      +40     
==========================================
+ Hits         1522     1538      +16     
+ Misses       1385     1322      -63     
- Partials       20       83      +63     

☔ View full report in Codecov by Harness.
📢 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

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR exposes optional integer priorities for regex category rules and supports canonicalizing the legacy weight alias.

  • Adds localized priority controls and validation to the category editor.
  • Preserves priorities when parsing presets and uses them when ranking local category matches.
  • Adds unit coverage for editing, alias normalization, preset parsing, and category ranking.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/components/CategoryEditModal.vue Adds localized priority input, integer validation, and canonical priority persistence; the previously reported localization issue is fixed.
src/util/classes.ts Extends category rules with priority metadata and ranks matching categories by explicit priority with depth fallback.
src/util/presetCategories.ts Validates and preserves integer priority values while normalizing the legacy weight alias.
test/unit/CategoryEditModal.test.js Covers priority saving, clearing, legacy alias loading, and decimal rejection.
test/unit/classes.test.node.ts Covers explicit priority and legacy weight behavior in local matching.
test/unit/presetCategories.test.node.ts Covers valid priority preservation, weight normalization, and invalid preset rejection.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  E[Category rule editor] --> V[Validate integer priority]
  V --> C[Store canonical priority]
  W[Legacy weight alias] --> C
  P[Preset category rules] --> C
  C --> R[Rank matching categories]
  R --> M[Highest-priority match]
Loading

Reviews (2): Last reviewed commit: "fix(categories): localize priority contr..." | Re-trigger Greptile

Git-Session-Id: f6df4e17-0dcc-5072-918b-297b6584d9da
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Addressed the localization finding in 473e74c: the Priority label, Default placeholder, and integer validation message now use locale keys, with translations in all six supported locales.

Verified the focused CategoryEditModal tests (14 passed), locale-key parity for the three new keys, lint (0 errors; existing config warnings only), and pre-commit checks. CI for the new commit is running.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@ErikBjare
ErikBjare merged commit 3e7fb7c into ActivityWatch:master Sep 6, 2026
9 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

Development

Successfully merging this pull request may close these issues.

2 participants