fix(query-options): prefer known hosts over unknown defaults#809
fix(query-options): prefer known hosts over unknown defaults#809TimeToBuildBob wants to merge 1 commit intoActivityWatch:masterfrom
Conversation
Greptile SummaryThis PR fixes a bug in Confidence Score: 5/5Safe to merge — targeted fix with correct logic, no regressions introduced, and a regression test added. The change is minimal (6 lines of logic, one computed-property call site), the utility function handles all meaningful edge cases correctly (mixed, all-known, all-unknown, single-unknown), and the three new test cases directly cover the described root cause. No P0 or P1 issues found. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant M as QueryOptions (mounted)
participant C as hostnameChoices (computed)
participant P as preferKnownHostnames()
participant S as bucketsStore.hosts
M->>S: ensureLoaded()
S-->>M: hosts loaded
M->>C: read hostnameChoices
C->>S: this.bucketsStore.hosts
S-->>C: ['unknown', 'laptop_ori', ...]
C->>P: preferKnownHostnames(hosts)
P-->>C: ['laptop_ori', ..., 'unknown']
C-->>M: hostnameChoices[0] = 'laptop_ori'
M->>M: set queryOptionsData.hostname = 'laptop_ori'
M->>M: emit('input', queryOptionsData)
Reviews (1): Last reviewed commit: "fix(query-options): prefer known hosts o..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #809 +/- ##
==========================================
+ Coverage 31.53% 31.72% +0.18%
==========================================
Files 32 33 +1
Lines 1877 1882 +5
Branches 345 334 -11
==========================================
+ Hits 592 597 +5
- Misses 1217 1264 +47
+ Partials 68 21 -47 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
unknownin the shared QueryOptions hostname chooserunknownavailable as a fallback option when it is the only hostRoot cause
QueryOptionsdefaulted tohostnameChoices[0], andbucketsStore.hostscan legitimately putunknownfirst when a special bucket likeaw-stopwatchwas updated more recently than the real window/AFK buckets.That meant Category Builder could start with
queryOptions.hostname = "unknown"already set, which bypassed its existing "if hostname is blank, pick a non-unknown host" fallback and led to synthesized queries likeaw-watcher-window_unknown.Testing
npm test -- --runInBand test/unit/hostnames.test.node.ts test/unit/queries.test.node.jsRefs ActivityWatch/activitywatch#1214