Skip to content

fix(category-builder): support hosts with only Android/ScreenTime buckets - #932

Merged
ErikBjare merged 2 commits into
masterfrom
fix/category-builder-android
Aug 11, 2026
Merged

fix(category-builder): support hosts with only Android/ScreenTime buckets#932
ErikBjare merged 2 commits into
masterfrom
fix/category-builder-android

Conversation

@ErikBjare

Copy link
Copy Markdown
Member

The category builder unconditionally queried aw-watcher-window_<host> + aw-watcher-afk_<host>, so on aw-android it failed with:

BucketQueryError("Failed to query bucket: NoSuchBucket(\"aw-watcher-window_POCO F8 Ultra\")")

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 via bid_android (resolving the actual bucket id from the buckets store, preferring the ScreenTime bucket when both exist — mirrors query_android in the activity store).
  • findCommonPhrases(): fall back to data.app when data.title is missing — Android events carry only an app name (and the android query path merges by app), so the old code would have thrown on undefined.split.
  • The "Show events" table likewise falls back to the app name.
  • Added a unit test for the app-name fallback.

Reported by @ErikBjare while testing aw-android 0.14.0b1.

…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.
@ErikBjare

Copy link
Copy Markdown
Member Author

@greptileai review

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.53%. Comparing base (266a714) to head (83aa9e4).
⚠️ Report is 4 commits behind head on master.

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.
📢 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 Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR enables the category builder for Android-only and ScreenTime-only hosts while preserving the desktop window/AFK query path.

  • Resolves Android-style bucket IDs from the buckets store, preferring ScreenTime imports.
  • Falls back from event titles to app names when generating and displaying category suggestions.
  • Adds unit coverage for app-only events.

Confidence Score: 5/5

The 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

Filename Overview
src/views/settings/CategoryBuilder.vue Selects a real Android or preferred ScreenTime bucket when no desktop bucket pair exists and displays app names when titles are unavailable.
src/util/categorization.ts Centralizes title-to-app fallback for both word and bigram extraction.
test/unit/categorization.test.node.ts Verifies that durations are accumulated correctly for app-only Android events.

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]
Loading

Reviews (1): Last reviewed commit: "fix(category-builder): support hosts wit..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/util/categorization.ts Outdated

// 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 ?? '';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 83aa9e4 (switched to || and added an empty-title case to the test).

@ErikBjare
ErikBjare merged commit 7db0598 into master Aug 11, 2026
8 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.

1 participant