Skip to content

Experimental touch - #79

Merged
atulmgupta merged 2581 commits into
mainfrom
experimental-touch
Jul 6, 2026
Merged

atulmgupta merged 2581 commits into
mainfrom
experimental-touch

Conversation

@atulmgupta

Copy link
Copy Markdown
Contributor

Description

Closes #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would break existing functionality)
  • Documentation update
  • Infrastructure / CI change

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing tests pass locally
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Screenshots (if applicable)

atulmgupta and others added 30 commits July 6, 2026 02:01
…ncyWidget.tsx

Fix: forward the useSleepEfficiency error to WidgetShell so a failed request surfaces a QueryError instead of the misleading 'No sleep efficiency data' empty state (matching RouteEfficiencyWidget/RegenEfficiencyWidget). Add a comprehensive Vitest + RTL suite covering vehicle resolution, loading/empty/error states, the populated gauge + stats, the asleep/offline sleep-total filter, gauge colour thresholds, null-safety, the compact layout, the help-tooltip a11y label, and the freshness refresh interaction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add co-located Vitest coverage for ALERTS_TOUR (definition metadata, step shape, routeMatch regex + registry integration, and onShow navigation incl. same-page no-op and pushState-throw resilience). Harden navigate() so a history.pushState SecurityError inside onShow can no longer bubble out of the useTour effect and crash the walkthrough.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Widget.tsx

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Register the real past-tense automation audit actions the Go backend writes to audit_logs (internal/automation/audit.go: created/updated/deleted/enabled/disabled/re_enabled/test_run/undo/imported/exported/executed/failed/auto_disabled). The registry only had imperative keys (automation.create/update/delete) that never match a real feed entry, so every automation event collapsed onto the generic fallback. Additive change: existing entries and tests are untouched; adds matching i18n keys in en.json and tests asserting each action resolves to its own visual, failures flag distinctly, and unlisted verbs still degrade to the domain entry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Widget.tsx

Fix two real unit-conversion bugs surfaced by the new tests:
- Distance: distanceKm (km) was fed straight into convertDistanceFromSI
  (which expects SI metres), skewing values ~1609x (62 mi rendered as 0.0).
  Now lifts km -> SI metres -> display unit via the lib.
- Efficiency: Wh/km was double-converted (MI_TO_KM then *1.609344), wrong in
  both unit branches. Now scaled once by the lib-derived km-per-display-unit
  span (250 Wh/km -> 402 Wh/mi / 250 Wh/km).

Harden: keep cached metrics on background-refetch error (error && !data),
stable useCallback refresh handler, drop unused UNITS import.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…idget.tsx

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…VisualWidget.tsx

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ur.ts

Add a comprehensive co-located Vitest suite covering AUTOMATIONS_TOUR metadata, registry wiring, step ordering/well-formedness, routeMatch regex, and the first step's onShow navigation (off-route push, already-on-route no-op, and history-failure paths).

Harden the internal navigate() helper: wrap history.pushState + popstate dispatch in try/catch so a SecurityError or throwing listener cannot escape the React effect that runs onShow and tear down the tour overlay. Mirrors the defensive style in @/lib/tourRegistry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add getStateConfig(map, state, fallbackLabel?) — a null-safe,
prototype-pollution-safe resolver returning a neutral fallback
StateConfig (never undefined) so callers can read .label/.color/.variant
without a guard. Mirrors the enums.ts / FSMBadge / getActivityVisual
fallback idiom; reuses a module-level singleton on the hot path.

Add comprehensive co-located Vitest coverage for every export: data
integrity across all six state maps (valid hex color, valid variant,
non-empty label), a backend-FSM drift guard on vehicleStates, and full
getStateConfig behaviour — exact hits, unknown/null/undefined/empty
fallback, custom fallback label, prototype-key regression, purity and
the StateConfig shape contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…idget.tsx

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add comprehensive Vitest coverage for the charging onboarding tour: identity/shape, launcher-only (no autoStart), registry resolution, step well-formedness + unique ordered spotlight targets, routeMatch RegExp accept/reject, and the onShow imperative-navigation side effects (pushState + popstate), the no-op guard when already on-route, and the invariant that every navigating step lands on a path its own routeMatch covers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…orsWidget.tsx

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…alysis.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
atulmgupta and others added 21 commits July 6, 2026 04:28
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a comprehensive co-located Vitest suite covering every runtime export of the charge-session FSM (states, entries/theming, triggers, guards, transitions, edges, disallowed<->coverage consistency, coverage matrix, scenarios, FSM assembly + registry integration, and ChargeSignalContext shape).

Fix a latent coverage-matrix bug: the four CHARGE_SESSION_DISALLOWED pairs were marked null instead of 'disallowed', so isValidTransition() reported them as ambiguous 'no info' rather than forbidden-with-reason. Align them to 'disallowed' to match the vehicle FSM contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add comprehensive co-located Vitest suite (27 cases) covering deriveEdges and isValidTransition plus every exported FSM type contract. Harden deriveEdges with a null-safe input guard and a collision-safe JSON composite dedup key, and make isValidTransition null-safe when the coverage matrix is missing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add direct whole-module coverage for the vehicle FSM (states, entries, labels, triggers, guards, transitions, disallowed, coverage matrix, truth table, scenarios, edges, FSM wiring, signal context, deriveVehicleStatus) with trigger-level truth-table/transition consistency checks stronger than the registry sweep.

Fix deriveVehicleStatus JSDoc: it claimed an 'offline fallback' but returns 'online' when a state object exists without a stronger signal (matches the tested twin in api/types.ts). Comment corrected; behaviour unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…vation

The per-unit gate only ran 'go test -race' on each unit's own package, so
cross-package regressions surfaced only in the aggregate 'go test -race ./...'
validation. Fixes:

- api/{energy,teslachargehist,teslachargesess,teslaenergylivestatus,
  teslauserconfig,teslauserorder,teslauserprofile,vehicleaccess}: handler
  construction tests passed nil pools into eager, nil-hostile constructors
  (db.Pool nil-panic / 'db must not be nil'). Pass construction-safe
  &database.DB{} / &tesla.Client{} instead.
- adapter/postgres: tripRepository used a concrete *pgxpool.Pool field while
  every sibling repo uses the pgxPool interface seam; align it so the fake
  pool injects, and wrap CollectRows errors with context ('collecting trips
  for vehicle') to match the getters.
- api/apiauthctx: add the arch-required doc.go // Layer: handler (package was
  extracted by an elevation unit that fixed a real 403 bug but omitted doc.go).
- web/src/ai: regenerate stale aigen mirrors (pre-existing drift) via
  'go run ./tools/aigen'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
30 elevation-added FE test files passed in isolation (the per-unit gate ran
only that file) but failed in the full 'vitest run' because later units
hardened shared components/hooks/formatting, leaving stale expectations.
Fixed all 30 to assert current behaviour; corrected real source bugs found
along the way:

- cost-analysis useCostAnalysisData: fix double distance conversion (was
  metres->miles before a display fn that converts again) — pass SI metres
  directly; add null-safety + finite guards.
- useVehiclePhoto, BreadcrumbOverridesContext, AutomationBuilderPage,
  ExportStatusWidget, TirePressureVisualWidget, TripReplayPage, InfoTile,
  TelemetryGrid: null-safety / merge / unit-display hardening surfaced by tests.

Full suite: 1574 test files / 23021 tests pass; tsc --noEmit clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 6, 2026 16:27
@atulmgupta
atulmgupta merged commit 576d863 into main Jul 6, 2026
5 of 9 checks passed
@atulmgupta
atulmgupta deleted the experimental-touch branch July 6, 2026 16:28

Copilot AI 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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@atulmgupta
atulmgupta restored the experimental-touch branch July 12, 2026 06:36
@atulmgupta
atulmgupta deleted the experimental-touch branch July 16, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants