feat(ui): render LiveValue.text enum labels in gauge + CSV - #64
Conversation
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
💡 Codex Reviewbeemuu/ops/backup-beemuu-db.sh Line 36 in a708c54 This new resolver is dead code in the normal production case: after it computes beemuu/src-tauri/src/data/live.rs Line 71 in a708c54 With this new per-parameter beemuu/src-tauri/src/commands.rs Line 259 in a708c54 With the new best-effort enum profiles, any raw byte that is missing from Line 181 in a708c54 When a user switches from Simulator to K+DCAN while the new connection-options panel is collapsed, ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Locks down the pure helpers introduced (logically) by PR #64 so a future refactor of main.js / gauges.js can't silently drift the CSV emission rules or the gauge numeric clamp. A regression here would re-break the "B58 gear log exports 'P/N,1,2,3' instead of '0,1,2,3'" behaviour #64 just shipped. - src/js/live_format.js: dual-context module with two pure helpers, csvCell(point) and clampGaugeValue(value, min, max). Loads in the browser via the existing <script> tag pattern (sets window.LiveFormat) and `require()`s cleanly under Node for the test harness. - src/js/test/live_format.test.cjs: eight tests covering every branch of csvCell (numeric, enum, comma-bearing label, missing, empty text) and clampGaugeValue (in-range, below, above, equal bounds, NaN). Uses Node's built-in `node:test`; no framework added. - src/js/gauges.js, src/js/main.js: Gauge.set and buildLogCsv now call the helpers instead of inlining the rules. No behaviour change. - src/index.html: loads live_format.js before gauges.js / main.js so window.LiveFormat is available when those run. - package.json: adds `test:js` script that runs `node --test src/js/test/*.test.cjs`. Existing `test:dtc` unchanged. The test harness deliberately stays small. There is no JS test runner in the repo today; the only existing JS tests are under server/dtc/test and use the same `node --test` runner. Extending the pattern to the frontend keeps the toolchain uniform. Verified locally: - npm run test:js → 8/8 pass - node --check on the three changed JS files - cargo test --lib → 34/34 (no Rust touched) Refs: PR #64 (gauge + CSV wiring), LiveValue.text from PR #60.
Wires the frontend half of the u8_enum feature shipped to the backend in PR #60 (commits 643bb24, 995a209). With this change, opening Live Data with a B58 profile renders the new `gear` and `engine_state` parameters as text gauges ("3rd", "Running") instead of as a 0.0 needle pinned to min. - src/js/gauges.js: Gauge constructor stores textOverride = null; Gauge.set(value, label?) enters text mode when a label is present (dial, ticks, and needle hidden; label drawn centred with unit underneath; font auto-shrinks 22 → 12 px so longer labels fit); Gauge.tick() skips the easing loop in text mode since labels are discrete. Numeric path is byte-identical. - src/js/main.js: pollOnce passes v.text through to Gauge.set. logTick stores point.text on each logged point. buildLogCsv emits the label as a quoted CSV cell when present so a gear-change log exports `0.00,"P/N",0.00,"1",...` rather than `0.00,0,0.00,1,...`. - CHANGELOG.md: [Unreleased] entry under Added. No backend/protected-path edits: transport/, protocol/, commands.rs, and bmw_diag/ are all untouched. Verified on clean origin/main: `cargo test --lib` 34/34, `node --check` clean on both JS files. Refs: PR #60 (backend), LiveValue.text field, UNIQUE_FEATURES.md §1.
a708c54 to
dbd4dce
Compare
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
…66) PR #64 added the gauge text-mode rendering and the CSV enum-label fidelity. PR #65 added the npm run test:js harness around the pure helpers in src/js/live_format.js. PR #66 added the wider-stance decode_enum_string_or_unknown so U8Enum samples with bytes that aren't in the profile enum_map surface as 0xNN ? instead of disappearing. None of the three had an [Unreleased] entry; this commit adds them so the next release notes compile cleanly.
…66) (#68) PR #64 (gauge text-mode rendering, CSV enum-label fidelity). PR #65 (npm run test:js harness around src/js/live_format.js). PR #66 (wider-stance decode_enum_string_or_unknown so unmapped U8Enum bytes surface as 0xNN ? instead of disappearing). All three shipped to main but were missing from [Unreleased].
Wires the frontend half of the u8_enum feature shipped to the backend in PR #60 (commits
643bb24,995a209). With this change, opening Live Data with a B58 profile renders the newgearandengine_stateparameters as text gauges ("3rd", "Running") instead of as a 0.0 needle pinned to min.What ships
src/js/gauges.js—Gaugegains a text-mode rendering path:set(value, label?): whenlabelis non-null, the gauge enters text mode; otherwise it behaves exactly as before.tick(): skips the easing loop in text mode (labels are discrete, not numeric).draw(): renders the dial face (kept for visual consistency with adjacent numeric gauges), then either the text label centred with the unit underneath, or the existing dial / ticks / needle / numeric readout. Long labels auto-shrink the font from 22 → 12 px so words like "Cranking" or "Overrun" fit without clipping.textOverridefield on the instance; defaults tonullso numeric gauges are unchanged.src/js/main.js:pollOnce(line 720):ensureGauge(v).set(v.value, v.text).logTick(line 1347): storespoint.textalongsideyfor each logged sample.buildLogCsv(line 1584): emits the label as a quoted CSV cell (JSON.stringify(p.text)) when present, falling back to the existing two-decimal numeric format otherwise. Result: a B58 gear log exports0.00,"P/N",0.00,"1",...instead of0.00,0,0.00,1,....CHANGELOG.md:[Unreleased]→### Addedentry referencing PR feat(data): u8_enum decoder + per-parameter enum-map pipeline #60.Protected-path flags
None touched.
transport/,protocol/,commands.rs, andbmw_diag/core/**are all unchanged. This is a frontend-only PR.Scope deliberately deferred
gearline graph that steps from 0 → 1 → 2 → 3 → 4) are a meaningful UX problem worth their own design pass. The chart still renders an enum param as its numeric value (always 0.0 today) when a user opts in via the existing checkbox. No regression; no new behaviour here.Verification
cargo test --lib— 34/34 passing (no Rust touched; verified on cleanorigin/mainfirst).node --check src/js/main.js src/js/gauges.js— clean syntax.r=74, the gauge accepts labels up to ~118 px wide before shrinking. Real-world BMW labels ("P/N", "1", "Cranking", "Running", "Idle", "Overrun", "Shutdown") are all under 90 px in 22 px Segoe UI, so no shrink should be needed in practice.Refs
643bb24+995a209),LiveValue.textfield,decode_enum_string.docs/DECODE_FUNCTIONS.md§8.UNIQUE_FEATURES.md§1 (the eventual Community Oracle stack)..hermes/plans/u8_enum_frontend_plan.md(gitignored working doc).Risk + rollback
Single revert, no migrations, no schema, no async surfaces touched. Rollback restores the gauge to numeric-only and the CSV to numeric-only exports.