Skip to content

Recognize the plug-in hybrid variants in the catalog - #187

Merged
vcanuel merged 2 commits into
mainfrom
feat/plugin-hybrid-variants
Oct 29, 2026
Merged

vcanuel merged 2 commits into
mainfrom
feat/plugin-hybrid-variants

Conversation

@vcanuel

@vcanuel vcanuel commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The catalog's step of plug-in hybrid support: the plug-in hybrid variants, recognized among their own powertrain.

Part of #165 (the catalog's box; the fuel of a trip and the documentation's page follow).

  • variants.yaml gains a powertrain field (electric when left out, plugin_hybrid) and 20 entries: the XC90 T8 of 9.2 kWh (MY2016–2017), the 10.4 kWh pack (MY2018–2019), the 11.6 kWh one (MY2020–2022), the 18.8 kWh one (from MY2022, on sale) of V60, S60, V90, S90, XC60 and XC90, the XC40 T4/T5 (10.7 kWh) and the Polestar 1.
    • Gross capacities from Volvo's manuals (volvocars.com/support), model year by model year; the 11.6 and 18.8 kWh packs overlap in MY2022, told apart by the capacity (an XC60 of MY2022 reports 11.832).
    • Net capacities from public sources only: 14.9 kWh (18.8), 8.0 (10.4), 8.5 (XC40); none settles those of 9.2, 11.6 and the Polestar 1, whose energies keep resting on the reported capacity.
    • Onboard chargers: 3.7 kW up to MY2022 (230 V, 16 A), 6.4 kW for the 18.8 kWh pack (the manual of MY2022 says 3.6 kW at most, today's 6.4: the highest is kept, as the file's rule says).
    • dc_max_kw may be left out, for a plug-in hybrid only.
  • catalog: Reading.Powertrain replaces BatteryElectric; Offer lists the variants of the reading's powertrain, family or brand; MatchReading, Recognize and Chosen rest on it. indiscernible never pairs two powertrains.
  • API: offered, effectiveModel and the variants' list read the powertrain. Contract change: dc_max_kw and levels.dc_max_kw are nullable (api/openapi.yaml; no golden file changes).
  • Front end: "no DC charging" (en, fr, sv) for a variant without one.
  • runsten-collector: the net capacities of the derivation follow.
  • Update note: rebuild after updating; a V60 of 2027's energies fall by 21 %.

How it was tested

  • go test ./internal/catalog/... ./internal/api/... ./cmd/runsten-collector/... ./internal/archtest/...: new cases for the hybrids' recognition (the API's real values 11.832 and 18.819, MY2022's two packs, a hybrid at an electric's capacity and the reverse, unknown and other powertrains, choices across powertrains), the validation (powertrain, DC left out), the API's model and variants list.

  • Mutation: without the powertrain filter in Offer, TestMatch and TestRecognize fail.

  • task lint, task fmt-check, task web-lint, task web-test. Not run: task lint-api, task integration, task system.

  • task unit passes

  • The API's diff (api/openapi.yaml, internal/api/testdata/) is intended, or there is none

  • Texts in English, French and Swedish, if the interface changed

  • No real VIN, token, API key or position, fixtures included

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added catalog support for Volvo and Polestar plug-in hybrid variants, with vehicle matching and variant selection based on powertrain.
    • Variant details now show when DC charging is unavailable.
  • Bug Fixes
    • Energy estimates for supported plug-in hybrids use known variant battery capacity, and AC charging costs respect the onboard charger’s limit.
    • Rebuilding after an update applies revised calculations to past events.

The catalog gains the plug-in hybrid Volvos (T6 and T8 of the 60 and 90
series, from the XC90 T8 of 2016; T4 and T5 of the XC40) and the Polestar
1, each with a powertrain field. Their gross capacities come from Volvo's
manuals, model year by model year; the net ones from public sources where
any settles them.

A vehicle is matched, offered and chosen among the variants of the
powertrain it reads, never one whose powertrain is unknown or other, so
that a hybrid's capacity is never taken for an electric's. A variant may
have no DC charging: dc_max_kw is null in the API then, and the vehicle's
settings say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a37700e and 0e07121.

Files ignored due to path filters: 1
  • api/openapi.yaml is excluded by !api/openapi.yaml
Files selected for processing: 5
  • AGENTS.md
  • web/src/shared/i18n/locales/en.json
  • web/src/shared/i18n/locales/fr.json
  • web/src/shared/i18n/locales/sv.json
  • web/test/features/edit-vehicle-model/VehicleModelForm.test.ts
Files skipped from review as they are similar to previous changes: 3
  • web/src/shared/i18n/locales/fr.json
  • web/src/shared/i18n/locales/en.json
  • web/src/shared/i18n/locales/sv.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

The catalog adds Volvo and Polestar plug-in hybrid variants. Matching, offers, and variant selection use the vehicle’s powertrain. The API represents absent DC charging power as null, and the vehicle-model interface displays a localized no-DC label.

Changes: Plug-in hybrid catalog support

Layer / File(s) Summary
Powertrain and charging-data contract
internal/catalog/catalog.go, internal/catalog/validate.go, internal/catalog/catalog_test.go, internal/catalog/validate_test.go
Variants now carry a validated powertrain. DC charging power may be absent for plug-in hybrids, but remains required for electric variants. Variants with different powertrains are distinguishable.
Plug-in hybrid catalog entries
internal/catalog/variants.yaml, internal/catalog/catalog_test.go
The catalog adds Volvo plug-in hybrid variants across the listed model years and a Polestar 1 variant, with capacity and charging figures.
Powertrain-aware matching and API integration
internal/catalog/match.go, internal/catalog/match_test.go, internal/api/model.go, internal/api/model_test.go, internal/api/read_test.go, cmd/runsten-collector/capacity.go
Matching, offering, and chosen variants use the reading’s powertrain. The API and collector pass powertrain readings, and the API represents missing DC charging data as null.
No-DC display and behavior documentation
web/src/features/edit-vehicle-model/ui/VariantLabel.vue, web/src/shared/i18n/locales/*.json, web/test/features/edit-vehicle-model/VehicleModelForm.test.ts, AGENTS.md, documentation/contributing/variants.md, documentation/guide/vehicle-models.md, documentation/self-hosting/updating.md
The interface displays a localized no-DC label. Documentation describes powertrain-specific recognition, catalog entry fields, and the update note for past events.

Possibly related issues

Possibly related PRs

  • runsten-app/runsten#157: Introduced MatchReading and Reading, which this change extends with powertrain-aware matching.
  • runsten-app/runsten#180: Introduced snapshot powertrain and plug-in hybrid readings, which this change uses for matching, offers, choices, and capacity selection.
  • runsten-app/runsten#163: Added the net_kwh display path that can use net capacities from the new plug-in hybrid catalog entries.
Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title is short, imperative, in English, and clearly describes the main catalog change: recognizing plug-in hybrid variants.
Description check Passed The description explains the changes, motivation, testing, API impact, localization, and unchecked tests. It is mostly complete, although the template's explicit "Closes #" line is absent and `task un…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the changes, motivation, testing, API impact, localization, and unchecked tests. It is mostly complete, although the template's explicit "Closes #" line is absent and task unit was not run.

Comment @coderabbitai help to get the list of available commands.

@vcanuel
vcanuel merged commit ee5a30c into main Oct 29, 2026
7 of 8 checks passed
@vcanuel vcanuel mentioned this pull request Oct 30, 2026
5 tasks done
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