Skip to content

Show saved sensor SoC history for each car - #1724

Merged
frahlg merged 5 commits into
masterfrom
codex/vehicle-soc-history-20261018
Oct 18, 2026
Merged

frahlg merged 5 commits into
masterfrom
codex/vehicle-soc-history-20261018

Conversation

@frahlg

@frahlg frahlg commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Cars have no way to open the sensor SoC already saved in history.db. Add Battery history to each car, including unplugged cars, with 24-hour, 7-day and 30-day views through the existing vehicle_soc series API.

Show reported levels with their source times, saved averages and ranges. Keep empty history separate from failed reads. Cancel reads when the dialog closes or its range changes. When an older aggregate lacks a last value, label its average as an average. Charging estimates and manual levels never enter this chart.

Depends on #1694. This branch starts at its exact db790a0a70382d288e9c9f4806b3d40439b5db24 head to preserve its car routes and UI. Merge #1694 first; its three commits appear here until then. This PR adds SoC history and clears car-choice feedback when a later plug-in replaces the session. A late reply cannot attach the old refusal to the new session. Charging, storage and deployment policy stay unchanged.

Validation:

  • New unplugged-car history regression fails on the feat(web): the box page shows the owner's cars #1694 base and passes with this change.
  • Full make verify passes; all 836 web tests pass on the current branch.
  • A real SQLite persistence/reopen test and its race run preserve the reported SoC and source time and reject repeated/cached observations as new readings.
  • Read-only inspection of the owner's box found 329 saved SoC buckets. Browser review uses those reports with car/source identifiers removed, in a local preview at 390 and 1280 px, light and dark. Range changes, point selection, empty/error states, cancellation and focus return pass.

The SoC UI is not installed on the box. The owner inspected and approved the rendered SoC view in this chat. The current code also fixes the existing #1694 review about old tap responses; two regressions fail before and pass after, and a browser test verifies that a new plug-in clears the pending/refused note. No beta is published by this PR.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T14:07:08.370858Z cec3408 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cec3408c63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/car-soc-history.js
const sources = await readCarLevelHistory(car, range, { fetcher, signal, now: until });
if (closed || current !== sequence) return;
content.replaceChildren();
if (!sources.length) node(doc, 'p', content, 'No sensor source is available for this car on this device.', 'soc-note');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prompt for authentication before declaring no sensor source

When LAN authentication is enabled and the device has not signed in, GET /api/cars deliberately returns HTTP 200 with redacted: true and omits sources; because the LAN auth wrapper prompts only on 401 responses, opening Battery history reaches this branch and falsely reports that no sensor source exists, with no way to authenticate from the flow. The dialog should recognize the redacted car or obtain the protected source list after prompting and refetching.

AGENTS.md reference: AGENTS.md:L22-L23

Useful? React with 👍 / 👎.

Comment thread web/car-soc-history.js
Comment on lines +34 to +36
} catch (err) {
if (signal?.aborted || err?.name === 'AbortError') throw err;
return { source, points: [], failed: true };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep completed source histories when another request times out

For a car with multiple sensor sources, if one request exceeds the dialog's 30-second deadline, the shared controller aborts it and this branch rethrows; consequently Promise.all rejects and the outer dialog replaces every section with one global failure, discarding histories that other sources already returned successfully. Treat a deadline abort as a failed result for that source while retaining rethrows for dialog-close/range-change cancellation, so failures remain distinct and successful evidence remains visible.

AGENTS.md reference: AGENTS.md:L22-L23

Useful? React with 👍 / 👎.

@frahlg
frahlg merged commit 12e5ba5 into master Oct 18, 2026
22 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.

1 participant