Skip to content

[go][js] update /api/capabilities#430

Open
Copilot wants to merge 7 commits intomainfrom
copilot/update-capabilities-check-radar-mode
Open

[go][js] update /api/capabilities#430
Copilot wants to merge 7 commits intomainfrom
copilot/update-capabilities-check-radar-mode

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

  • Explore current capabilities API format (Go structs, TS types, frontend, tests)
  • Create docs/plans/api-multi-sensor-capabilities-plan.md with the agreed format (radar/lidar named objects, no _sensors suffix)
  • Implement Go backend changes (types, handler, provider)
  • Implement frontend changes (TS types, store, layout)
  • Update all tests (Go and web)
  • Smart polling: only poll when LiDAR hardware present; static when radar-only
  • Handle empty radar/lidar maps gracefully (dev, prod scenarios)
  • 100% test coverage on capabilities store (25 tests, all branches)
  • Go test coverage: empty-maps, multi-sensor, sweep-disabled edge cases
  • All 647 web tests pass, all Go capabilities tests pass
  • Code review feedback addressed

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 4 commits March 24, 2026 07:50
Replace the flat capabilities response shape with per-sensor-class
maps keyed by a stable sensor name (e.g. 'default').  This allows
multiple sensors of the same class (radar, lidar) to coexist in
future without breaking the API contract.

Wire changes:
- SensorStatus / LidarSensorStatus replace LidarCapability
- Capabilities.Radar is now map[string]SensorStatus
- Capabilities.Lidar is now map[string]LidarSensorStatus
- 'State' field renamed to 'Status'; top-level LidarSweep removed
- Default fallback in showCapabilities updated
- capabilitiesProvider.Capabilities() builds named-object maps
- All tests updated for the new shape
Align the Svelte frontend with the new /api/capabilities JSON shape
where radar and lidar are Record<string, SensorStatus> maps keyed by
sensor name, replacing the flat boolean/object fields.

- api.ts: replace LidarCapability with SensorStatus and
  LidarSensorStatus; Capabilities uses Record maps
- capabilities.ts: default to { radar: { default: ... }, lidar: {} };
  derive lidarEnabled via Object.values().some()
- +layout.svelte: gate LiDAR nav items on the new map shape
- api.test.ts, capabilities.test.ts: update all test data to the new
  shape
@ddol ddol marked this pull request as ready for review March 24, 2026 08:08
Copilot AI review requested due to automatic review settings March 24, 2026 08:08
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

🤖 Version Bump Advisory

Warnings

Web Frontend code changed but version unchanged - update web/package.json


📖 See CHANGELOG.md for detailed guidelines.

This is an automated advisory. Review the detected changes and update versions accordingly.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ddol ddol changed the title Multi-sensor capabilities API: named-object maps per sensor class [go][js] update /api/capabilities Mar 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Redesigns the /api/capabilities contract to support multiple named sensors per sensor class (radar/LiDAR) by switching from a flat single-sensor shape to map[string]T / Record<string, T> keyed by sensor name, and updates the frontend gating + tests accordingly.

Changes:

  • Backend: replace flat Radar bool / LidarCapability with Radar map[string]SensorStatus and Lidar map[string]LidarSensorStatus, plus updated defaults/providers/tests.
  • Frontend: update Capabilities typings and derived stores to operate on named-object maps; update nav gating.
  • Docs/tests: add a plan doc describing the new format; update Go/TS test fixtures for the new shape.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
internal/api/server.go Introduces SensorStatus/LidarSensorStatus and changes Capabilities fields to named maps.
internal/api/server_admin.go Updates the default /api/capabilities fallback response to the new map-based shape.
cmd/radar/capabilities.go Updates the runtime capabilities provider to emit radar.default and optional lidar.default.
internal/api/capabilities_test.go Updates API handler tests for the new JSON shape and map access.
cmd/radar/capabilities_test.go Updates provider tests for map-based capabilities.
web/src/lib/api.ts Updates TypeScript API types to map-based Capabilities with per-sensor status interfaces.
web/src/lib/api.test.ts Updates API client tests to the new capabilities response shape.
web/src/lib/stores/capabilities.ts Updates default capabilities + derived stores (lidarEnabled, lidarState) for map semantics.
web/src/lib/stores/capabilities.test.ts Updates store tests for map-based capabilities and derived logic.
web/src/routes/+layout.svelte Updates LiDAR nav gating to check Object.values($capabilities.lidar).
docs/plans/api-multi-sensor-capabilities-plan.md Adds a plan/spec doc for the multi-sensor capabilities redesign.

Comment on lines 43 to 48
caps := Capabilities{
Radar: true,
Lidar: LidarCapability{
Enabled: false,
State: "disabled",
Radar: map[string]SensorStatus{
"default": {Enabled: true, Status: "receiving"},
},
LidarSweep: false,
Lidar: map[string]LidarSensorStatus{},
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default response now represents LiDAR absence as an empty map (lidar: {}), which is semantically "no LiDAR configured" rather than an explicit disabled sensor. The doc comment above showCapabilities still says "LiDAR as disabled"; consider updating it to reflect the empty-map contract to avoid confusion for API consumers.

Copilot uses AI. Check for mistakes.
Comment thread web/src/lib/api.ts
Comment thread internal/api/server.go
Comment thread docs/plans/api-multi-sensor-capabilities-plan.md Outdated
Comment on lines +33 to +39
"radar": {
"default": {
"enabled": true,
"status": "receiving",
"last_reading_at": "2026-03-24T06:45:12Z"
}
},
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan/examples and type definitions include a last_reading_at field, but the implemented Go/TypeScript SensorStatus types in this PR do not include it. Either implement last_reading_at end-to-end or remove it from the plan/spec so the documentation matches the shipped API.

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +97
| `enabled` | `bool` | Sensor channel was activated at startup |
| `status` | `string` | Runtime state: `disabled`, `starting`, `receiving`, `stale`, `error` |
| `last_reading_at` | `string \| null` | ISO 8601 timestamp of last data received; `null` = never |
| `sweep` | `bool` | (lidar only) Sweep/auto-tuner operational |

### State machine

```
disabled → starting → receiving ⇄ stale
↘ error
```
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan defines the status state machine/literals around "receiving"/"stale" and does not mention "ready", but the current implementation/provider emits "ready" for LiDAR. Please reconcile the documented status vocabulary/state machine with what the API actually returns (update the plan or adjust the implementation/tests).

Copilot uses AI. Check for mistakes.
Comment thread docs/plans/api-multi-sensor-capabilities-plan.md Outdated
Copilot AI requested a review from ddol March 24, 2026 08:34
Copilot finished work on behalf of ddol March 24, 2026 08:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: David Dolphin <445312+ddol@users.noreply.github.com>
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.

3 participants