fsanyoto commited on
Commit
1f54fa6
·
verified ·
1 Parent(s): 9e8f025

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,6 +1,12 @@
1
  {
2
- "current": "v41 (1d6adcc)",
3
  "releases": [
 
 
 
 
 
 
4
  {
5
  "version": "v41",
6
  "sha": "1d6adcc",
 
1
  {
2
+ "current": "v42 (25b885e)",
3
  "releases": [
4
+ {
5
+ "version": "v42",
6
+ "sha": "25b885e",
7
+ "date": "2026-08-23",
8
+ "subject": "release v42"
9
+ },
10
  {
11
  "version": "v41",
12
  "sha": "1d6adcc",
VERSION CHANGED
@@ -1 +1 @@
1
- v41 (1d6adcc)
 
1
+ v42 (25b885e)
api/routes_customers.py CHANGED
@@ -845,10 +845,11 @@ def route_order_write(body: dict = Body(default=None),
845
  defn = {
846
  "key": key,
847
  "label": label or (existing or {}).get("label") or key,
848
- # ⛔ `int`, NEVER `text`. A text column sorts 1, 10, 11, 2 — fully populated, entirely
849
- # plausible, wrong, and named by no gate. `patch_shared_cell` defaults to text; this door
850
- # cannot.
851
- "type": "int",
 
852
  "source": "overlay",
853
  "shared": True,
854
  "kind": ROUTE_KIND,
@@ -901,11 +902,12 @@ def route_order_write(body: dict = Body(default=None),
901
  continue
902
  if gone not in ranks:
903
  stale[gone] = {key: ""}
904
- written = shared_overlay.put_rows(
905
- _shared_key(), {**{p: {key: v} for p, v in ranks.items()}, **stale},
906
  st=session.runtime)
907
 
908
- out = {"ok": True, "field": key, "label": defn["label"], "type": "int",
 
909
  "stops": len(ranks), "cleared": len(stale),
910
  "rows_written": len(written), "inputsHash": defn["route"]["inputsHash"],
911
  "depot": defn["route"]["depot"],
 
845
  defn = {
846
  "key": key,
847
  "label": label or (existing or {}).get("label") or key,
848
+ # The route rank is a single-select field, not an integer-only system column. That makes
849
+ # Destination 1 immediately editable in Grid while its declared choices keep the route
850
+ # order vocabulary finite and sortable as numbers in the UI.
851
+ "type": "select",
852
+ "options": [str(n) for n in range(1, len(ranks) + 1)],
853
  "source": "overlay",
854
  "shared": True,
855
  "kind": ROUTE_KIND,
 
902
  continue
903
  if gone not in ranks:
904
  stale[gone] = {key: ""}
905
+ written = shared_overlay.put_rows(
906
+ _shared_key(), {**{p: {key: str(v)} for p, v in ranks.items()}, **stale},
907
  st=session.runtime)
908
 
909
+ out = {"ok": True, "field": key, "label": defn["label"], "type": "select",
910
+ "options": defn["options"],
911
  "stops": len(ranks), "cleared": len(stale),
912
  "rows_written": len(written), "inputsHash": defn["route"]["inputsHash"],
913
  "depot": defn["route"]["depot"],
api/routes_geo.py CHANGED
@@ -71,7 +71,11 @@ _MIN_INTERVAL_MS_DEFAULT = 1100
71
 
72
  #: The most addresses one call may carry. Small on purpose: the client loops and shows progress,
73
  #: and no single request can sit on the connection for a minute waiting out the throttle.
74
- MAX_BATCH = 25
 
 
 
 
75
 
76
  #: Tile zoom the provider actually serves. OSM stops at 19.
77
  _TILE_MAX_Z_DEFAULT = 19
@@ -191,8 +195,8 @@ def geocode_one(address, country=None, timeout=12):
191
  params = {"q": q, "format": "jsonv2", "limit": 1}
192
  if country:
193
  params["countrycodes"] = str(country).strip().lower()
194
- try:
195
- r = requests.get(
196
  _env("AIOS_GEOCODE_URL", _GEOCODE_URL_DEFAULT),
197
  params=params,
198
  headers={"User-Agent": _env("AIOS_GEO_USER_AGENT", _UA_DEFAULT),
@@ -317,9 +321,9 @@ def geo_route(body: dict = Body(...), session: Session = Depends(require_session
317
  stops = body.get("stops")
318
  if not isinstance(stops, list) or len(stops) < 2:
319
  raise err(400, "too_few_stops", "A route needs at least two stops with a location.")
320
- if len(stops) > 25:
321
- raise err(400, "too_many_stops",
322
- "Route at most 25 stops at once. Narrow the selection and try again.")
323
  pairs = []
324
  for s in stops:
325
  try:
@@ -339,12 +343,26 @@ def geo_route(body: dict = Body(...), session: Session = Depends(require_session
339
  headers={"User-Agent": _env("AIOS_GEO_USER_AGENT", _UA_DEFAULT)},
340
  timeout=20,
341
  )
342
- r.raise_for_status()
343
- data = r.json()
344
- except Exception:
345
- raise err(502, "route_service_unavailable",
346
- "The routing service did not answer. The stop order and the straight line "
347
- "distance are still on the map.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  routes = (data or {}).get("routes") or []
349
  if not routes:
350
  raise err(
 
71
 
72
  #: The most addresses one call may carry. Small on purpose: the client loops and shows progress,
73
  #: and no single request can sit on the connection for a minute waiting out the throttle.
74
+ MAX_BATCH = 25
75
+ # OSRM accepts substantially more route coordinates than the geocoder batch. Keep routing useful
76
+ # for a normal customer day (including the 32-stop route that exposed the old failure) without
77
+ # allowing an unbounded request to occupy the provider.
78
+ MAX_ROUTE_STOPS = 100
79
 
80
  #: Tile zoom the provider actually serves. OSM stops at 19.
81
  _TILE_MAX_Z_DEFAULT = 19
 
195
  params = {"q": q, "format": "jsonv2", "limit": 1}
196
  if country:
197
  params["countrycodes"] = str(country).strip().lower()
198
+ try:
199
+ r = requests.get(
200
  _env("AIOS_GEOCODE_URL", _GEOCODE_URL_DEFAULT),
201
  params=params,
202
  headers={"User-Agent": _env("AIOS_GEO_USER_AGENT", _UA_DEFAULT),
 
321
  stops = body.get("stops")
322
  if not isinstance(stops, list) or len(stops) < 2:
323
  raise err(400, "too_few_stops", "A route needs at least two stops with a location.")
324
+ if len(stops) > MAX_ROUTE_STOPS:
325
+ raise err(400, "too_many_stops",
326
+ f"Route at most {MAX_ROUTE_STOPS} stops at once. Narrow the selection and try again.")
327
  pairs = []
328
  for s in stops:
329
  try:
 
343
  headers={"User-Agent": _env("AIOS_GEO_USER_AGENT", _UA_DEFAULT)},
344
  timeout=20,
345
  )
346
+ r.raise_for_status()
347
+ data = r.json()
348
+ except requests.Timeout:
349
+ raise err(504, "route_service_timeout",
350
+ "OSRM routing timed out after 20 seconds. The stop order and the straight-line "
351
+ "estimate are still on the map; try Driving route again.")
352
+ except requests.HTTPError as exc:
353
+ status = getattr(exc.response, "status_code", None)
354
+ suffix = f" (HTTP {status})" if status else ""
355
+ raise err(502, "route_service_http_error",
356
+ f"OSRM routing returned an upstream error{suffix}. The stop order and the "
357
+ "straight-line estimate are still on the map; try again shortly.")
358
+ except (TypeError, ValueError):
359
+ raise err(502, "route_service_invalid_response",
360
+ "OSRM routing returned an invalid answer. The stop order and the straight-line "
361
+ "estimate are still on the map; try again shortly.")
362
+ except requests.RequestException:
363
+ raise err(502, "route_service_unavailable",
364
+ "OSRM routing could not be reached. The stop order and the straight-line "
365
+ "estimate are still on the map; try again shortly.")
366
  routes = (data or {}).get("routes") or []
367
  if not routes:
368
  raise err(
web/src/customer-grid/CustomerGrid.tsx CHANGED
@@ -124,7 +124,7 @@ import type { GridFolder, ViewPermissions } from "./types";
124
  import type { FieldStamps } from "./optimism";
125
  import { evalFormula, orderFormulas, parseFormula } from "./formulaEngine";
126
  import type { FormulaAst } from "./formulaEngine";
127
- import { CalendarView, KanbanView, ListView, ModeSwitch } from "./viewModes";
128
  import { SwipeView } from "./SwipeView";
129
  import type { SwipeSpec } from "./SwipeView";
130
  // The chart engine lives in `viz/` since EXIT wave 2 (W2-5/Y3) — the grid is now
@@ -1658,6 +1658,11 @@ function CustomerGridSurface({
1658
  setColumnVisible,
1659
  insertColumn,
1660
  } = useGridColumns(fields, config, updateConfig);
 
 
 
 
 
1661
  // W39-T22 — the transit link is an action, so it is appended to what Glide paints without
1662
  // joining the saved-view column contract. `onCellClicked` below is the one tap door.
1663
  const gridColumns = useMemo(
@@ -1935,7 +1940,6 @@ function CustomerGridSurface({
1935
  // the same reason grouping is off there).
1936
  const displaySpec = cleanDisplay(config.display);
1937
  const displayMode: DisplayMode = serverWindowed ? "grid" : displaySpec?.mode ?? "grid";
1938
- const [routeRailHost, setRouteRailHost] = useState<HTMLDivElement | null>(null);
1939
 
1940
  // ═══════════════════════════════════════════════════════════════════════════════════════
1941
  // ⭐⭐ WAVE 30 · W30-T42 (contract C2) — PAGING A READ-THROUGH GRID.
@@ -2723,12 +2727,13 @@ function CustomerGridSurface({
2723
  );
2724
  const { gridSelection, selectedPids, onGridSelectionChange, selectPids, togglePid,
2725
  setActiveCell, clearSelection } =
2726
- useGridSelection(
2727
- displayRows,
2728
- displayPidToIndex,
2729
  gridColumns.length,
2730
- embeddedSelectable ? embeddedSelectedIds : []
2731
- );
 
2732
  const embeddedSelectedKey = embeddedSelectedIds.join(",");
2733
  const selectedPidKey = [...selectedPids].join(",");
2734
  useEffect(() => {
@@ -6375,16 +6380,11 @@ function CustomerGridSurface({
6375
  fed it go with it. `mapColorField` survives: `MapView` still reads the encoding, it just
6376
  no longer offers a second control for choosing it. `colorFieldChoices` survives too and
6377
  now feeds the toolbar's one Color control. */
6378
- sizeField={mapSizeField}
6379
- sizeChoices={sizeFieldChoices}
6380
  onPickField={setDisplayField}
6381
  /* ⭐ W37-T28 (item 15) — the coordinate picker's three props. D's own guard renders the
6382
  control only when `coordChoices.length > 0 && onPickCoordField`, so there is no
6383
  arrangement that paints a control which does nothing
6384
  (`web_map::coord-picker-has-a-handler` asserts it by name). */
6385
- coordField={mapCoordField}
6386
- coordChoices={coordFieldChoices}
6387
- onPickCoordField={onPickCoordField}
6388
  // Items 3 + 4 (C-DISP). `kanbanClamp` is absent-means-clamped, so the boolean handed
6389
  // down is `!== false` rather than a truthiness test — the one place that distinction
6390
  // decides whether the user's opt-out survives a reload.
@@ -6742,9 +6742,6 @@ function CustomerGridSurface({
6742
  onToggleImportant={toggleViewImportant}
6743
  />
6744
  )}
6745
- {displayMode === "map" && (
6746
- <div className="cg-route-slot" ref={setRouteRailHost} aria-label="Route navigation" />
6747
- )}
6748
  {/* ⭐⭐ W37-T29 / CONTRACT C6 (rulings R2, R10) — E's CHAT, DOCKED AND OPENABLE.
6749
  ⛔ THE LAUNCHER SHIPS IN THE SAME CHANGE AS THE MOUNT, and that is not tidiness: a panel
6750
  whose only entry point is a prop nobody flips is mounted-but-never-offered, which is the
@@ -6859,9 +6856,19 @@ function CustomerGridSurface({
6859
  pool={payload?.workspace?.pool}
6860
  serverWindowed={serverWindowed}
6861
  cohortAction={cohortAction}
6862
- filterSeed={filterSeed}
6863
- modeControl={modeControl}
6864
- />
 
 
 
 
 
 
 
 
 
 
6865
  {/* Wave-10 item 9: the view's description used to render HERE, as a full-width band
6866
  between the toolbar and the grid — it cost every row a strip of vertical space and
6867
  read as an alert rather than as a label. It now sits under the view's name in the
@@ -7359,15 +7366,15 @@ function CustomerGridSurface({
7359
  The write goes through `patchAndRecord`, the SAME door a typed edit takes, so the
7360
  undo stack and the permission check are the ones that already exist rather than a
7361
  second writer sitting outside every guard. */
7362
- onGeocoded={(writes) => {
7363
  for (const w of writes)
7364
  if (mapCoordField && canEditField(mapCoordField))
7365
  patchAndRecord(w.pid, { [mapCoordField.key]: w.value }, "a lookup");
7366
- }}
 
7367
  selectedPids={selectedPids}
7368
  onSelectPids={selectPids}
7369
  onOpen={setDetailPid}
7370
- routeRailHost={routeRailHost}
7371
  />
7372
  )}
7373
  {/* Owner item 19 — the hover-only Expand. The COUNTERPART to item 17: the single
 
124
  import type { FieldStamps } from "./optimism";
125
  import { evalFormula, orderFormulas, parseFormula } from "./formulaEngine";
126
  import type { FormulaAst } from "./formulaEngine";
127
+ import { CalendarView, KanbanView, ListView, MapSettings, ModeSwitch } from "./viewModes";
128
  import { SwipeView } from "./SwipeView";
129
  import type { SwipeSpec } from "./SwipeView";
130
  // The chart engine lives in `viz/` since EXIT wave 2 (W2-5/Y3) — the grid is now
 
1658
  setColumnVisible,
1659
  insertColumn,
1660
  } = useGridColumns(fields, config, updateConfig);
1661
+ const revealRouteField = useCallback((key: string) => {
1662
+ setColumnVisible(key, true);
1663
+ signal(WORKSPACE_STALE_EVENT);
1664
+ signal(ROWS_STALE_EVENT);
1665
+ }, [setColumnVisible]);
1666
  // W39-T22 — the transit link is an action, so it is appended to what Glide paints without
1667
  // joining the saved-view column contract. `onCellClicked` below is the one tap door.
1668
  const gridColumns = useMemo(
 
1940
  // the same reason grouping is off there).
1941
  const displaySpec = cleanDisplay(config.display);
1942
  const displayMode: DisplayMode = serverWindowed ? "grid" : displaySpec?.mode ?? "grid";
 
1943
 
1944
  // ═══════════════════════════════════════════════════════════════════════════════════════
1945
  // ⭐⭐ WAVE 30 · W30-T42 (contract C2) — PAGING A READ-THROUGH GRID.
 
2727
  );
2728
  const { gridSelection, selectedPids, onGridSelectionChange, selectPids, togglePid,
2729
  setActiveCell, clearSelection } =
2730
+ useGridSelection(
2731
+ displayRows,
2732
+ displayPidToIndex,
2733
  gridColumns.length,
2734
+ embeddedSelectable ? embeddedSelectedIds : [],
2735
+ !embedded ? `aios:grid-selection:${scope}` : undefined
2736
+ );
2737
  const embeddedSelectedKey = embeddedSelectedIds.join(",");
2738
  const selectedPidKey = [...selectedPids].join(",");
2739
  useEffect(() => {
 
6380
  fed it go with it. `mapColorField` survives: `MapView` still reads the encoding, it just
6381
  no longer offers a second control for choosing it. `colorFieldChoices` survives too and
6382
  now feeds the toolbar's one Color control. */
 
 
6383
  onPickField={setDisplayField}
6384
  /* ⭐ W37-T28 (item 15) — the coordinate picker's three props. D's own guard renders the
6385
  control only when `coordChoices.length > 0 && onPickCoordField`, so there is no
6386
  arrangement that paints a control which does nothing
6387
  (`web_map::coord-picker-has-a-handler` asserts it by name). */
 
 
 
6388
  // Items 3 + 4 (C-DISP). `kanbanClamp` is absent-means-clamped, so the boolean handed
6389
  // down is `!== false` rather than a truthiness test — the one place that distinction
6390
  // decides whether the user's opt-out survives a reload.
 
6742
  onToggleImportant={toggleViewImportant}
6743
  />
6744
  )}
 
 
 
6745
  {/* ⭐⭐ W37-T29 / CONTRACT C6 (rulings R2, R10) — E's CHAT, DOCKED AND OPENABLE.
6746
  ⛔ THE LAUNCHER SHIPS IN THE SAME CHANGE AS THE MOUNT, and that is not tidiness: a panel
6747
  whose only entry point is a prop nobody flips is mounted-but-never-offered, which is the
 
6856
  pool={payload?.workspace?.pool}
6857
  serverWindowed={serverWindowed}
6858
  cohortAction={cohortAction}
6859
+ filterSeed={filterSeed}
6860
+ modeControl={modeControl}
6861
+ />
6862
+ {displayMode === "map" && (
6863
+ <MapSettings
6864
+ coordField={mapCoordField}
6865
+ coordChoices={coordFieldChoices}
6866
+ onPickCoordField={onPickCoordField}
6867
+ sizeField={mapSizeField}
6868
+ sizeChoices={sizeFieldChoices}
6869
+ onPickSizeField={(key) => setDisplayField("sizeField", key)}
6870
+ />
6871
+ )}
6872
  {/* Wave-10 item 9: the view's description used to render HERE, as a full-width band
6873
  between the toolbar and the grid — it cost every row a strip of vertical space and
6874
  read as an alert rather than as a label. It now sits under the view's name in the
 
7366
  The write goes through `patchAndRecord`, the SAME door a typed edit takes, so the
7367
  undo stack and the permission check are the ones that already exist rather than a
7368
  second writer sitting outside every guard. */
7369
+ onGeocoded={(writes) => {
7370
  for (const w of writes)
7371
  if (mapCoordField && canEditField(mapCoordField))
7372
  patchAndRecord(w.pid, { [mapCoordField.key]: w.value }, "a lookup");
7373
+ }}
7374
+ onRouteFieldCreated={revealRouteField}
7375
  selectedPids={selectedPids}
7376
  onSelectPids={selectPids}
7377
  onOpen={setDetailPid}
 
7378
  />
7379
  )}
7380
  {/* Owner item 19 — the hover-only Expand. The COUNTERPART to item 17: the single
web/src/customer-grid/MapView.tsx CHANGED
@@ -53,7 +53,6 @@
53
  // ---------------------------------------------------------------------------
54
 
55
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
56
- import { createPortal } from "react-dom";
57
  import type { KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from "react";
58
  import type { Field, Row } from "./types";
59
  import { formatDisplay } from "./cells";
@@ -69,7 +68,7 @@ import {
69
  fromScreen,
70
  googleDirectionsUrl,
71
  googleMapsUrl,
72
- googleRouteUrl,
73
  googleZoomForK,
74
  graticuleOpacity,
75
  hairline,
@@ -217,7 +216,7 @@ export function MapView({
217
  onSelectPids,
218
  onOpen,
219
  onGeocoded,
220
- routeRailHost,
221
  }: {
222
  /** DISTINCT data rows from the full pipeline, overlay edits layered — the
223
  * calendar/kanban contract, verbatim. */
@@ -253,11 +252,12 @@ export function MapView({
253
  * arrangement in which a person can run a lookup whose results have nowhere to land.
254
  */
255
  onGeocoded?: (writes: { pid: number; value: string }[]) => void;
256
- routeRailHost?: HTMLElement | null;
257
  }) {
258
- const [hoverPid, setHoverPid] = useState<number | null>(null);
259
- // I18-R — the route planner. Off until asked for: a route drawn over a
260
- // selection nobody asked to route is just clutter.
 
261
  const [routeOn, setRouteOn] = useState(false);
262
  const [roundTrip, setRoundTrip] = useState(false);
263
  const [routeStartPid, setRouteStartPid] = useState<number | null>(null);
@@ -705,10 +705,10 @@ export function MapView({
705
  /** The origin the planner was given, so the saved column records the same one the
706
  * fingerprint was taken over. */
707
  startPid: depotPoint ? null : routable[start].pid,
708
- link: googleRouteUrl(
709
- ordered.map((p) => ({ lat: p.lat, lon: p.lon })),
710
- { roundTrip, coarsePointer }
711
- ),
712
  /** The identity of THIS set of stops in THIS order. The road answer is only about the plan
713
  * whose key it carries; anything else on screen makes it stale rather than wrong. */
714
  key: ordered.map((p) => `${p.pid}@${p.lat.toFixed(6)},${p.lon.toFixed(6)}`).join(",") +
@@ -743,17 +743,17 @@ export function MapView({
743
  headers: { "Content-Type": "application/json" },
744
  body: JSON.stringify({ stops, roundTrip }),
745
  });
746
- const body = await res.json().catch(() => null);
747
- if (!res.ok) {
748
- // ⭐ The SERVER's sentence, not a generic one. It knows whether the service was down or
749
- // whether no road connects these stops, and those need different actions from the user.
750
- setRoadErr(
751
- (body && body.detail && body.detail.error && body.detail.error.message) ||
752
- "The routing service did not answer."
753
- );
754
- setRoad(null);
755
- return;
756
- }
757
  setRoad({
758
  km: Number(body.km) || 0,
759
  minutes: Number(body.minutes) || 0,
@@ -761,8 +761,8 @@ export function MapView({
761
  key,
762
  attribution: String(body.attribution || ""),
763
  });
764
- } catch {
765
- setRoadErr("The routing service could not be reached.");
766
  setRoad(null);
767
  } finally {
768
  setRoadBusy(false);
@@ -856,8 +856,10 @@ export function MapView({
856
  "The visit order could not be saved."
857
  );
858
  return;
859
- }
860
- setSaveTarget(String(body?.field || ""));
 
 
861
  setSaveMsg(
862
  `Saved ${Number(body?.stops || 0).toLocaleString()} visit numbers to ` +
863
  `${body?.label || "the column"}` +
@@ -869,7 +871,7 @@ export function MapView({
869
  } finally {
870
  setSaveBusy(false);
871
  }
872
- }, [plan, saveTarget, roundTrip, routeCols, loadRouteCols]);
873
 
874
  /**
875
  * The saved column selected for writing, and whether what is on screen would solve differently.
@@ -1438,16 +1440,25 @@ export function MapView({
1438
  {/* I18-R — the route planner. Appears only with a multi-pin selection, so
1439
  it is mutually exclusive with the single-pin links above and the bar
1440
  never carries both. */}
1441
- {routeRailHost &&
1442
- createPortal(
1443
- <aside className="cg-route-rail" aria-label="Route navigation">
1444
- <div className="cg-route-rail-head">
 
 
 
 
 
 
 
 
 
1445
  <span className="cg-views-title">Route</span>
1446
- <span className="cg-route-rail-count">
1447
  {selectedPids.size >= 2 ? `${selectedPids.size} selected` : "Select records"}
1448
  </span>
1449
  </div>
1450
- <div className="cg-route-rail-body">
1451
  {selectedPids.size >= 2 ? (
1452
  <span className="cg-map-route">
1453
  {!routeOn ? (
@@ -1568,22 +1579,21 @@ export function MapView({
1568
  />
1569
  Return to start
1570
  </label>
1571
- {plan.link && (
1572
- <a
1573
- href={plan.link.url}
1574
- target="_blank"
1575
- rel="noopener noreferrer"
1576
- title="Open this route in Google Maps for driving directions (new tab)"
1577
- >
1578
- Open route in Google Maps
1579
- {/* The free URL takes 9 waypoints on desktop and 3 on a
1580
- phone. When the route is longer, SAY which part rides. */}
1581
- {plan.link.used < plan.ordered.length &&
1582
- (plan.depot
1583
- ? ` (depot plus first ${plan.link.used - 1} of ${plan.customerStops} visits)`
1584
- : ` (first ${plan.link.used} of ${plan.customerStops} visits)`)}
1585
- </a>
1586
- )}
1587
  {/* ⭐ W37-T36 — THE ORDER IS CHANGEABLE, and it has to be more than the Start
1588
  picker. The planner optimises for distance; a person routing a day of visits
1589
  is working around an appointment at eleven, and no solver knows that. So the
@@ -1732,8 +1742,7 @@ export function MapView({
1732
  </span>
1733
  )}
1734
  </div>
1735
- </aside>,
1736
- routeRailHost
1737
  )}
1738
  {/* ⭐⭐ W37-T37 (R4 / R3 / R14) — LOOK UP THE ADDRESSES OF THE RECORDS YOU CHOSE.
1739
  It lives HERE, on the map, because this is the surface where the absence is felt: you
 
53
  // ---------------------------------------------------------------------------
54
 
55
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
 
56
  import type { KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from "react";
57
  import type { Field, Row } from "./types";
58
  import { formatDisplay } from "./cells";
 
68
  fromScreen,
69
  googleDirectionsUrl,
70
  googleMapsUrl,
71
+ googleRouteUrls,
72
  googleZoomForK,
73
  graticuleOpacity,
74
  hairline,
 
216
  onSelectPids,
217
  onOpen,
218
  onGeocoded,
219
+ onRouteFieldCreated,
220
  }: {
221
  /** DISTINCT data rows from the full pipeline, overlay edits layered — the
222
  * calendar/kanban contract, verbatim. */
 
252
  * arrangement in which a person can run a lookup whose results have nowhere to land.
253
  */
254
  onGeocoded?: (writes: { pid: number; value: string }[]) => void;
255
+ onRouteFieldCreated?: (key: string) => void;
256
  }) {
257
+ const [hoverPid, setHoverPid] = useState<number | null>(null);
258
+ // I18-R — the route planner. Off until asked for: a route drawn over a
259
+ // selection nobody asked to route is just clutter.
260
+ const [routePanelOpen, setRoutePanelOpen] = useState(false);
261
  const [routeOn, setRouteOn] = useState(false);
262
  const [roundTrip, setRoundTrip] = useState(false);
263
  const [routeStartPid, setRouteStartPid] = useState<number | null>(null);
 
705
  /** The origin the planner was given, so the saved column records the same one the
706
  * fingerprint was taken over. */
707
  startPid: depotPoint ? null : routable[start].pid,
708
+ links: googleRouteUrls(
709
+ ordered.map((p) => ({ lat: p.lat, lon: p.lon })),
710
+ { roundTrip, coarsePointer }
711
+ ),
712
  /** The identity of THIS set of stops in THIS order. The road answer is only about the plan
713
  * whose key it carries; anything else on screen makes it stale rather than wrong. */
714
  key: ordered.map((p) => `${p.pid}@${p.lat.toFixed(6)},${p.lon.toFixed(6)}`).join(",") +
 
743
  headers: { "Content-Type": "application/json" },
744
  body: JSON.stringify({ stops, roundTrip }),
745
  });
746
+ const body = await res.json().catch(() => null);
747
+ if (!res.ok) {
748
+ // The SERVER's sentence, not a generic one. It distinguishes a provider timeout, an
749
+ // upstream HTTP failure, an impossible road route and a request that is too large.
750
+ const message = body?.detail?.error?.message || body?.error?.message ||
751
+ body?.detail?.message || body?.detail;
752
+ setRoadErr(String(message ||
753
+ "Driving route unavailable. The straight-line estimate remains on the map; try again."));
754
+ setRoad(null);
755
+ return;
756
+ }
757
  setRoad({
758
  km: Number(body.km) || 0,
759
  minutes: Number(body.minutes) || 0,
 
761
  key,
762
  attribution: String(body.attribution || ""),
763
  });
764
+ } catch {
765
+ setRoadErr("Driving route could not reach OSRM. The straight-line estimate remains on the map; try again.");
766
  setRoad(null);
767
  } finally {
768
  setRoadBusy(false);
 
856
  "The visit order could not be saved."
857
  );
858
  return;
859
+ }
860
+ const savedField = String(body?.field || "");
861
+ setSaveTarget(savedField);
862
+ if (savedField) onRouteFieldCreated?.(savedField);
863
  setSaveMsg(
864
  `Saved ${Number(body?.stops || 0).toLocaleString()} visit numbers to ` +
865
  `${body?.label || "the column"}` +
 
871
  } finally {
872
  setSaveBusy(false);
873
  }
874
+ }, [plan, saveTarget, roundTrip, routeCols, loadRouteCols, onRouteFieldCreated]);
875
 
876
  /**
877
  * The saved column selected for writing, and whether what is on screen would solve differently.
 
1440
  {/* I18-R — the route planner. Appears only with a multi-pin selection, so
1441
  it is mutually exclusive with the single-pin links above and the bar
1442
  never carries both. */}
1443
+ <button
1444
+ type="button"
1445
+ className={"cg-map-route-toggle" + (routePanelOpen ? " is-open" : "")}
1446
+ aria-expanded={routePanelOpen}
1447
+ aria-controls="cg-route-popover"
1448
+ onClick={() => setRoutePanelOpen((open) => !open)}
1449
+ title="Show or hide route planning"
1450
+ >
1451
+ Route{selectedPids.size >= 2 ? ` · ${selectedPids.size} selected` : ""}
1452
+ </button>
1453
+ {routePanelOpen && (
1454
+ <aside id="cg-route-popover" className="cg-route-popover" aria-label="Route navigation">
1455
+ <div className="cg-route-popover-head">
1456
  <span className="cg-views-title">Route</span>
1457
+ <span className="cg-route-popover-count">
1458
  {selectedPids.size >= 2 ? `${selectedPids.size} selected` : "Select records"}
1459
  </span>
1460
  </div>
1461
+ <div>
1462
  {selectedPids.size >= 2 ? (
1463
  <span className="cg-map-route">
1464
  {!routeOn ? (
 
1579
  />
1580
  Return to start
1581
  </label>
1582
+ {plan.links.length > 0 && (
1583
+ <span className="cg-map-google-links" aria-label="Google Maps route links">
1584
+ {plan.links.map((link) => (
1585
+ <a
1586
+ key={link.index}
1587
+ href={link.url}
1588
+ target="_blank"
1589
+ rel="noopener noreferrer"
1590
+ title={`Open Google Maps route ${link.index} in a new tab`}
1591
+ >
1592
+ Google Maps route {link.index}
1593
+ </a>
1594
+ ))}
1595
+ </span>
1596
+ )}
 
1597
  {/* ⭐ W37-T36 — THE ORDER IS CHANGEABLE, and it has to be more than the Start
1598
  picker. The planner optimises for distance; a person routing a day of visits
1599
  is working around an appointment at eleven, and no solver knows that. So the
 
1742
  </span>
1743
  )}
1744
  </div>
1745
+ </aside>
 
1746
  )}
1747
  {/* ⭐⭐ W37-T37 (R4 / R3 / R14) — LOOK UP THE ADDRESSES OF THE RECORDS YOU CHOSE.
1748
  It lives HERE, on the map, because this is the surface where the absence is felt: you
web/src/customer-grid/mapProjection.ts CHANGED
@@ -624,7 +624,7 @@ export function routeStopCap(coarsePointer: boolean, roundTrip = false): number
624
  * ([[no-unverifiable-aggregates]]). Shrinks further if the character budget
625
  * binds, which it can with a long tail of 6-dp coordinates.
626
  */
627
- export function googleRouteUrl(
628
  stops: GeoStop[],
629
  opts: { roundTrip?: boolean; coarsePointer?: boolean } = {}
630
  ): { url: string; used: number } | null {
@@ -645,7 +645,50 @@ export function googleRouteUrl(
645
  if (url.length <= MAX_MAPS_URL || used <= 2) return { url, used };
646
  used -= 1;
647
  }
648
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
649
 
650
  /** An svg's own bounding box in client px — the `getBoundingClientRect()` half
651
  * of the conversion below, taken as plain data so the maths stays testable
 
624
  * ([[no-unverifiable-aggregates]]). Shrinks further if the character budget
625
  * binds, which it can with a long tail of 6-dp coordinates.
626
  */
627
+ export function googleRouteUrl(
628
  stops: GeoStop[],
629
  opts: { roundTrip?: boolean; coarsePointer?: boolean } = {}
630
  ): { url: string; used: number } | null {
 
645
  if (url.length <= MAX_MAPS_URL || used <= 2) return { url, used };
646
  used -= 1;
647
  }
648
+ }
649
+
650
+ /**
651
+ * Split a long ordered route into contiguous Google Maps links. Adjacent links share their
652
+ * boundary stop, so every stop is represented while each individual URL stays within Google's
653
+ * free-link limit. `googleRouteUrl` remains the single-link primitive for callers that want its
654
+ * reported cap; the map planner uses this list so it never hides the tail of a route.
655
+ */
656
+ export function googleRouteUrls(
657
+ stops: GeoStop[],
658
+ opts: { roundTrip?: boolean; coarsePointer?: boolean } = {}
659
+ ): { url: string; index: number; start: number; end: number }[] {
660
+ if (stops.length < 2) return [];
661
+ const links: { url: string; index: number; start: number; end: number }[] = [];
662
+ const cap = routeStopCap(!!opts.coarsePointer, false);
663
+ let start = 0;
664
+ while (start < stops.length - 1) {
665
+ const end = Math.min(stops.length, start + cap);
666
+ const segment = stops.slice(start, end);
667
+ const built = googleRouteUrl(segment, { coarsePointer: opts.coarsePointer });
668
+ if (!built || built.used < 2) break;
669
+ links.push({
670
+ url: built.url,
671
+ index: links.length + 1,
672
+ start,
673
+ end: start + built.used,
674
+ });
675
+ if (start + built.used >= stops.length) break;
676
+ // Share the last stop so route 2 starts where route 1 ends.
677
+ start = start + built.used - 1;
678
+ }
679
+ // A round trip is represented honestly by adding the original origin to the final segment when
680
+ // there is room. If the segment is full, the contiguous links still cover every visit; Google
681
+ // cannot express the global return without dropping a visit, which this helper never does.
682
+ if (opts.roundTrip && links.length) {
683
+ const last = links[links.length - 1];
684
+ const segment = stops.slice(last.start, last.end);
685
+ if (segment.length >= 2 && last.end === stops.length) {
686
+ const returned = googleRouteUrl([...segment, stops[0]], { roundTrip: false, coarsePointer: opts.coarsePointer });
687
+ if (returned) last.url = returned.url;
688
+ }
689
+ }
690
+ return links;
691
+ }
692
 
693
  /** An svg's own bounding box in client px — the `getBoundingClientRect()` half
694
  * of the conversion below, taken as plain data so the maths stays testable
web/src/customer-grid/useGridSelection.ts CHANGED
@@ -43,10 +43,26 @@ export function useGridSelection(
43
  visibleRows: VisibleRow[],
44
  pidToIndex: Map<number, number>,
45
  colCount: number,
46
- initialSelectedPids: readonly number[] = []
 
47
  ): GridSelectionApi {
48
  const [selectedPids, setSelectedPids] = useState<Set<number>>(
49
- () => new Set(initialSelectedPids)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  );
51
  const [current, setCurrent] = useState<GridSelection["current"] | undefined>(
52
  undefined
@@ -96,6 +112,18 @@ export function useGridSelection(
96
  return { current: safeCurrent, columns: CompactSelection.empty(), rows };
97
  }, [selectedPids, pidToIndex, current, visibleRows.length, colCount]);
98
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  const onGridSelectionChange = useCallback(
100
  (sel: GridSelection) => {
101
  setCurrent(sel.current);
 
43
  visibleRows: VisibleRow[],
44
  pidToIndex: Map<number, number>,
45
  colCount: number,
46
+ initialSelectedPids: readonly number[] = [],
47
+ selectionStorageKey?: string
48
  ): GridSelectionApi {
49
  const [selectedPids, setSelectedPids] = useState<Set<number>>(
50
+ () => {
51
+ const seeded = new Set(initialSelectedPids);
52
+ if (!selectionStorageKey || typeof window === "undefined") return seeded;
53
+ try {
54
+ const raw = window.sessionStorage.getItem(selectionStorageKey);
55
+ const stored = raw ? JSON.parse(raw) : [];
56
+ if (Array.isArray(stored)) {
57
+ for (const pid of stored) {
58
+ if (Number.isInteger(pid) && pid > 0) seeded.add(pid);
59
+ }
60
+ }
61
+ } catch {
62
+ // Session storage is an enhancement, never a reason to make the grid unusable.
63
+ }
64
+ return seeded;
65
+ }
66
  );
67
  const [current, setCurrent] = useState<GridSelection["current"] | undefined>(
68
  undefined
 
112
  return { current: safeCurrent, columns: CompactSelection.empty(), rows };
113
  }, [selectedPids, pidToIndex, current, visibleRows.length, colCount]);
114
 
115
+ // The selection is semantic (PIDs), so it can survive a saved-view remount without carrying
116
+ // stale grid row indexes with it. Session scope keeps it useful across view changes while
117
+ // avoiding a permanent cross-session selection surprise.
118
+ useEffect(() => {
119
+ if (!selectionStorageKey || typeof window === "undefined") return;
120
+ try {
121
+ window.sessionStorage.setItem(selectionStorageKey, JSON.stringify([...selectedPids]));
122
+ } catch {
123
+ // Private browsing and quota policies may reject storage; the in-memory selection remains.
124
+ }
125
+ }, [selectedPids, selectionStorageKey]);
126
+
127
  const onGridSelectionChange = useCallback(
128
  (sel: GridSelection) => {
129
  setCurrent(sel.current);
web/src/customer-grid/viewModes.tsx CHANGED
@@ -90,15 +90,10 @@ export function ModeSwitch({
90
  onMode,
91
  locked = false,
92
  dateField,
93
- dateChoices,
94
- stackField,
95
- stackChoices,
96
- coordField,
97
- coordChoices = [],
98
- onPickCoordField,
99
- sizeField,
100
- sizeChoices,
101
- onPickField,
102
  clamped = true,
103
  onClamp,
104
  calendarMode = "records",
@@ -122,46 +117,12 @@ export function ModeSwitch({
122
  /** The kanban's effective stack field (resolved by the caller). */
123
  stackField?: Field;
124
  stackChoices: Field[];
125
- /** Wave-8 I3/I5 — the map's SIZE encoding, resolved by the caller from the VIEW
126
- * DEF exactly like the two above (never from component state that dies on
127
- * unmount). It is an optional encoding, so it offers a "no encoding" row —
128
- * which is why its picker carries an explicit empty option instead of
129
- * relying on a first option, the wave-7 trap.
130
- * ⚠ This said "the map's encodingS", plural, while colour was its twin. W38-T07 moved colour
131
- * to the toolbar's one Color control, so size is the only encoding this component still owns. */
132
- /**
133
- * W37-T34 — WHICH COLUMN CARRIES THE LOCATION, resolved by the caller from the view def like
134
- * every field above it. Its cell holds `"lat,lon"` (contract C7).
135
- *
136
- * ⚠ `coordChoices` defaults to `[]` so the picker simply does not appear until the host mounts
137
- * it (W37-T28, cross-fence wiring 3). That default is a COMPILE convenience for a shared working
138
- * tree and it is NOT the safety: the safety is C's `verify_wiring` row in the mounting ticket,
139
- * because a control that renders nothing is exactly how a finished feature ships unreachable.
140
- */
141
- coordField?: Field;
142
- coordChoices?: Field[];
143
- /**
144
- * ⚠ A SEPARATE CALLBACK RATHER THAN A FIFTH KEY ON `onPickField`, and the reason is a fence
145
- * rather than a taste: widening that union breaks the host's own narrower handler at COMPILE
146
- * time, in a file this lane may not edit, in a wave where four other lanes share this working
147
- * tree. A red `tsc` for everybody is a worse answer than one extra prop.
148
- * ⭐ AND IT BUYS THE THING THE UNION COULD NOT: the picker renders only when the choices AND the
149
- * handler are both present, so there is no arrangement of props that paints a control which does
150
- * nothing. The mounted-but-inert defect is unreachable here rather than merely unlikely.
151
- */
152
- onPickCoordField?: (key: string) => void;
153
- /** ⭐ W38-T07 — `colorField`/`colorChoices` are GONE from this component, not merely unused: the
154
- * toolbar's Color popover is the one colour control now, so a prop here would be a second door
155
- * standing open for the next lane to mount a twin through. The map still reads its colour from
156
- * `display.colorField`; that key is written by the toolbar's picker. */
157
- sizeField?: Field;
158
- sizeChoices: Field[];
159
  /** ⭐ W38-T07 — `"colorField"` LEFT THIS UNION, and dropping it is the point rather than tidying
160
  * up after the deleted picker: the mode bar must not be able to write a colour at all, so a
161
  * later lane that mounts a colour control here fails to COMPILE instead of shipping the twin
162
  * the owner just asked us to remove. The host's `setDisplayField` still accepts the wider set
163
  * (it is the general display-field writer) and stays assignable to this narrower prop. */
164
- onPickField: (k: "dateField" | "stackField" | "sizeField", key: string) => void;
165
  /** Item 3 (C-DISP) — cards are clamped unless the view stored the literal `false`. */
166
  clamped?: boolean;
167
  /** `false` = opt out of the clamp; `undefined` = back to the default (the key comes OFF). */
@@ -435,60 +396,63 @@ export function ModeSwitch({
435
  )}
436
  </Popover>
437
  )}
438
- {/* The map's SIZE encoding is OPTIONAL, so "none" is a real choice and not merely the
439
- absence of one: it is a row in the list AND the placeholder the button falls back to,
440
- which is the same state said twice on purpose — you can see what you would return to
441
- before you pick it. The "Size: " prefix lived on every option because a native
442
- select had nowhere else to say which encoding it was; the aria-label and the row
443
- carry that now, so the labels are just the field names.
444
- ⚠ This read "the map's two encodings" while colour was the other; W38-T07 left one. */}
445
- {/* W37-T34 — the LOCATION picker, and it is deliberately the FIRST of the map's three.
446
- Colour and size are encodings you can live without; this one decides whether there are
447
- any pins at all, so it reads left to right in the order the questions actually arrive.
448
- ⚠ Unlike the two below it, "none" here is not a neutral choice: it means fall back to the
449
- `lat`/`lon` column pair, which most databases do not have. The row says so rather than
450
- offering a bare "No location" that looks like a way to turn pins off. */}
451
- {mode === "map" && coordChoices.length > 0 && onPickCoordField && (
452
- <FieldSelectButton
453
- className="cg-mode-field"
454
- ariaLabel="Plot pins from"
455
- placeholder="Location: default"
456
- value={coordField?.key ?? ""}
457
- onChange={(key) => onPickCoordField(key)}
458
- fields={[
459
- { key: "", label: "Location: the lat and lon columns", type: undefined },
460
- ...coordChoices.map((f) => ({
461
- key: f.key, label: `Location: ${f.label}`, type: f.type,
462
- })),
463
- ]}
464
- />
465
- )}
466
- {/* ⭐⭐ W38-T07 (owner instruction 12) — THE MAP'S OWN COLOUR PICKER USED TO SIT HERE, and it
467
- is deleted rather than moved. Owner: *"Under Map view, the 'Colour' dropdown duplicates
468
- the existing Color dropdown. Use the existing one."* The toolbar's Color popover is "the
469
- existing one"; it was two radios and is now a field picker, and it writes BOTH
470
- `config.colorBy` (the grid's row wash) AND `display.colorField` (this map's pins), so the
471
- map still gets its encoding from a control that no longer has a twin.
472
- ⛔ THE SIZE PICKER BELOW IS NOT PART OF THIS. It has no duplicate anywhere in the strip
473
- and the ticket's non-goal names it explicitly: "No size" stays, and it still sizes pins. */}
474
- {mode === "map" && sizeChoices.length > 0 && (
475
- <FieldSelectButton
476
- className="cg-mode-field"
477
- ariaLabel="Size pins by"
478
- placeholder="Size: none"
479
- value={sizeField?.key ?? ""}
480
- onChange={(key) => onPickField("sizeField", key)}
481
- fields={[
482
- { key: "", label: "No size", type: undefined },
483
- ...sizeChoices.map((f) => ({
484
- key: f.key, label: `Size: ${f.label}`, type: f.type,
485
- })),
486
- ]}
487
- />
488
- )}
489
- </span>
490
- );
491
- }
 
 
 
492
 
493
  // ------------------------------------------------------------------- list
494
 
 
90
  onMode,
91
  locked = false,
92
  dateField,
93
+ dateChoices,
94
+ stackField,
95
+ stackChoices,
96
+ onPickField,
 
 
 
 
 
97
  clamped = true,
98
  onClamp,
99
  calendarMode = "records",
 
117
  /** The kanban's effective stack field (resolved by the caller). */
118
  stackField?: Field;
119
  stackChoices: Field[];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  /** ⭐ W38-T07 — `"colorField"` LEFT THIS UNION, and dropping it is the point rather than tidying
121
  * up after the deleted picker: the mode bar must not be able to write a colour at all, so a
122
  * later lane that mounts a colour control here fails to COMPILE instead of shipping the twin
123
  * the owner just asked us to remove. The host's `setDisplayField` still accepts the wider set
124
  * (it is the general display-field writer) and stays assignable to this narrower prop. */
125
+ onPickField: (k: "dateField" | "stackField", key: string) => void;
126
  /** Item 3 (C-DISP) — cards are clamped unless the view stored the literal `false`. */
127
  clamped?: boolean;
128
  /** `false` = opt out of the clamp; `undefined` = back to the default (the key comes OFF). */
 
396
  )}
397
  </Popover>
398
  )}
399
+ </span>
400
+ );
401
+ }
402
+
403
+ /** Map-only settings live in their own row beneath the main Filter / Sort / Group navigation. */
404
+ export function MapSettings({
405
+ coordField,
406
+ coordChoices,
407
+ onPickCoordField,
408
+ sizeField,
409
+ sizeChoices,
410
+ onPickSizeField,
411
+ }: {
412
+ coordField?: Field;
413
+ coordChoices: Field[];
414
+ onPickCoordField: (key: string) => void;
415
+ sizeField?: Field;
416
+ sizeChoices: Field[];
417
+ onPickSizeField: (key: string) => void;
418
+ }) {
419
+ if (coordChoices.length === 0 && sizeChoices.length === 0) return null;
420
+ return (
421
+ <div className="cg-map-settings" aria-label="Map settings">
422
+ <span className="cg-map-settings-label">Map</span>
423
+ {coordChoices.length > 0 && (
424
+ <FieldSelectButton
425
+ className="cg-mode-field"
426
+ ariaLabel="Plot pins from"
427
+ placeholder="Location: default"
428
+ value={coordField?.key ?? ""}
429
+ onChange={onPickCoordField}
430
+ fields={[
431
+ { key: "", label: "Location: the lat and lon columns", type: undefined },
432
+ ...coordChoices.map((f) => ({
433
+ key: f.key, label: `Location: ${f.label}`, type: f.type,
434
+ })),
435
+ ]}
436
+ />
437
+ )}
438
+ {sizeChoices.length > 0 && (
439
+ <FieldSelectButton
440
+ className="cg-mode-field"
441
+ ariaLabel="Size pins by"
442
+ placeholder="Size: none"
443
+ value={sizeField?.key ?? ""}
444
+ onChange={onPickSizeField}
445
+ fields={[
446
+ { key: "", label: "No size", type: undefined },
447
+ ...sizeChoices.map((f) => ({
448
+ key: f.key, label: `Size: ${f.label}`, type: f.type,
449
+ })),
450
+ ]}
451
+ />
452
+ )}
453
+ </div>
454
+ );
455
+ }
456
 
457
  // ------------------------------------------------------------------- list
458
 
web/src/index.css CHANGED
@@ -351,60 +351,6 @@ body {
351
  flex-direction: column;
352
  }
353
 
354
- /* Route navigation is a sibling rail, not map chrome. The planner is portalled into this slot
355
- by MapView so every route control stays beside View navigation while the map remains the work
356
- surface. It deliberately uses the same rail token and fold rhythm as `.cg-views`. */
357
- .cg-route-slot {
358
- flex: 0 0 var(--lp-rail-w);
359
- width: var(--lp-rail-w);
360
- min-width: var(--lp-rail-w);
361
- height: 100%;
362
- border-right: 1px solid var(--lp-line);
363
- background: var(--lp-surface);
364
- color: var(--cg-text);
365
- overflow: hidden;
366
- display: flex;
367
- flex-direction: column;
368
- }
369
- .cg-route-rail {
370
- width: 100%;
371
- height: 100%;
372
- min-width: 0;
373
- padding: 0 8px 10px;
374
- display: flex;
375
- flex-direction: column;
376
- overflow: hidden;
377
- }
378
- .cg-route-rail-head {
379
- flex: 0 0 var(--lp-rail-head-h);
380
- min-height: var(--lp-rail-head-h);
381
- display: flex;
382
- align-items: center;
383
- justify-content: space-between;
384
- gap: 8px;
385
- margin: 0 -8px 8px;
386
- padding: 0 8px;
387
- border-bottom: 1px solid var(--lp-line);
388
- }
389
- .cg-route-rail-count {
390
- color: var(--lp-muted);
391
- font-size: var(--lp-fs-3xs);
392
- white-space: nowrap;
393
- }
394
- .cg-route-rail-body {
395
- min-height: 0;
396
- overflow-y: auto;
397
- padding: 0 2px;
398
- scrollbar-width: thin;
399
- }
400
- .cg-route-empty {
401
- display: block;
402
- color: var(--lp-muted);
403
- font-size: var(--lp-fs-2xs);
404
- line-height: 1.45;
405
- padding: 4px 2px;
406
- }
407
-
408
  .cg-grid-box {
409
  position: relative;
410
  flex: 1 1 auto;
@@ -1241,7 +1187,7 @@ body {
1241
  /* customer-grid Toolbar — Airtable-style strip. Loopable C1 pastels (I7c). */
1242
  /* All rules scoped under .cg-* so nothing leaks into the glide canvas. */
1243
  /* ------------------------------------------------------------------------- */
1244
- .cg-toolbar {
1245
  /* ⭐⭐ WAVE 36 · T54 — THE STRIP IS ITS OWN QUERY CONTAINER, AND THAT REPLACES A PREMISE THAT DIED
1246
  WITH STREAMLIT. Every breakpoint below used to be a `@media` query, defended in its own comment
1247
  as *"media queries, not container queries, and that is measured rather than lazy: the grid
@@ -1293,8 +1239,28 @@ body {
1293
  clipped at the edge instead of painting over the grid beneath — and a clipped control is
1294
  something a screenshot shows, where a scrolled one looks like a complete toolbar. */
1295
  overflow-x: hidden;
1296
- overflow-y: hidden;
1297
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1298
 
1299
  .cg-tb-spacer {
1300
  flex: 1 1 auto;
@@ -4715,24 +4681,23 @@ body > .cg-overlay {
4715
 
4716
  /* Item W11c (C3) — the MAP view: SVG scatter over a coarse US outline, pins in
4717
  brand navy, hover/focus in gold. */
4718
- .cg-mapview {
4719
- height: 100%;
 
4720
  overflow: auto;
4721
  background: #fff;
4722
  padding: 10px 12px;
4723
  display: flex;
4724
  flex-direction: column;
4725
  }
4726
- .cg-map-bar {
4727
  display: flex;
4728
  align-items: center;
4729
  gap: 10px;
4730
  margin-bottom: 8px;
4731
- /* Route controls live in the sibling route rail; this row only carries map-local status and
4732
- lookup controls. */
4733
- flex-wrap: wrap;
4734
- row-gap: 6px;
4735
- }
4736
  .cg-map-hint {
4737
  color: var(--lp-muted);
4738
  font-size: var(--lp-fs-3xs);
@@ -4766,12 +4731,67 @@ body > .cg-overlay {
4766
  min-width: 0;
4767
  }
4768
  .cg-map-go a:hover { border-bottom-color: var(--lp-blue-deep); }
4769
- .cg-map-go a:focus-visible {
4770
  outline: 2px solid var(--lp-blue-deep);
4771
  outline-offset: 2px;
4772
  border-radius: 2px;
4773
- }
4774
- .cg-map-frame {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4775
  position: relative; /* the legends float over the map, never in the flow */
4776
  flex: 1;
4777
  min-height: 0;
@@ -4966,8 +4986,7 @@ a.cg-map-ctl-b { text-decoration: none; }
4966
  }
4967
 
4968
  /* Wave-9 I18-R — the route planner. Sequencing is ours (free arithmetic); the
4969
- roads are Google's, reached by the same key-less URL as the rest of the
4970
- hand-off. The controls are rendered in the sibling route rail. */
4971
  .cg-map-route {
4972
  display: flex;
4973
  flex-direction: column;
@@ -4979,20 +4998,20 @@ a.cg-map-ctl-b { text-decoration: none; }
4979
  min-width: 0;
4980
  overflow: visible;
4981
  }
4982
- .cg-route-rail .cg-map-route-go { width: 100%; min-height: 28px; height: auto; text-align: left; white-space: normal; }
4983
- .cg-route-rail .cg-map-route-sum { white-space: normal; line-height: 1.45; }
4984
- .cg-route-rail .cg-map-route-opt {
4985
  align-items: stretch;
4986
  flex-direction: column;
4987
  gap: 4px;
4988
  white-space: normal;
4989
  }
4990
- .cg-route-rail .cg-map-route-opt:has(input[type="checkbox"]) {
4991
  flex-direction: row;
4992
  align-items: center;
4993
  }
4994
- .cg-route-rail .cg-map-route-start { width: 100%; max-width: none; }
4995
- .cg-route-rail .cg-map-route a { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
4996
  .cg-map-route-go {
4997
  flex: 0 0 auto;
4998
  height: 22px;
@@ -5049,12 +5068,20 @@ a.cg-map-ctl-b { text-decoration: none; }
5049
  flex: 0 0 auto;
5050
  }
5051
  .cg-map-route a:hover { border-bottom-color: var(--lp-blue-deep); }
5052
- .cg-map-route a:focus-visible {
5053
  outline: 2px solid var(--lp-blue-deep);
5054
  outline-offset: 2px;
5055
- border-radius: 2px;
5056
- }
5057
- /* The path itself: dashed, so it never reads as a road that exists. */
 
 
 
 
 
 
 
 
5058
  .cg-map-route-line {
5059
  fill: none;
5060
  stroke: var(--lp-blue-solid);
 
351
  flex-direction: column;
352
  }
353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  .cg-grid-box {
355
  position: relative;
356
  flex: 1 1 auto;
 
1187
  /* customer-grid Toolbar — Airtable-style strip. Loopable C1 pastels (I7c). */
1188
  /* All rules scoped under .cg-* so nothing leaks into the glide canvas. */
1189
  /* ------------------------------------------------------------------------- */
1190
+ .cg-toolbar {
1191
  /* ⭐⭐ WAVE 36 · T54 — THE STRIP IS ITS OWN QUERY CONTAINER, AND THAT REPLACES A PREMISE THAT DIED
1192
  WITH STREAMLIT. Every breakpoint below used to be a `@media` query, defended in its own comment
1193
  as *"media queries, not container queries, and that is measured rather than lazy: the grid
 
1239
  clipped at the edge instead of painting over the grid beneath — and a clipped control is
1240
  something a screenshot shows, where a scrolled one looks like a complete toolbar. */
1241
  overflow-x: hidden;
1242
+ overflow-y: hidden;
1243
+ }
1244
+
1245
+ /* Map encodings are a second navigation row, matching the time-series controls below its
1246
+ primary toolbar. They stay in document flow, while route planning is map-local overlay chrome. */
1247
+ .cg-map-settings {
1248
+ flex: 0 0 auto;
1249
+ min-height: 38px;
1250
+ display: flex;
1251
+ align-items: center;
1252
+ gap: 6px;
1253
+ padding: 5px 10px;
1254
+ border-bottom: 1px solid var(--lp-line);
1255
+ background: var(--lp-surface);
1256
+ color: var(--lp-muted);
1257
+ font-size: var(--lp-fs-3xs);
1258
+ }
1259
+ .cg-map-settings-label {
1260
+ margin-right: 2px;
1261
+ font-weight: 600;
1262
+ letter-spacing: 0.02em;
1263
+ }
1264
 
1265
  .cg-tb-spacer {
1266
  flex: 1 1 auto;
 
4681
 
4682
  /* Item W11c (C3) — the MAP view: SVG scatter over a coarse US outline, pins in
4683
  brand navy, hover/focus in gold. */
4684
+ .cg-mapview {
4685
+ position: relative;
4686
+ height: 100%;
4687
  overflow: auto;
4688
  background: #fff;
4689
  padding: 10px 12px;
4690
  display: flex;
4691
  flex-direction: column;
4692
  }
4693
+ .cg-map-bar {
4694
  display: flex;
4695
  align-items: center;
4696
  gap: 10px;
4697
  margin-bottom: 8px;
4698
+ flex-wrap: wrap;
4699
+ row-gap: 6px;
4700
+ }
 
 
4701
  .cg-map-hint {
4702
  color: var(--lp-muted);
4703
  font-size: var(--lp-fs-3xs);
 
4731
  min-width: 0;
4732
  }
4733
  .cg-map-go a:hover { border-bottom-color: var(--lp-blue-deep); }
4734
+ .cg-map-go a:focus-visible {
4735
  outline: 2px solid var(--lp-blue-deep);
4736
  outline-offset: 2px;
4737
  border-radius: 2px;
4738
+ }
4739
+ .cg-map-route-toggle {
4740
+ flex: 0 0 auto;
4741
+ height: 24px;
4742
+ padding: 0 9px;
4743
+ border: 1px solid var(--lp-line);
4744
+ border-radius: 5px;
4745
+ background: var(--lp-surface);
4746
+ color: var(--lp-ink);
4747
+ font: inherit;
4748
+ cursor: pointer;
4749
+ }
4750
+ .cg-map-route-toggle:hover,
4751
+ .cg-map-route-toggle.is-open {
4752
+ background: var(--lp-blue-tint);
4753
+ border-color: var(--lp-blue-deep);
4754
+ }
4755
+ .cg-map-route-toggle:focus-visible {
4756
+ outline: 2px solid var(--lp-blue-deep);
4757
+ outline-offset: 1px;
4758
+ }
4759
+ .cg-route-popover {
4760
+ position: absolute;
4761
+ z-index: var(--cg-z-overlay);
4762
+ top: 48px;
4763
+ right: 12px;
4764
+ width: min(360px, calc(100% - 24px));
4765
+ max-height: calc(100% - 60px);
4766
+ overflow-y: auto;
4767
+ padding: 10px;
4768
+ border: 1px solid var(--lp-line);
4769
+ border-radius: 7px;
4770
+ background: var(--lp-surface);
4771
+ color: var(--lp-ink);
4772
+ box-shadow: 0 8px 24px rgba(32, 36, 51, 0.16);
4773
+ }
4774
+ .cg-route-popover-head {
4775
+ display: flex;
4776
+ align-items: center;
4777
+ justify-content: space-between;
4778
+ gap: 8px;
4779
+ padding-bottom: 8px;
4780
+ border-bottom: 1px solid var(--lp-line);
4781
+ }
4782
+ .cg-route-popover-count {
4783
+ color: var(--lp-muted);
4784
+ font-size: var(--lp-fs-3xs);
4785
+ white-space: nowrap;
4786
+ }
4787
+ .cg-route-empty {
4788
+ display: block;
4789
+ padding: 10px 2px 2px;
4790
+ color: var(--lp-muted);
4791
+ font-size: var(--lp-fs-2xs);
4792
+ line-height: 1.45;
4793
+ }
4794
+ .cg-map-frame {
4795
  position: relative; /* the legends float over the map, never in the flow */
4796
  flex: 1;
4797
  min-height: 0;
 
4986
  }
4987
 
4988
  /* Wave-9 I18-R — the route planner. Sequencing is ours (free arithmetic); the
4989
+ roads are Google's, reached by the same key-less URL as the rest of the hand-off. */
 
4990
  .cg-map-route {
4991
  display: flex;
4992
  flex-direction: column;
 
4998
  min-width: 0;
4999
  overflow: visible;
5000
  }
5001
+ .cg-route-popover .cg-map-route-go { width: 100%; min-height: 28px; height: auto; text-align: left; white-space: normal; }
5002
+ .cg-route-popover .cg-map-route-sum { white-space: normal; line-height: 1.45; }
5003
+ .cg-route-popover .cg-map-route-opt {
5004
  align-items: stretch;
5005
  flex-direction: column;
5006
  gap: 4px;
5007
  white-space: normal;
5008
  }
5009
+ .cg-route-popover .cg-map-route-opt:has(input[type="checkbox"]) {
5010
  flex-direction: row;
5011
  align-items: center;
5012
  }
5013
+ .cg-route-popover .cg-map-route-start { width: 100%; max-width: none; }
5014
+ .cg-route-popover .cg-map-route a { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
5015
  .cg-map-route-go {
5016
  flex: 0 0 auto;
5017
  height: 22px;
 
5068
  flex: 0 0 auto;
5069
  }
5070
  .cg-map-route a:hover { border-bottom-color: var(--lp-blue-deep); }
5071
+ .cg-map-route a:focus-visible {
5072
  outline: 2px solid var(--lp-blue-deep);
5073
  outline-offset: 2px;
5074
+ border-radius: 2px;
5075
+ }
5076
+ .cg-map-google-links {
5077
+ display: flex;
5078
+ flex-wrap: wrap;
5079
+ gap: 6px 10px;
5080
+ }
5081
+ .cg-map-google-links a {
5082
+ white-space: nowrap;
5083
+ }
5084
+ /* The path itself: dashed, so it never reads as a road that exists. */
5085
  .cg-map-route-line {
5086
  fill: none;
5087
  stroke: var(--lp-blue-solid);