fix(category-builder): support hosts with only Android/ScreenTime buckets - #932
Conversation
…kets The category builder unconditionally queried aw-watcher-window_<host> and aw-watcher-afk_<host>, which fails with NoSuchBucket on Android (and for iOS ScreenTime imports) where the only bucket is aw-watcher-android_<host> or aw-import-screentime_<host>. Query the android-style bucket when the host has no window/AFK pair (mirroring query_android in the activity store, including preferring the ScreenTime bucket), and make findCommonPhrases and the events table fall back to the app name since Android events have no title.
|
@greptileai review |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #932 +/- ##
==========================================
+ Coverage 42.50% 42.53% +0.02%
==========================================
Files 44 44
Lines 2416 2417 +1
Branches 518 490 -28
==========================================
+ Hits 1027 1028 +1
- Misses 1313 1368 +55
+ Partials 76 21 -55 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThe PR enables the category builder for Android-only and ScreenTime-only hosts while preserving the desktop window/AFK query path.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code defect identified. The Android bucket parameters match the canonical query contract, ScreenTime preference mirrors the established activity-store behavior, and app-only events are handled consistently by phrase extraction. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Category builder fetches words] --> B{Window and AFK buckets available?}
B -->|Yes| C[Query desktop window and AFK buckets]
B -->|No| D{Android or ScreenTime bucket available?}
D -->|Yes| E[Prefer ScreenTime, otherwise Android bucket]
D -->|No| C
C --> F[Canonical events query]
E --> F
F --> G[Filter selected category]
G --> H[Extract title or app text]
H --> I[Generate common words and phrases]
Reviews (1): Last reviewed commit: "fix(category-builder): support hosts wit..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e8df30d6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // Android/ScreenTime events have no title (only an app name), so fall | ||
| // back to the app field there. | ||
| const eventText = (event: IEvent): string => event.data.title ?? event.data.app ?? ''; |
There was a problem hiding this comment.
Fall back to the app when the title is empty
For an Android/ScreenTime event containing title: '' and a valid app, the nullish-coalescing expression selects the empty title, so the event contributes no words even though the event table displays its app via title || app. Treat an empty title as missing here as well; otherwise such app activity silently disappears from the category-builder suggestions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — fixed in 83aa9e4 (switched to || and added an empty-title case to the test).
The category builder unconditionally queried
aw-watcher-window_<host>+aw-watcher-afk_<host>, so on aw-android it failed with:since the phone only has an
aw-watcher-android_<host>bucket (same problem for iOS ScreenTime imports).Changes:
CategoryBuilder.fetchWords(): when the selected host has no window/AFK bucket pair but has an android-style bucket, query it viabid_android(resolving the actual bucket id from the buckets store, preferring the ScreenTime bucket when both exist — mirrorsquery_androidin the activity store).findCommonPhrases(): fall back todata.appwhendata.titleis missing — Android events carry only an app name (and the android query path merges byapp), so the old code would have thrown onundefined.split.Reported by @ErikBjare while testing aw-android 0.14.0b1.