Skip to content

fix(categories): auto-select sole hostname in category builder - #950

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/category-builder-hostname-empty-state
Aug 28, 2026
Merged

fix(categories): auto-select sole hostname in category builder#950
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/category-builder-hostname-empty-state

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Problem

The category builder looks broken until you open Show options and pick a hostname (ActivityWatch/activitywatch#1389). Two things stacked:

  1. queryOptions was initialized without hostname, and fetchWords() was not called on mount (commented as "Called by watch" without immediate: true).
  2. The empty state for a missing hostname said install a watcher, which is the wrong diagnosis when buckets already exist.

Change

  • After ensureLoaded(), auto-select the hostname when there is exactly one non-unknown host.
  • If several known hosts exist (or only unknown), leave hostname unset and tell the user to open Show options.
  • Keep the "install a watcher" copy only when bucketsStore.hosts is empty.
  • Mount QueryOptions with v-if instead of v-show so it does not auto-pick hostnameChoices[0] while the panel is still collapsed.

Workaround (until this lands)

Open Show options and choose the device hostname.

Test plan

  • npx jest --selectProjects node --testPathPattern hostnames.test.node
  • One-host machine: category builder shows words without opening options
  • Multi-host machine: empty state names Show options; picking a host loads words
  • No buckets: still shows the install-a-watcher copy

…ng watchers

Category builder initialized queryOptions without a hostname and never
called fetchWords on mount, so users with data saw "install a watcher"
until they opened Show options and picked a host. Auto-select the only
non-unknown hostname after buckets load, and point the empty state at
the hostname picker when hosts exist but none is selected.

Related to ActivityWatch/activitywatch#1389.
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.55%. Comparing base (3cbe349) to head (f66c44b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #950      +/-   ##
==========================================
+ Coverage   49.36%   49.55%   +0.18%     
==========================================
  Files          45       45              
  Lines        2769     2779      +10     
  Branches      625      629       +4     
==========================================
+ Hits         1367     1377      +10     
  Misses       1322     1322              
  Partials       80       80              

☔ 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 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes the category builder automatically query activity when exactly one known hostname is available and provides more accurate empty-state guidance otherwise.

  • Adds reusable helpers for selecting a sole known hostname and classifying hostname-related empty states.
  • Defers mounting query options until the panel is opened.
  • Adds unit coverage for hostname selection and empty-state classification.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or non-blocking defects identified in the changed behavior.

The sole-host selection receives a deduplicated host list, reactive hostname assignment reaches the existing query watcher, and multi-host or unavailable-host states remain explicitly user-selectable.

Important Files Changed

Filename Overview
src/views/settings/CategoryBuilder.vue Coordinates bucket loading, sole-host selection, query triggering, options-panel mounting, and distinct no-host versus unselected-host messaging without an identified actionable defect.
src/util/hostnames.ts Adds focused hostname filtering, sole-host selection, and empty-state helpers with behavior aligned to the category builder flow.
test/unit/hostnames.test.node.ts Covers known, unknown, empty, and multi-host cases for the newly introduced utility behavior.

Reviews (1): Last reviewed commit: "fix(categories): auto-select sole hostna..." | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable — 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.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Automated merge handoff for f66c44b0c9e4:

  • CI gate: satisfied
  • Review threads: clear
  • Self-merge: blocked — pull-only access on this repo, and these paths are outside the allowlist:
  • src/util/hostnames.ts
  • src/views/settings/CategoryBuilder.vue

This head is ready for maintainer review and manual merge. Project monitoring marked it human_merge_required and will not spend retry sessions attempting an automated merge. A new head will be evaluated independently.

@ErikBjare
ErikBjare merged commit 13a9428 into ActivityWatch:master Aug 28, 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