Skip to content

feat(aw-client-rust): add get_classes with fallback to the default classes - #735

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
0xbrayo:feat/aw-client-get-classes
Sep 27, 2026
Merged

ErikBjare merged 1 commit into
ActivityWatch:masterfrom
0xbrayo:feat/aw-client-get-classes

Conversation

@0xbrayo

@0xbrayo 0xbrayo commented Sep 24, 2026

Copy link
Copy Markdown
Member

Part of #724 (aw-client-rust parity with the Python client).

Adds AwClient::get_classes() (async and blocking), the counterpart of aw_client.classes.get_classes() in Python:

  • fetches the classes setting with get_setting("classes");
  • parses it with the existing classes::classes_from_settings_json, which already falls back to default_classes() for null, empty or invalid values and decodes double-encoded payloads;
  • if the request itself fails (server down, 5xx, auth error), logs a warning and returns default_classes(), as Python does.

It returns the classes directly rather than a Result, because every failure falls back to the defaults. Unlike the Python helper, it uses the caller's client (host, port, API key) instead of building its own client against the default production server.

Tests

A mock-server test covers: a server-provided class list is used; an unset (null) setting → defaults; a 500 → defaults.

@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds a new method to fetch categorization classes from the server.

The PR appears safe to merge; no actionable new issue was identified.

Summary

The PR adds async and blocking class retrieval with default-class fallback. Changes since the previous review also add bucket export/import methods and round-trip coverage.

  • Class retrieval uses the configured client and falls back when the setting is unusable or the request fails.
  • Export/import routes and payloads match the server contracts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Client[AwClient] -->|GET classes setting| Server[Server]
  Server -->|setting or error| Classes{Parse classes}
  Classes -->|valid| Custom[Server classes]
  Classes -->|unset, invalid, or request error| Defaults[Default classes]
Loading

Reviews (4) · Last reviewed commit: "feat(aw-client-rust): add get_classes wi..."

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.46%. Comparing base (656f3c9) to head (76e85a3).
⚠️ Report is 155 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #735       +/-   ##
===========================================
+ Coverage   70.81%   81.46%   +10.65%     
===========================================
  Files          51       80       +29     
  Lines        2916     9789     +6873     
===========================================
+ Hits         2065     7975     +5910     
- Misses        851     1814      +963     

☔ 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.

@0xbrayo
0xbrayo force-pushed the feat/aw-client-get-classes branch 2 times, most recently from 941220b to a62711a Compare September 26, 2026 19:13
@0xbrayo

0xbrayo commented Sep 26, 2026

Copy link
Copy Markdown
Member Author

@greptile review

@0xbrayo
0xbrayo force-pushed the feat/aw-client-get-classes branch from a62711a to dec63ea Compare September 26, 2026 19:48
@0xbrayo

0xbrayo commented Sep 26, 2026

Copy link
Copy Markdown
Member Author

@greptile review

…asses

Mirrors aw_client.classes.get_classes(): read the "classes" setting and fall
back to the default classes when the request fails or the setting is unset or
invalid. The parsing and fallback rules are the existing
classes_from_settings_json; this only adds the fetch.
@0xbrayo
0xbrayo force-pushed the feat/aw-client-get-classes branch from dec63ea to 76e85a3 Compare September 26, 2026 20:13
@0xbrayo

0xbrayo commented Sep 26, 2026

Copy link
Copy Markdown
Member Author

@greptile review

@ErikBjare
ErikBjare merged commit 7497182 into ActivityWatch:master Sep 27, 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.

2 participants