Skip to content

feat(api): expose local device discovery - #835

Open
TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:feat/local-device-discovery-2da5
Open

TimeToBuildBob wants to merge 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:feat/local-device-discovery-2da5

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

GET /api/0/devices currently returns 404 in Rust, leaving the local-device discovery slice of ActivityWatch/activitywatch#302 absent. Add a local-only JSON list with the persisted instance ID and current hostname, matching the pending Python implementation in ActivityWatch/aw-server#183. The hostname comes from the same helper as /info, including Android overrides.

The route uses the existing host, CORS and API-key guards. Tests cover exact JSON and /info agreement, repeated identity stability, legacy bucket hostnames producing no inferred peers, valid/missing/wrong API keys on canonical/trailing/encoded paths, and invalid Host rejection.

This is an additive local-discovery slice on master, independent of #786. Full peer catalogue semantics, device-aware bucket/cache addressing and compatibility resolution remain prerequisites of V2 import; this PR does not complete ActivityWatch/activitywatch#302 or enable V2 sync.

Validation: the new behavior tests first reproduced the missing-route 404, then passed after implementation. cargo test -p aw-server -- --test-threads=2: 155 passed, 1 ignored. cargo clippy --workspace -- -D warnings, formatting, whitespace and commit hooks pass. Tests use isolated in-memory data and local test processes.

Git-Session-Id: 7e70ca36-75d1-44e3-9e81-7d3ad59c8aa1
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge.

Summary

Adds GET /api/0/devices, returning one local device with its instance ID and current hostname.

  • The Rust API returns a one-entry list describing the local server.

Reviews (1) · Last reviewed commit: "feat(api): expose local device discovery" · Reviewed by Greptile

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.49%. Comparing base (656f3c9) to head (1b08583).
⚠️ Report is 219 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #835       +/-   ##
===========================================
+ Coverage   70.81%   85.49%   +14.67%     
===========================================
  Files          51       88       +37     
  Lines        2916    12679     +9763     
===========================================
+ Hits         2065    10840     +8775     
- Misses        851     1839      +988     

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

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

All eight checks passed and Greptile reports 5/5 on the current head. No review changes are outstanding. Bob has triage, not write access here; waiting for maintainer review and merge.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — 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

TimeToBuildBob commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Adds a serializable Device struct and devices_get() handler in aw-server/src/endpoints/mod.rs, mounted at /api/0/devices. The handler returns a one-element JSON array containing state.device_id and the hostname from the same helper used by /api/0/info. Adds integration tests for the response, bucket hostname exclusion, API-key authentication across path variants, and invalid Host rejection.

Safe to merge — no P0/P1 findings

Confidence 5/5

✅ No findings. The diff looks correct to me on this pass.

Files changed (2) — the diff as I read it
  • aw-server/src/endpoints/mod.rs — Adds Device, devices_get(), and the /api/0/devices mount returning the local instance ID and current hostname.
  • aw-server/tests/api.rs — Adds three device endpoint tests covering /info agreement, repeated responses, exclusion of bucket hostnames, API-key authentication, path variants, and Host rejection.

Reviewed 1b0858314437 · panel: codex:gpt-6.1-sol · subscription engine · 13s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

Outage coverage: 1-pass, not merge evidence. Subscription review supplied findings while full consensus capacity was unavailable. The consensus merge gate remains unsatisfied.

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