* feat(mileage): prefill distance and purpose from earlier trips on the same route
Christoffer's beta feedback: recurring routes meant retyping the same km
every time. Fran/Till now autocomplete from earlier trips, and when the
pair matches a previous trip the one-way distance and purpose prefill
from the latest match. Only empty fields are filled, edit mode is
untouched, and a hint under the km field shows when a value came from
route memory.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mileage): invalidate route prefill when the route changes
Skeptic + review findings on the first push, resolved in one pass:
- Stale prefill: km/purpose filled from a matched route survived onto a
different route (typing past the match, or switching Fran), with the
hint still claiming same-route provenance. Prefill state now tracks
the route key and the exact prefilled strings; when the key changes,
fields still holding those strings are cleared and the match re-derives
for the new route. User-typed values are never touched.
- Purpose was filled with no indicator: the hint now renders under both
km and purpose, each cleared independently by manual edits.
- Prefill now uses the unrounded half of a stored round trip (21.25, as
the copy flow does) so the round-trip toggle re-doubles to the exact
stored km.
- Per-keystroke O(n log n) sort replaced with a WeakMap-cached sorted
order per trips array.
- Docstrings on all route-memory exports.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mileage): offer a route's prefill at most once and drop stray NUL byte
Second skeptic pass on the rework found two issues, both fixed:
- Same-key refill rebuilt the prefill record from scratch, dropping the
other field's live tracking and re-filling a field the user had
deliberately emptied. applyRoutePrefill now matches only when no
record exists for the current route key; the record survives as an
offered-marker even fully disowned, so per-field tracking is stable
and an emptied field stays empty until the route actually changes.
- routeKey embedded a raw 0x00 byte as separator, which made git treat
the file as binary and killed diff review. The separator is now an
explicit String.fromCharCode(10) newline, which normalizeLocation can
never produce, keeping keys collision-free and the source printable.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>