fix(categories): keep Top Categories colors when category query contains encoded segments#781
Conversation
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to 09fc232 in 6 seconds. Click for details.
- Reviewed
48lines of code in2files - Skipped
0files when reviewing. - Skipped posting
0draft 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_qeGfzLiQW7N4q3Iv
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #781 +/- ##
==========================================
+ Coverage 25.71% 25.92% +0.21%
==========================================
Files 30 30
Lines 1754 1759 +5
Branches 307 307
==========================================
+ Hits 451 456 +5
Misses 1281 1281
Partials 22 22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Greptile SummaryThis PR fixes a color-resolution bug in the Top Categories ( Changes:
Minor note: The normalization block is duplicated across the two getters — extracting it to a shared helper would improve maintainability (see inline comment), but it does not affect correctness. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as aw-summary (Vue component)
participant Store as categoryStore
participant Helper as getColorFromCategory
UI->>Store: get_category_color(["Work%20Project"])
Note over Store: decodeURIComponent each segment<br/>→ ["Work Project"]
Store->>Store: get_category(["Work Project"])
Store-->>Store: returns matched Category
Store->>Helper: getColorFromCategory(category, classes)
Helper-->>Store: "#123456"
Store-->>UI: "#123456" ✅
Note over UI,Store: Before fix — encoded segment missed lookup
UI->>Store: get_category_color(["Work%20Project"])
Store->>Store: get_category(["Work%20Project"])
Store-->>Store: no match → Uncategorized fallback
Store->>Helper: getColorFromCategory(Uncategorized, classes)
Helper-->>Store: gray ❌
|
Additional Comments (1)
For consistency and robustness, apply the same normalization: Alternatively—and more robustly—move the normalization into |
|
@TimeToBuildBob Worth addressing those greptile comments |
Same URL-encoding vulnerability existed in get_category_score as was fixed in get_category_color. Encoded segments like 'Work%20Project' would fail to match stored decoded names and silently return score 0. Adds a regression test mirroring the one for get_category_color.
|
Addressed the Greptile concern: applied the same URL-decode normalization to Also added a regression test mirroring the one for |
|
@greptileai review |
|
Also extracted the normalization logic to a |
Summary
Fixes category color fallback in Top Categories when category segments are URL-encoded (e.g. spaces encoded as
%20).Issue: ActivityWatch/activitywatch#1135
Root cause
Top Categories (
aw-summary) resolves colors viacategoryStore.get_category_color(e.data['$category']).After navigation/filtering through query params, category segments can be URL-encoded in some paths (
Work%20Project), while configured categories are stored decoded (Work Project).The lookup then misses, falls back to
Uncategorized, and renders gray.Changes
src/stores/categories.tsdecodeURIComponenteach category segment inget_category_color()before lookup.test/unit/store/categories.test.node.tsValidation
npm test -- test/unit/store/categories.test.node.ts✅(Repo-level lint in this environment can conflict with parent worktree eslint plugin resolution; targeted unit test is green.)
Important
Fixes category color resolution by decoding URL-encoded segments in
get_category_color()and adds a test for this behavior.get_category_color()insrc/stores/categories.tsby decoding URL-encoded segments before lookup.get_category_color decodes URL-encoded category segmentsincategories.test.node.tsto verify encoded and decoded segments resolve to the same color.This description was created by
for 09fc232. You can customize this summary. It will automatically update as commits are pushed.