feat(profile): add profile= to ActivityWatchClient and --profile CLI - #118
feat(profile): add profile= to ActivityWatchClient and --profile CLI#118TimeToBuildBob wants to merge 5 commits into
Conversation
--testing stays as an alias for --profile testing. The client exports AW_PROFILE before loading config so aw-core dirs isolate the queue file; persistqueue keeps the -testing suffix and named profiles get the same shape. Local rust API-key lookup reads config-<profile>.toml for named profiles so a research client does not inherit the default instance's key. The default profile unsets AW_PROFILE rather than setting it to "default", because aw-core suffixes any non-empty value. Part of ActivityWatch/activitywatch#1399.
Greptile SummaryThe PR adds named profile selection to the Python client and CLI while preserving default and testing compatibility.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains in the previously reported areas. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[CLI flags or AW_PROFILE] --> B[Resolve and validate profile]
B --> C[Export AW_PROFILE]
C --> D[Load profile configuration]
D --> E[Select host and port]
D --> F[Select persistent queue path]
E --> G[Discover matching local API key]
E --> H[ActivityWatchClient]
F --> H
G --> H
Reviews (4): Last reviewed commit: "fix(profile): apply #1399 testing-root r..." | Re-trigger Greptile |
Do not pull tests/test_auth.py into make test — those tests assume XDG_CONFIG_HOME, which platformdirs ignores on macOS/Windows. Patch get_config_dir in the named-profile test instead.
Click defaulted --port to 5600, so an explicit --port 5600 was indistinguishable from "unset" and got discarded. Default is now None so profile config wins only when the flag is omitted.
|
CI is all green now (including Windows). Addressing the two Greptile P1 findings: Port override discarded (cli.py) — false positive on the reviewed commit. The Queue profile changes on disconnect (client.py) — valid design note. Ready for review when maintainers have bandwidth. |
|
@greptileai review |
|
Correction to my previous note: the review exposed a real, cheap-to-fix reconnect invariant, so I fixed it in 9072c70. |
|
@greptileai review |
Isolated profile roots use bare config.toml. Legacy testing keeps config-testing.toml on the shared root. Named profiles no longer read config-<profile>.toml. Warn when an unprovisioned named profile falls back to [server]/5600, matching aw-server#167. Part of ActivityWatch/activitywatch#1399.
|
Pushed Isolated profile roots now read bare Unprovisioned named profiles now warn on the silent 50 profile/queue/auth tests passed locally; mypy + ruff clean. Do not merge until #152 has a PyPI release (maintainer order unchanged). |
|
@greptileai review |
Part of ActivityWatch/activitywatch#1399 (isolated profiles per edition/mode).
Python aw-client half of the profile work.
ActivityWatchClient(profile=...)and--profile NAMEpick the instance;testing=True/--testingstay as the alias forprofile="testing". Existing behaviour is unchanged for no-flag and--testing(port 5600 / 5666, persistqueue-testingsuffix,[server]/[server-testing]).aw_client/profile.py) — same rule as aw-qt, aw-server, and aw-server-rust.AW_PROFILEbefore loading config so aw-core#149 isolates the queue dir. If no constructor flag is set,AW_PROFILEfrom the launcher is used (watchers inherit it).AW_PROFILEinstead of setting it to"default". aw-core suffixes any non-empty value, soAW_PROFILE=defaultwould resolve toactivitywatch-defaultand orphan an existing install.-testingsuffix; named profiles get the same shape.MockClientwithout aprofileattr still uses the testing bool.[server-<profile>]/[client-<profile>], falling back to[server]/[client]. Unprovisioned named profiles log a warning that port 5600 may collide with the default instance (same as aw-server#167).activitywatch-testing/exists →activitywatch-testing/aw-server-rust/config.tomlactivitywatch/root →config-testing.tomlthereconfig.tomlIsolated roots (including named profiles) use bare
config.toml. Suffixedconfig-<profile>.tomlis no longer read. Lookup does not create directories. Testing also tries the other layout second so a python client that already createdactivitywatch-testing/still finds a rust server that wrote the key on the shared root.Testing-root note
Erik, 2026-08-29 on #1399: testing moves to
activitywatch-testing/going forward, with legacy fallback. This PR implements that for rust API-key lookup. Do not merge until aw-core#152 has a PyPI release and aw-server-rust#652 is in (maintainer order: #152 + release → #652 → #167 → #118 → #241).Not in this PR
--profile/ settings / info.profile — sibling PR feat(profile): add --profile flag and port/settings isolation aw-server#167Verification
pytest tests/test_profile.py tests/test_profile_config.py tests/test_auth.py tests/test_requestqueue.py— 50 passedmypy aw_client tests/test_profile.py tests/test_profile_config.py tests/test_auth.py— cleanruff checkon changed files — clean (pre-existing unusedtimeincli.pyleft alone)