Skip to content

perf(web): IndexedDB paint cache, shared freshness loader in list view, drop global Live Tracking#85

Merged
JamesReate merged 2 commits into
mainfrom
perf/idb-paint-cache
Jul 9, 2026
Merged

perf(web): IndexedDB paint cache, shared freshness loader in list view, drop global Live Tracking#85
JamesReate merged 2 commits into
mainfrom
perf/idb-paint-cache

Conversation

@JamesReate

Copy link
Copy Markdown
Member

Why

For a ~500-vehicle tenant the fleet views were generating avoidable DIMO telemetry load, and cold loads waited a full network round-trip before painting anything:

  • The global Live Tracking button force-refreshed the entire fleet every 60s, bypassing both the 5-min locationPulledAt freshness window and the backend 45s cache (~500 telemetry queries/min while enabled).
  • fleet-list-view had its own inline location fan-out that ignored the freshness window and DB seeding — it re-pulled every vehicle on each cold visit.
  • Nothing persisted across hard reloads, so the map was blank until /vehicles returned.

What

  • FleetCache → IndexedDB write-through (idb-keyval, key fleet:${tenantId}, 24h max age). Map and list views paint instantly from the last snapshot on cold load, then always revalidate: /vehicles still fetched, stale-only fan-out still runs, server data replaces the paint. Markers are pruned after a persisted paint so removed vehicles don't ghost. invalidate() also deletes the persisted entry.
  • List view unified onto the shared loader (seedLocationsFromDb + fetchFleetLocations), so it respects the 5-min window and streams stale-only — identical backend load profile to the map view.
  • Global Live Tracking removed (top-bar button + map-legend timer duplicate, interval state, CSS, es strings). Per-vehicle live tracking is unchanged: the quick-view "Real-time · 20s" toggle.
  • Freshness window stays at 5 min (server-stamped locationPulledAt, shared across users/devices — deliberately not moved client-side).
  • Docs: LOCATION_REFRESH_PLAN.md status updated (was still "pre-implementation").

Verification (live, 430-vehicle James Fleet tenant)

  • Hard reload within the window: instant paint, /vehicles 200, zero /telemetry/locations requests
  • Hard reload on List View after stamps aged: partial refresh — only ~115 stale vehicles re-pulled, not 430
  • Force refresh: full re-pull (window bypassed as intended)
  • Snapshot tampered to 25h old: ignored gracefully, normal load, entry rewritten fresh
  • Quick-view Real-time toggle verified on a live (in-trip) vehicle
  • tsc clean, ESLint 0 errors, localize extract/build regenerated (only the 3 removed strings)

🤖 Generated with Claude Code

https://claude.ai/code/session_01UxoaxTXSLqUwkYfewdwGBM

JamesReate and others added 2 commits July 9, 2026 16:51
…w, drop global Live Tracking

Make the fleet views cheaper against DIMO APIs (~500-vehicle tenants) and
faster to paint on cold load:

- FleetCache now writes through to IndexedDB (idb-keyval, one snapshot per
  tenant, 24h max age). Map and list views paint instantly from the last
  snapshot on a hard reload, then always revalidate against /vehicles —
  paint-only, server wins; markers for vehicles no longer in the fleet are
  pruned after a persisted paint.
- fleet-list-view drops its private always-pull-everything location fan-out
  for the shared seedLocationsFromDb + fetchFleetLocations, so it now
  respects the 5-min locationPulledAt freshness window instead of re-pulling
  every vehicle on each visit.
- Remove the global "Live Tracking" button (top bar + map legend): it force-
  refreshed the entire fleet every 60s, bypassing both the freshness window
  and the backend 45s cache. Per-vehicle live tracking stays via the
  quick-view "Real-time · 20s" toggle.

Live-verified against the 430-vehicle fleet: zero /telemetry/locations on
reload within the window, partial refresh re-pulls only stale vehicles,
force refresh still re-pulls all, expired snapshots ignored gracefully.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UxoaxTXSLqUwkYfewdwGBM
The committed bundle lost the two eslint-disable comments during a local
stash round-trip, tripping CI's localize drift check. Regenerated via
npm run localize; no message changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UxoaxTXSLqUwkYfewdwGBM
@JamesReate JamesReate merged commit bf0d910 into main Jul 9, 2026
3 checks passed
@JamesReate JamesReate deleted the perf/idb-paint-cache branch July 9, 2026 21:15
JamesReate added a commit that referenced this pull request Jul 10, 2026
Ships #85 (IndexedDB paint cache, shared freshness loader in list view,
remove global Live Tracking) and #86 (vehicles.vin backfill from the DIMO
VIN VC).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UxoaxTXSLqUwkYfewdwGBM
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