fsanyoto commited on
Commit
7ffb400
Β·
verified Β·
1 Parent(s): 3561f1e

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "8689deb",
3
  "releases": [
4
  {
5
  "version": "v62",
 
1
  {
2
+ "current": "2824bc7",
3
  "releases": [
4
  {
5
  "version": "v62",
VERSION CHANGED
@@ -1 +1 @@
1
- 8689deb
 
1
+ 2824bc7
web/src/customer-grid/MapView.tsx CHANGED
@@ -625,6 +625,13 @@ export function MapView({
625
  const [routeOn, setRouteOn] = useState(false);
626
  /** Route navigation is an index first; planning begins only after the explicit Create route
627
  * action or an existing saved route has been opened. */
 
 
 
 
 
 
 
628
  const [roundTrip, setRoundTrip] = useState(false);
629
  const [routeStartPid, setRouteStartPid] = useState<number | null>(null);
630
  const askRoadRef = useRef(false);
@@ -2762,7 +2769,7 @@ export function MapView({
2762
  // migration code, but its second navigator is deliberately gone. Keep these compatibility
2763
  // hooks live until route-order columns are retired server-side; none renders a second Route UI.
2764
  void [
2765
- formatDuration, ROUTE_STOP_CAP, RecordPicker, setRoundTrip, setDepot, setTravelMode, travelModes,
2766
  roadBusy, roadErr, routeEditBusy, routeEditErr, routeCopyMsg,
2767
  openErr, naming, nameDraft, setNameDraft,
2768
  saveBusy, saveMsg, saveErr, unroutable, unroutableNames,
@@ -3534,6 +3541,12 @@ export function MapView({
3534
  onOpenRecord={onOpen}
3535
  stopLabels={routeStopLabels}
3536
  stopCoords={routeStopCoords}
 
 
 
 
 
 
3537
  onCreate={createNamedRoute}
3538
  onMoveToOrder={moveNamedRouteStop}
3539
  onUpdate={updateNamedRoute}
 
625
  const [routeOn, setRouteOn] = useState(false);
626
  /** Route navigation is an index first; planning begins only after the explicit Create route
627
  * action or an existing saved route has been opened. */
628
+ /** ⭐⭐ OWNER 2026-08-31 - *"wtf I don't see the button to make it either 1 single trip or
629
+ * round trip. The algorithm was there its not being displayed anymore"*. Correct, and the
630
+ * record was in the code: this state's ONLY writer, `setRoundTrip`, sat in the retired
631
+ * `void []` compatibility list below, so the value was pinned at false with no control
632
+ * anywhere while `planRoute`, `twoOptOrder`, `tourLength` and `routes_geo.py` all still read
633
+ * it. It lives HERE, not in `RouteNav`, because the drawn `plan` and the panel's drive time
634
+ * have to answer the same question - two copies is how they come to disagree. */
635
  const [roundTrip, setRoundTrip] = useState(false);
636
  const [routeStartPid, setRouteStartPid] = useState<number | null>(null);
637
  const askRoadRef = useRef(false);
 
2769
  // migration code, but its second navigator is deliberately gone. Keep these compatibility
2770
  // hooks live until route-order columns are retired server-side; none renders a second Route UI.
2771
  void [
2772
+ formatDuration, ROUTE_STOP_CAP, RecordPicker, setDepot, setTravelMode, travelModes,
2773
  roadBusy, roadErr, routeEditBusy, routeEditErr, routeCopyMsg,
2774
  openErr, naming, nameDraft, setNameDraft,
2775
  saveBusy, saveMsg, saveErr, unroutable, unroutableNames,
 
3541
  onOpenRecord={onOpen}
3542
  stopLabels={routeStopLabels}
3543
  stopCoords={routeStopCoords}
3544
+ roundTrip={roundTrip}
3545
+ onRoundTripChange={setRoundTrip}
3546
+ onStopAdded={(updated) => setNamedRoutes((current) => current.map((item) =>
3547
+ item.id === updated.id
3548
+ ? { ...item, ...updated, folderId: item.folderId, navOrder: item.navOrder }
3549
+ : item))}
3550
  onCreate={createNamedRoute}
3551
  onMoveToOrder={moveNamedRouteStop}
3552
  onUpdate={updateNamedRoute}
web/src/customer-grid/RouteNav.tsx CHANGED
@@ -91,10 +91,19 @@ function IconRoute() {
91
  );
92
  }
93
  const SETTLE_DEBOUNCE_MS = 400;
94
- /** Both halves of the figure must ask the same question, or the number jumps on drop by the size
95
- * of a closing edge and the reorder gets blamed for it. These two travel together, into
96
- * `previewSeconds` during the drag and into the request body on drop. */
97
- const ROUTE_ROUND_TRIP = false;
 
 
 
 
 
 
 
 
 
98
  const ROUTE_MODE = "driving";
99
 
100
  /**
@@ -140,7 +149,8 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
140
  onMoveToOrder, onUpdate, onDuplicate, onDelete, onShare, onRouteMove, onRouteReorder, stopLabels = {},
141
  stopCoords = {},
142
  onFolderCreate, onFolderUpdate, onFolderDelete, onFolderReorder, onCreateStart, mapLinks, mapLinkRefusal, deliveries, onSchedule,
143
- onDeleteDelivery, assignees, routeToday, assigneeError, zones = [] }: {
 
144
  routes: MapRouteDto[];
145
  folders: MapRouteFolderDto[];
146
  selectedIds: ReadonlySet<string>;
@@ -192,6 +202,13 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
192
  * mounts in a render harness with no host behind it. An empty list renders the selector
193
  * disabled with a sentence, never a silently empty dropdown. */
194
  zones?: MapZoneDto[];
 
 
 
 
 
 
 
195
  }) {
196
  /* ⭐⭐ OWNER 2026-08-31 item 3 - THE ROUTES RAIL IS THE VIEWS RAIL, NOT A COUSIN OF IT.
197
  Owner: *"I need the routes LIST navigation and the routes itself to have the exact same
@@ -234,8 +251,10 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
234
  const [folderName, setFolderName] = useState("");
235
  const [sourceId, setSourceId] = useState<MapRouteSource["id"]>("selection");
236
  const [error, setError] = useState<string | null>(null);
237
- const [orderDrafts, setOrderDrafts] = useState<Record<number, string>>({});
238
  const [orderErrors, setOrderErrors] = useState<Record<number, string>>({});
 
 
 
239
  const [titleDraft, setTitleDraft] = useState<string | null>(null);
240
  const [editMapsUrl, setEditMapsUrl] = useState("");
241
  /** D-599 - the Route's Zone, as a draft, saved by the same Save Route button as the Maps URL. */
@@ -293,6 +312,31 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
293
  ),
294
  [activeStopIds, activeStopRouteId, removedStops]
295
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  const assigneeNames = useMemo(
297
  () => new Set((assignees || []).map((person) => person.username)),
298
  [assignees]
@@ -367,7 +411,6 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
367
  setEditMapsUrl(route?.mapsUrl || "");
368
  setEditZoneId(route?.zoneId || "");
369
  setEditColor((route?.color || ROUTE_SWATCHES[0]).toUpperCase());
370
- setOrderDrafts({});
371
  setOrderErrors({});
372
  setDeleteConfirm(false);
373
  setError(null);
@@ -478,11 +521,6 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
478
  setOrderErrors((current) => ({ ...current, [pid]: message }));
479
  return;
480
  }
481
- setOrderDrafts((current) => {
482
- const next = { ...current };
483
- delete next[pid];
484
- return next;
485
- });
486
  setOrderErrors((current) => {
487
  const next = { ...current };
488
  delete next[pid];
@@ -490,6 +528,47 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
490
  });
491
  }).finally(() => setBusy(false));
492
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
  const commitStopRemove = (target: MapRouteDto, pid: number) => {
494
  setBusy(true);
495
  setOrderErrors((current) => {
@@ -514,11 +593,6 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
514
  setOrderErrors((current) => ({ ...current, [pid]: message }));
515
  return;
516
  }
517
- setOrderDrafts((current) => {
518
- const next = { ...current };
519
- delete next[pid];
520
- return next;
521
- });
522
  setRemovedStops((current) => current.routeId === target.id
523
  ? (current.pids.includes(pid) ? current : { routeId: target.id, pids: [...current.pids, pid] })
524
  : { routeId: target.id, pids: [pid] });
@@ -661,7 +735,7 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
661
  }
662
  if (order.length < 2) return null;
663
  const geo: GeoStop[] = locatedStops.map((stop) => ({ lat: stop.lat, lon: stop.lon }));
664
- return previewSeconds(order, geo, haversineKm, ROUTE_ROUND_TRIP);
665
  };
666
 
667
  const cancelSettle = () => {
@@ -697,7 +771,7 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
697
  // the one-click apply has no record to move. `fallback: true` is what makes an
698
  // arithmetic answer come back as `source: "haversine"` instead of an error.
699
  body: JSON.stringify({
700
- stops, mode: ROUTE_MODE, roundTrip: ROUTE_ROUND_TRIP, fallback: true,
701
  }),
702
  });
703
  const payload = await res.json().catch(() => null);
@@ -901,6 +975,21 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
901
  : timerLabel ? "Drive time" : "Add two located stops"}
902
  </span>
903
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
904
  {unlocatedCount > 0 && (
905
  <p className="cg-w46-timer-note">
906
  {unlocatedCount.toLocaleString()} stop{unlocatedCount === 1 ? " has" : "s have"} no
@@ -932,11 +1021,29 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
932
  ))}
933
  {timerError && <p className="cg-w46-timer-error" role="alert">{timerError}</p>}
934
  </section>
 
 
 
 
 
 
 
 
 
935
  {stopIds.length ? (
936
- <ol className="cg-w44-route-stops">
937
  {displayIds.map((pid, index) => (
938
  <li key={pid}
939
- className={dragPid === pid ? "cg-w46-stop-dragging" : undefined}
 
 
 
 
 
 
 
 
 
940
  onDragOver={(event) => {
941
  if (dragPid === null) return;
942
  event.preventDefault();
@@ -947,96 +1054,33 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
947
  event.preventDefault();
948
  dropStopDrag(stopView, pid);
949
  }}>
950
- {/* The grip is POINTER ONLY and hidden from assistive technology on purpose:
951
- Move earlier, Position and Move later already reorder this list from the
952
- keyboard, and a focusable duplicate of them would be a second tab stop that
953
- announces nothing a keyboard user can act on. */}
954
- {canEdit && (
955
- <span className="cg-w46-stop-grip" draggable aria-hidden="true"
956
- title="Drag to reorder this stop"
957
- onDragStart={(event) => {
958
- event.dataTransfer.effectAllowed = "move";
959
- try { event.dataTransfer.setData("text/plain", String(pid)); }
960
- catch { /* Some browsers refuse a payload; the drag still works. */ }
961
- beginStopDrag(pid);
962
- }}
963
- onDragEnd={() => endStopDrag()}>
964
- <svg viewBox="0 0 16 16" aria-hidden="true">
965
- <circle cx="6" cy="4" r="1" /><circle cx="10" cy="4" r="1" />
966
- <circle cx="6" cy="8" r="1" /><circle cx="10" cy="8" r="1" />
967
- <circle cx="6" cy="12" r="1" /><circle cx="10" cy="12" r="1" />
968
- </svg>
969
- </span>
970
- )}
971
- <button type="button" className="cg-w44-route-stop-open"
972
  aria-label={`Open stop ${index + 1} record`}
973
  aria-describedby={`cg-route-stop-name-${pid}`} onClick={() => onOpenRecord(pid)}>
974
  {/* The ordinal is furniture: it says where in the drive this falls, and the
975
  accessible name above already carries it, so it is hidden from the reader
976
  rather than announced twice. */}
977
  <span className="cg-w46-stop-index" aria-hidden="true">{index + 1}</span>
978
- <span className="cg-w46-stop-name" id={`cg-route-stop-name-${pid}`}>
979
- {stopIdentity(stopLabels[pid], pid)}
 
 
980
  </span>
981
  </button>
 
 
 
 
 
 
 
 
982
  {canEdit && (
983
- <span className="cg-w44-route-stop-actions">
984
- <button type="button" className="cg-w44-route-step" disabled={busy || index === 0}
985
- aria-label={`Move stop ${index + 1} earlier`}
986
- title="Move earlier" onClick={() => commitStopMove(stopView, pid, String(index))}>
987
- <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3 5 8l5 5" /></svg>
988
- </button>
989
- <label className="cg-w44-route-position"><span>Position</span>
990
- <input className="cg-w44-route-order" type="text" inputMode="numeric" pattern="[0-9]*"
991
- disabled={busy}
992
- value={orderDrafts[pid] ?? String(index + 1)}
993
- aria-invalid={orderErrors[pid] ? true : undefined}
994
- aria-describedby={orderErrors[pid] ? `cg-route-order-error-${pid}` : undefined}
995
- onFocus={(event) => event.currentTarget.select()}
996
- onChange={(event) => {
997
- const raw = event.target.value;
998
- setOrderDrafts((current) => ({ ...current, [pid]: raw }));
999
- setOrderErrors((current) => {
1000
- const next = { ...current };
1001
- delete next[pid];
1002
- return next;
1003
- });
1004
- }}
1005
- onKeyDown={(event) => {
1006
- if (event.key === "Enter") {
1007
- event.preventDefault();
1008
- commitStopMove(stopView, pid, event.currentTarget.value);
1009
- } else if (event.key === "Escape") {
1010
- event.preventDefault();
1011
- setOrderDrafts((current) => {
1012
- const next = { ...current };
1013
- delete next[pid];
1014
- return next;
1015
- });
1016
- setOrderErrors((current) => {
1017
- const next = { ...current };
1018
- delete next[pid];
1019
- return next;
1020
- });
1021
- }
1022
- }} />
1023
- </label>
1024
- <button type="button" className="cg-w44-route-position-apply" disabled={busy}
1025
- onClick={() => commitStopMove(stopView, pid, orderDrafts[pid] ?? String(index + 1))}>
1026
- Move
1027
- </button>
1028
- <button type="button" className="cg-w44-route-step"
1029
- disabled={busy || index === displayIds.length - 1}
1030
- aria-label={`Move stop ${index + 1} later`}
1031
- title="Move later" onClick={() => commitStopMove(stopView, pid, String(index + 2))}>
1032
- <svg viewBox="0 0 16 16" aria-hidden="true"><path d="m6 3 5 5-5 5" /></svg>
1033
- </button>
1034
- <button type="button" className="cg-w44-route-step" disabled={busy}
1035
- aria-label={`Remove stop ${index + 1} from this route`}
1036
- title="Remove stop" onClick={() => commitStopRemove(route, pid)}>
1037
- <svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8" /></svg>
1038
- </button>
1039
- </span>
1040
  )}
1041
  {orderErrors[pid] && <span id={`cg-route-order-error-${pid}`}
1042
  className="cg-w44-route-order-error" role="alert">{orderErrors[pid]}</span>}
@@ -1044,6 +1088,57 @@ export function RouteNav({ routes, folders, selectedIds, activeRouteId, sources,
1044
  ))}
1045
  </ol>
1046
  ) : <p className="cg-w44-route-empty">No stops yet. Add customers from a route source.</p>}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1047
  {mapsUrl && <a className="cg-w44-route-maps" href={mapsUrl} target="_blank" rel="noopener noreferrer">Open Maps</a>}
1048
  {route.mapsUrl && !mapsUrl && <span className="cg-w44-route-empty">Maps link is unavailable.</span>}
1049
  <section className="cg-w44-route-map-links" aria-labelledby="cg-route-map-links-title">
 
91
  );
92
  }
93
  const SETTLE_DEBOUNCE_MS = 400;
94
+ /** β›” BOTH HALVES OF THE FIGURE MUST ASK THE SAME QUESTION, or the number jumps on drop by the
95
+ * size of a closing edge and the reorder gets blamed for it. That is why the round-trip answer
96
+ * travels as ONE value into `previewSeconds` during the drag and into the request body on drop.
97
+ *
98
+ * ⭐⭐ OWNER 2026-08-31: *"wtf I don't see the button to make it either 1 single trip or round
99
+ * trip. The algorithm was there its not being displayed anymore"*. They are right, and the
100
+ * record says so in code: `MapView.tsx` holds `roundTrip` state whose only writer, `setRoundTrip`,
101
+ * sits in the retired `void []` compatibility list, so the value was pinned at false with no
102
+ * control anywhere. The solver (`mapProjection.ts::planRoute`, `twoOptOrder`, `tourLength`) and
103
+ * the server door (`routes_geo.py`, which reads `roundTrip` off the body) were both live the
104
+ * whole time. So this is a control being re-attached to an algorithm, not a feature being built.
105
+ * It is a PROP rather than local state because the map's drawn plan and this panel's timer must
106
+ * answer the same question; two copies is how they come to disagree. */
107
  const ROUTE_MODE = "driving";
108
 
109
  /**
 
149
  onMoveToOrder, onUpdate, onDuplicate, onDelete, onShare, onRouteMove, onRouteReorder, stopLabels = {},
150
  stopCoords = {},
151
  onFolderCreate, onFolderUpdate, onFolderDelete, onFolderReorder, onCreateStart, mapLinks, mapLinkRefusal, deliveries, onSchedule,
152
+ onDeleteDelivery, assignees, routeToday, assigneeError, zones = [],
153
+ roundTrip = false, onRoundTripChange, onStopAdded }: {
154
  routes: MapRouteDto[];
155
  folders: MapRouteFolderDto[];
156
  selectedIds: ReadonlySet<string>;
 
202
  * mounts in a render harness with no host behind it. An empty list renders the selector
203
  * disabled with a sentence, never a silently empty dropdown. */
204
  zones?: MapZoneDto[];
205
+ /** Owner 2026-08-31 - one way, or back to where the driver started. Owned by the host so the
206
+ * map's drawn plan and this panel's drive time cannot answer different questions. */
207
+ roundTrip?: boolean;
208
+ onRoundTripChange?: (value: boolean) => void;
209
+ /** The Route the membership door answered with, so the host's read model gains the new stop
210
+ * without a second fetch. Mirrors what `moveNamedRouteStop` already does on a reorder. */
211
+ onStopAdded?: (route: MapRouteDto) => void;
212
  }) {
213
  /* ⭐⭐ OWNER 2026-08-31 item 3 - THE ROUTES RAIL IS THE VIEWS RAIL, NOT A COUSIN OF IT.
214
  Owner: *"I need the routes LIST navigation and the routes itself to have the exact same
 
251
  const [folderName, setFolderName] = useState("");
252
  const [sourceId, setSourceId] = useState<MapRouteSource["id"]>("selection");
253
  const [error, setError] = useState<string | null>(null);
 
254
  const [orderErrors, setOrderErrors] = useState<Record<number, string>>({});
255
+ /** Owner 2026-08-31 - the add-record door's own two pieces of state. */
256
+ const [addStopOpen, setAddStopOpen] = useState(false);
257
+ const [addStopQuery, setAddStopQuery] = useState("");
258
  const [titleDraft, setTitleDraft] = useState<string | null>(null);
259
  const [editMapsUrl, setEditMapsUrl] = useState("");
260
  /** D-599 - the Route's Zone, as a draft, saved by the same Save Route button as the Maps URL. */
 
312
  ),
313
  [activeStopIds, activeStopRouteId, removedStops]
314
  );
315
+ /**
316
+ * ⭐ OWNER 2026-08-31 - the records the add-record dropdown may offer: everything in the book
317
+ * this panel already holds, minus what is already a stop.
318
+ *
319
+ * β›” CAPPED AT 50 WITH THE REMAINDER COUNTED, NEVER SILENTLY TRUNCATED. `stopLabels` covers the
320
+ * whole customer book (3,649 rows on tenant #0), and a menu that renders all of them is a
321
+ * frozen tab; one that renders the first fifty and says nothing is standing rule 1's silent
322
+ * cap. The overflow figure is printed with what to do about it.
323
+ */
324
+ const stopSet = useMemo(() => new Set(stopIds), [stopIds]);
325
+ const addStopMatches = useMemo(() => {
326
+ const needle = addStopQuery.trim().toLowerCase();
327
+ const out: { pid: number; label: string }[] = [];
328
+ for (const [key, value] of Object.entries(stopLabels)) {
329
+ const pid = Number(key);
330
+ if (!Number.isSafeInteger(pid) || stopSet.has(pid)) continue;
331
+ const label = stopIdentity(value, pid);
332
+ if (needle && !label.toLowerCase().includes(needle)) continue;
333
+ out.push({ pid, label });
334
+ }
335
+ out.sort((a, b) => a.label.localeCompare(b.label));
336
+ return out;
337
+ }, [addStopQuery, stopLabels, stopSet]);
338
+ const addableStops = useMemo(() => addStopMatches.slice(0, 50), [addStopMatches]);
339
+ const addStopOverflow = Math.max(0, addStopMatches.length - addableStops.length);
340
  const assigneeNames = useMemo(
341
  () => new Set((assignees || []).map((person) => person.username)),
342
  [assignees]
 
411
  setEditMapsUrl(route?.mapsUrl || "");
412
  setEditZoneId(route?.zoneId || "");
413
  setEditColor((route?.color || ROUTE_SWATCHES[0]).toUpperCase());
 
414
  setOrderErrors({});
415
  setDeleteConfirm(false);
416
  setError(null);
 
521
  setOrderErrors((current) => ({ ...current, [pid]: message }));
522
  return;
523
  }
 
 
 
 
 
524
  setOrderErrors((current) => {
525
  const next = { ...current };
526
  delete next[pid];
 
528
  });
529
  }).finally(() => setBusy(false));
530
  };
531
+ /**
532
+ * Put ONE record onto this Route, through the same membership door the x uses.
533
+ *
534
+ * β›” NO OPTIMISTIC ROW. The server answers with the whole Route and `onMoveToOrder`'s host
535
+ * already replaces the record from that answer; painting a stop locally first would show a
536
+ * position the server has not agreed to, and a refusal would then have to un-paint it.
537
+ */
538
+ const commitStopAdd = (target: MapRouteDto, pid: number) => {
539
+ setBusy(true);
540
+ setError(null);
541
+ void (async () => {
542
+ try {
543
+ const res = await fetch(
544
+ `/api/v1/customers/routes/${encodeURIComponent(target.id)}/stops/membership`,
545
+ {
546
+ method: "POST", credentials: "same-origin",
547
+ headers: { "Content-Type": "application/json" },
548
+ body: JSON.stringify({ customerPid: pid, present: true }),
549
+ }
550
+ );
551
+ const payload = await res.json().catch(() => null);
552
+ if (!res.ok) {
553
+ setError(payload?.error?.message || payload?.detail?.message
554
+ || "That record could not be added to this Route.");
555
+ return;
556
+ }
557
+ // The removal ledger is what hides a stop this session took OFF the Route. Adding the
558
+ // same record back has to clear its entry, or the row the server just returned would be
559
+ // filtered straight back out and the button would look broken.
560
+ setRemovedStops((current) => current.routeId === target.id
561
+ ? { routeId: target.id, pids: current.pids.filter((item) => item !== pid) }
562
+ : current);
563
+ const routeUpdate = payload?.route as MapRouteDto | undefined;
564
+ if (routeUpdate) onStopAdded?.(routeUpdate);
565
+ } catch {
566
+ setError("That record could not be added to this Route.");
567
+ } finally {
568
+ setBusy(false);
569
+ }
570
+ })();
571
+ };
572
  const commitStopRemove = (target: MapRouteDto, pid: number) => {
573
  setBusy(true);
574
  setOrderErrors((current) => {
 
593
  setOrderErrors((current) => ({ ...current, [pid]: message }));
594
  return;
595
  }
 
 
 
 
 
596
  setRemovedStops((current) => current.routeId === target.id
597
  ? (current.pids.includes(pid) ? current : { routeId: target.id, pids: [...current.pids, pid] })
598
  : { routeId: target.id, pids: [pid] });
 
735
  }
736
  if (order.length < 2) return null;
737
  const geo: GeoStop[] = locatedStops.map((stop) => ({ lat: stop.lat, lon: stop.lon }));
738
+ return previewSeconds(order, geo, haversineKm, roundTrip);
739
  };
740
 
741
  const cancelSettle = () => {
 
771
  // the one-click apply has no record to move. `fallback: true` is what makes an
772
  // arithmetic answer come back as `source: "haversine"` instead of an error.
773
  body: JSON.stringify({
774
+ stops, mode: ROUTE_MODE, roundTrip, fallback: true,
775
  }),
776
  });
777
  const payload = await res.json().catch(() => null);
 
975
  : timerLabel ? "Drive time" : "Add two located stops"}
976
  </span>
977
  </div>
978
+ {/* ⭐⭐ OWNER 2026-08-31 - ONE WAY, OR BACK TO THE START. It sits INSIDE the timer,
979
+ against the figure it changes, because a round trip adds the closing edge and
980
+ therefore a different number; a control for it anywhere else would move a number
981
+ the reader is not looking at. */}
982
+ {onRoundTripChange && (
983
+ <div className="w46-recur-row cg-w46-timer-trip">
984
+ <span className="w46-recur-label">Trip</span>
985
+ <div className="w46-recur-controls" role="group" aria-label="Trip shape">
986
+ <button type="button" className={"w46-recur-pill" + (roundTrip ? "" : " is-on")}
987
+ aria-pressed={!roundTrip} onClick={() => onRoundTripChange(false)}>One way</button>
988
+ <button type="button" className={"w46-recur-pill" + (roundTrip ? " is-on" : "")}
989
+ aria-pressed={roundTrip} onClick={() => onRoundTripChange(true)}>Round trip</button>
990
+ </div>
991
+ </div>
992
+ )}
993
  {unlocatedCount > 0 && (
994
  <p className="cg-w46-timer-note">
995
  {unlocatedCount.toLocaleString()} stop{unlocatedCount === 1 ? " has" : "s have"} no
 
1021
  ))}
1022
  {timerError && <p className="cg-w46-timer-error" role="alert">{timerError}</p>}
1023
  </section>
1024
+ {/* ⭐⭐ OWNER 2026-08-31 - THE STOP LIST IS THE RAIL, SAME FORMATTING.
1025
+ Owner: *"Same as the rail, same formatting too i believe"*, and then the exact scope:
1026
+ *"The only difference with the rail is that route you can have an x button to remove a
1027
+ record, and also an add record button where it provides the dropdown for the user to
1028
+ add more customer to the route."* So the row wears `.cg-view-row` / `.cg-view-main` /
1029
+ `.cg-view-text` / `.cg-view-name` exactly as a Route row does, drags whole rather than
1030
+ by a grip, and carries the ordinal in the purple disc where the rail carries the Route
1031
+ mark. The `<ol>` stays an `<ol>`: a drive IS an ordered list, and the class the panel's
1032
+ own stylesheet targets rides alongside the rail's. */}
1033
  {stopIds.length ? (
1034
+ <ol className="cg-w44-route-stops cg-view-list">
1035
  {displayIds.map((pid, index) => (
1036
  <li key={pid}
1037
+ className={"cg-view-row cg-w46-stop-row" + (dragPid === pid ? " is-viewdrag" : "")}
1038
+ draggable={canEdit}
1039
+ onDragStart={(event) => {
1040
+ if (!canEdit) return;
1041
+ event.dataTransfer.effectAllowed = "move";
1042
+ try { event.dataTransfer.setData("text/plain", String(pid)); }
1043
+ catch { /* Some browsers refuse a payload; the drag still works. */ }
1044
+ beginStopDrag(pid);
1045
+ }}
1046
+ onDragEnd={() => endStopDrag()}
1047
  onDragOver={(event) => {
1048
  if (dragPid === null) return;
1049
  event.preventDefault();
 
1054
  event.preventDefault();
1055
  dropStopDrag(stopView, pid);
1056
  }}>
1057
+ <button type="button" className="cg-view-main"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1058
  aria-label={`Open stop ${index + 1} record`}
1059
  aria-describedby={`cg-route-stop-name-${pid}`} onClick={() => onOpenRecord(pid)}>
1060
  {/* The ordinal is furniture: it says where in the drive this falls, and the
1061
  accessible name above already carries it, so it is hidden from the reader
1062
  rather than announced twice. */}
1063
  <span className="cg-w46-stop-index" aria-hidden="true">{index + 1}</span>
1064
+ <span className="cg-view-text">
1065
+ <span className="cg-view-name" id={`cg-route-stop-name-${pid}`}>
1066
+ {stopIdentity(stopLabels[pid], pid)}
1067
+ </span>
1068
  </span>
1069
  </button>
1070
+ {/* β›” OWNER 2026-08-31, TWICE: *"the < > for the route panel where you can choose
1071
+ the numbers i thought they're deleted. I still see them up"*. Move earlier,
1072
+ Position, Move and Move later are gone; DRAG IS THE GESTURE, exactly as it now
1073
+ is for a Route row. The x stays because removing a stop is not a reorder and a
1074
+ drag cannot express it - it is the one difference the owner named.
1075
+ ⚠ THE COST, SAID OUT LOUD: those four controls were the KEYBOARD path, so a
1076
+ stop can no longer be reordered without a pointer. Recorded here so the next
1077
+ reader does not read it as an oversight and quietly put them back. */}
1078
  {canEdit && (
1079
+ <button type="button" className="cg-view-more cg-w46-stop-remove" disabled={busy}
1080
+ aria-label={`Remove stop ${index + 1} from this route`}
1081
+ title="Remove stop" onClick={() => commitStopRemove(route, pid)}>
1082
+ <svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8" /></svg>
1083
+ </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1084
  )}
1085
  {orderErrors[pid] && <span id={`cg-route-order-error-${pid}`}
1086
  className="cg-w44-route-order-error" role="alert">{orderErrors[pid]}</span>}
 
1088
  ))}
1089
  </ol>
1090
  ) : <p className="cg-w44-route-empty">No stops yet. Add customers from a route source.</p>}
1091
+ {/* ⭐⭐ OWNER 2026-08-31 - THE OTHER DIFFERENCE FROM THE RAIL: *"an add record button
1092
+ where it provides the dropdown for the user to add more customer to the route."*
1093
+ It wears the rail's own `.cg-create-new` shape, and its list is the rail's
1094
+ `.cg-find-view` box over the book the panel ALREADY HOLDS: `stopLabels` is built from
1095
+ `allRows` in `MapView`, so this needs no second fetch and can only offer records the
1096
+ reader can already see. β›” The write is the SAME membership door the x uses, with
1097
+ `present: true` - one door for both directions, so a stop cannot be added through a
1098
+ path the removal wall does not guard. */}
1099
+ {canEdit && (
1100
+ <div className="cg-create-new cg-w46-stop-add">
1101
+ <button type="button" className="cg-link-btn cg-create-btn" aria-haspopup="menu"
1102
+ aria-expanded={addStopOpen} disabled={busy}
1103
+ onClick={() => { setAddStopOpen(!addStopOpen); setAddStopQuery(""); }}>
1104
+ <span className="cg-create-icon" aria-hidden="true">+</span>
1105
+ <span className="cg-create-label">Add record…</span>
1106
+ </button>
1107
+ {addStopOpen && (
1108
+ <div className="cg-view-menu cg-w46-stop-addmenu" role="menu">
1109
+ <div className="cg-find-view">
1110
+ <svg className="cg-find-view-icon" width="14" height="14" viewBox="0 0 16 16"
1111
+ fill="none" aria-hidden="true">
1112
+ <circle cx="7" cy="7" r="4.4" stroke="currentColor" strokeWidth="1.35" />
1113
+ <path d="m10.4 10.4 3.1 3.1" stroke="currentColor" strokeWidth="1.35"
1114
+ strokeLinecap="round" />
1115
+ </svg>
1116
+ <input type="text" value={addStopQuery} placeholder="Find…" autoFocus
1117
+ aria-label="Find a record to add to this Route"
1118
+ onChange={(event) => setAddStopQuery(event.target.value)}
1119
+ onKeyDown={(event) => { if (event.key === "Escape") setAddStopOpen(false); }} />
1120
+ </div>
1121
+ {addableStops.length ? addableStops.map((candidate) => (
1122
+ <button type="button" role="menuitem" key={candidate.pid} disabled={busy}
1123
+ onClick={() => { setAddStopOpen(false); commitStopAdd(route, candidate.pid); }}>
1124
+ {candidate.label}
1125
+ </button>
1126
+ )) : (
1127
+ <span className="cg-w44-route-empty">
1128
+ {addStopQuery.trim()
1129
+ ? "No record matches that search."
1130
+ : "Every record you can see is already on this Route."}
1131
+ </span>
1132
+ )}
1133
+ {addStopOverflow > 0 && (
1134
+ <span className="cg-w44-route-empty">
1135
+ {addStopOverflow.toLocaleString()} more match. Keep typing to narrow them.
1136
+ </span>
1137
+ )}
1138
+ </div>
1139
+ )}
1140
+ </div>
1141
+ )}
1142
  {mapsUrl && <a className="cg-w44-route-maps" href={mapsUrl} target="_blank" rel="noopener noreferrer">Open Maps</a>}
1143
  {route.mapsUrl && !mapsUrl && <span className="cg-w44-route-empty">Maps link is unavailable.</span>}
1144
  <section className="cg-w44-route-map-links" aria-labelledby="cg-route-map-links-title">
web/src/styles/wave42/route-nav.css CHANGED
@@ -528,3 +528,62 @@
528
  background: transparent;
529
  cursor: pointer;
530
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  background: transparent;
529
  cursor: pointer;
530
  }
531
+
532
+ /* ── OWNER 2026-08-31: the stop list is the rail, with an x and an add door ─────────────────
533
+ Owner: *"Same as the rail, same formatting too i believe"* / *"The only difference with the
534
+ rail is that route you can have an x button to remove a record, and also an add record button
535
+ where it provides the dropdown."* The rows already wear `.cg-view-row` and `.cg-view-main`, so
536
+ index.css sizes and hovers them; only the two differences and the list reset live here. */
537
+ #cg-route-popover .cg-w44-route-stops.cg-view-list {
538
+ margin: 0;
539
+ padding: 0;
540
+ list-style: none;
541
+ }
542
+
543
+ #cg-route-popover .cg-w46-stop-row.is-viewdrag { opacity: 0.45; }
544
+
545
+ /* The x. It takes `.cg-view-more`'s box, so it appears on hover exactly as the rail's "..." does
546
+ and cannot widen the row. */
547
+ #cg-route-popover .cg-w46-stop-remove {
548
+ display: grid;
549
+ place-items: center;
550
+ color: var(--lp-muted);
551
+ }
552
+
553
+ #cg-route-popover .cg-w46-stop-remove:hover { color: var(--lp-red-deep, #b3261e); }
554
+
555
+ #cg-route-popover .cg-w46-stop-remove svg {
556
+ width: 12px;
557
+ height: 12px;
558
+ fill: none;
559
+ stroke: currentColor;
560
+ stroke-width: 1.6;
561
+ stroke-linecap: round;
562
+ }
563
+
564
+ /* The add-record door and its menu. `position: relative` is what keeps the popover tied to the
565
+ button rather than to the scrolling panel, which is where a menu goes wandering. */
566
+ #cg-route-popover .cg-w46-stop-add { position: relative; }
567
+
568
+ #cg-route-popover .cg-w46-stop-addmenu {
569
+ position: absolute;
570
+ z-index: var(--cg-z-menu);
571
+ left: 0;
572
+ right: 0;
573
+ max-height: 280px;
574
+ overflow-y: auto;
575
+ }
576
+
577
+ /* One row per candidate, ellipsised: a customer name is arbitrary length and a menu that grows
578
+ sideways pushes the panel off the map. */
579
+ #cg-route-popover .cg-w46-stop-addmenu button[role="menuitem"] {
580
+ display: block;
581
+ width: 100%;
582
+ overflow: hidden;
583
+ text-align: left;
584
+ text-overflow: ellipsis;
585
+ white-space: nowrap;
586
+ }
587
+
588
+ /* One way / Round trip, inside the drive-time card it changes. */
589
+ #cg-route-popover .cg-w46-timer-trip { padding-top: 8px; }