WFDASH-WEBAPP/docs/superpowers/specs
Dave 6fd11f4af0 feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection
Groundwork for the rep visit check-in feature: a rep taps "I'm on site",
the vehicle's tracker position surfaces which customers are there, and
the visit is logged against them.

Pure/unit-testable layers only — no PocketBase writes and no UI yet,
both of which are blocked on schema that has to be added in the PB
admin first. Design doc: docs/superpowers/specs/2026-09-05-rep-visit-check-in-design.md

- lib/visit-matching.ts   rankNearbyCustomers: radius match around a
                          point, rep's own customers first
- lib/visit-stops.ts      detectStops: breadcrumb trail -> stops.
                          Anchor-based clustering rather than a running
                          centroid, which would let a slow crawl chain
                          into one bogus stationary stop
- lib/tracker-parsing.ts  Netstar FleetAI response decoding
- lib/server/tracker-service.ts
                          FleetAiAdapter + FakeTrackerAdapter behind a
                          TrackerAdapter seam. The fake is auto-selected
                          when no credentials are configured, so the rest
                          of the feature builds and tests without vendor
                          access.
- lib/geo.ts              isRealGeoPoint, lifting the Null-Island guard
                          that was inlined identically in customers/[id]
                          and companies/[id]

Three FleetAI conventions drive real code here and are each pinned by a
test: errors arrive as HTTP 200 with a failure envelope; "--" means
"unavailable" and is not null (and for IGN, not false); timestamps are
platform-local UTC+2 with no offset marker, so parsing them naively puts
every fresh fix two hours in the past.

FleetAI has no position-history endpoint, so the design polls
getTokenBaseLiveData (whole fleet in one call) and keeps its own trail.
scripts/fleetai-probe.mjs is a throwaway read-only probe to confirm the
three account-shaped assumptions before more is built on top.

102 tests pass. The 9 pre-existing failing test files elsewhere in the
suite were verified identical on a stashed tree and are unrelated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 14:22:28 +02:00
..
2026-07-07-collection-confirm-bulk-and-search-design.md
2026-07-07-collection-confirm-enhancements-design.md
2026-07-07-collection-confirm-fixes-design.md
2026-07-07-collection-confirm-page-design.md
2026-07-07-collection-confirm-selection-and-return-design.md
2026-07-07-collection-pool-cluster-sort-design.md
2026-07-07-collection-pool-redesign-design.md
2026-07-07-invoicing-page-design.md
2026-07-07-invoicing-print-and-quickbooks-design.md
2026-07-07-invoicing-quickbooks-customer-modal-design.md
2026-07-08-invoicing-quickbooks-writeback-design.md
2026-07-08-invoicing-redesign-and-pdf-upload-design.md
2026-07-09-collection-confirm-rewrite-design.md
2026-07-09-collection-map-date-filter-and-unassign-design.md
2026-07-09-collection-pool-mark-ready-notes-design.md
2026-07-09-collection-pool-nearby-sort-design.md
2026-07-09-customer-search-company-disambiguation-design.md
2026-07-09-invoice-bulk-print-tracking-design.md
2026-07-09-invoice-print-bundle-design.md
2026-07-09-new-quote-form-redesign-design.md
2026-07-09-order-color-stripe-design.md
2026-07-09-picking-slip-supplier-pickedby-design.md
2026-07-09-po-additional-attachments-design.md
2026-07-09-po-pdf-token-vs-filename-design.md
2026-07-10-collection-pool-supplier-groups-and-notes-design.md
2026-07-11-collection-map-simplify-pins-design.md
2026-07-12-collection-map-driver-cards-redesign-design.md
2026-07-12-collection-map-drop-date-filter-and-ready-gate-design.md
2026-07-29-buyer-tasks-design.md
2026-07-29-order-sprint-item-history-design.md
2026-07-29-orders-review-modal-design.md
2026-07-30-stock-quick-draft-design.md
2026-08-02-collection-confirm-revamp-design.md
2026-08-03-buyer-tasks-mail-failed-recovery-design.md
2026-08-03-stock-orders-total-value-design.md
2026-08-03-stock-orders-wrap-pdf-design.md
2026-08-06-buyer-tasks-resend-button-design.md
2026-08-06-supplier-po-pdf-vat-design.md
2026-08-07-order-item-context-block-design.md
2026-08-26-no-quote-design.md
2026-08-27-approve-and-send-from-list-design.md
2026-08-27-boss-phone-dashboard-design.md
2026-08-29-order-delivery-note-match-design.md docs(orders): spec + plan for delivery-note repeat-order detection 2026-08-29 23:51:52 +02:00
2026-08-29-order-quote-linking-design.md
2026-08-30-non-invoiceable-order-extras-design.md docs: non-invoiceable extras design + plan, quantity-handling audit 2026-08-30 18:28:44 +02:00
2026-08-30-quantity-handling-audit.md docs: non-invoiceable extras design + plan, quantity-handling audit 2026-08-30 18:28:44 +02:00
2026-08-30-wfsales-pos-design.md docs(pos): add design spec for WFSALES POS app 2026-08-30 23:50:56 +02:00
2026-08-31-stock-pricing-inline-edit-design.md docs(stock): reconcile spec with shipped design 2026-08-31 17:19:12 +02:00
2026-09-01-deliveries-dn-items-expand-design.md docs: clarify unit suffix handling in DN items panel header 2026-09-01 12:01:42 +02:00
2026-09-01-delivery-row-info-and-order-age-badge-design.md docs: spec for compact DN row + order age badge 2026-09-01 01:56:28 +02:00
2026-09-01-rep-dashboard-design.md docs: add design spec for rep dashboard (dashboard 2) 2026-09-01 01:25:53 +02:00
2026-09-04-pos-slip-layout-editor-design.md docs(pos): add design spec for the slip layout editor 2026-09-04 12:42:45 +02:00
2026-09-05-rep-visit-check-in-design.md feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection 2026-09-06 14:22:28 +02:00