fsanyoto commited on
Commit
c5c1906
Β·
verified Β·
1 Parent(s): 0427303

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,6 +1,12 @@
1
  {
2
- "current": "95b0c42",
3
  "releases": [
 
 
 
 
 
 
4
  {
5
  "version": "v39",
6
  "sha": "a78bdf0",
 
1
  {
2
+ "current": "v40 (1451837)",
3
  "releases": [
4
+ {
5
+ "version": "v40",
6
+ "sha": "1451837",
7
+ "date": "2026-08-22",
8
+ "subject": "release v40 route UI correction"
9
+ },
10
  {
11
  "version": "v39",
12
  "sha": "a78bdf0",
VERSION CHANGED
@@ -1 +1 @@
1
- 95b0c42
 
1
+ v40 (1451837)
api/routes_customers.py CHANGED
@@ -607,12 +607,33 @@ SHARE_TOPIC = MODULE
607
 
608
 
609
  def _route_slug(label):
610
- """A stable store key from a human label. Lower case, non-alphanumerics collapsed to `_`."""
611
- import re as _re
612
- slug = _re.sub(r"[^a-z0-9]+", "_", str(label or "").strip().lower()).strip("_")
613
  return f"{ROUTE_KEY_PREFIX}{slug[:48]}" if slug else ""
614
 
615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  def _clean_route_depot(raw):
617
  """The optional origin stored once on a route-order definition, never on a customer cell."""
618
  if raw is None:
@@ -689,7 +710,10 @@ def route_order_write(body: dict = Body(default=None),
689
  session: Session = Depends(module_gate(MODULE))):
690
  """Create (or re-solve) a tenant-wide route-order column and fill it, in ONE call.
691
 
692
- `{label, field?, ranks: {"<pid>": <int>}, inputsHash, roundTrip?, startPid?, depot?}`
 
 
 
693
 
694
  β›” THE DEFINITION IS WRITTEN FIRST AND THE GRANT CLAIMED SECOND, which is `patch_shared_cell`'s
695
  order and it is deliberate: the window where a column is MARKED and UNCLAIMED fails CLOSED
@@ -706,22 +730,29 @@ def route_order_write(body: dict = Body(default=None),
706
  import core.perm_scope as perm_scope
707
  from routes_grid import MAX_BULK_ROWS
708
 
709
- body = body if isinstance(body, dict) else {}
710
- label = " ".join(str(body.get("label") or "").split())[:120]
711
- key = str(body.get("field") or "").strip() or _route_slug(label)
712
- if not key:
713
- raise err(400, "bad_request", "a name is required for the route order column")
 
 
 
 
 
 
 
 
 
714
  if not key.startswith(ROUTE_KEY_PREFIX):
715
  raise err(400, "bad_field_key",
716
  f"a route order column's key starts with '{ROUTE_KEY_PREFIX}', so it cannot "
717
  f"collide with a column this database already owns")
718
- import aios_grid
719
- if key in {f.get("key") for f in aios_grid.FIELDS}:
720
- raise err(400, "field_key_taken",
721
- "this database already has a column with that key")
722
-
723
- defs = shared_fields(st=session.runtime) or {}
724
- existing = defs.get(key) if isinstance(defs.get(key), dict) else None
725
  if existing is not None:
726
  # β›”β›” A REFUSAL MUST NOT DESCRIBE A COLUMN THE CALLER CANNOT SEE. The two refusals below
727
  # name the column's KIND and its CREATOR, which is exactly the information the field wall
 
607
 
608
 
609
  def _route_slug(label):
610
+ """A stable store key from a human label. Lower case, non-alphanumerics collapsed to `_`."""
611
+ import re as _re
612
+ slug = _re.sub(r"[^a-z0-9]+", "_", str(label or "").strip().lower()).strip("_")
613
  return f"{ROUTE_KEY_PREFIX}{slug[:48]}" if slug else ""
614
 
615
 
616
+ def _next_destination_label(defs, base_fields=()):
617
+ """Return the next human route-field label without colliding with a visible field."""
618
+ occupied_keys = {str(key) for key in (defs or {})}
619
+ occupied_labels = set()
620
+ for field in list((defs or {}).values()) + list(base_fields or ()):
621
+ if not isinstance(field, dict):
622
+ continue
623
+ label = " ".join(str(field.get("label") or "").split()).casefold()
624
+ if label:
625
+ occupied_labels.add(label)
626
+ key = str(field.get("key") or "").strip()
627
+ if key:
628
+ occupied_keys.add(key)
629
+ n = 1
630
+ while True:
631
+ label = f"Destination {n}"
632
+ if label.casefold() not in occupied_labels and _route_slug(label) not in occupied_keys:
633
+ return label
634
+ n += 1
635
+
636
+
637
  def _clean_route_depot(raw):
638
  """The optional origin stored once on a route-order definition, never on a customer cell."""
639
  if raw is None:
 
710
  session: Session = Depends(module_gate(MODULE))):
711
  """Create (or re-solve) a tenant-wide route-order column and fill it, in ONE call.
712
 
713
+ `{label?, field?, ranks: {"<pid>": <int>}, inputsHash, roundTrip?, startPid?, depot?}`
714
+
715
+ When `label` is omitted for a new column, the door allocates the next unused `Destination N`
716
+ label. This keeps route creation one-click while preserving unique, readable field names.
717
 
718
  β›” THE DEFINITION IS WRITTEN FIRST AND THE GRANT CLAIMED SECOND, which is `patch_shared_cell`'s
719
  order and it is deliberate: the window where a column is MARKED and UNCLAIMED fails CLOSED
 
730
  import core.perm_scope as perm_scope
731
  from routes_grid import MAX_BULK_ROWS
732
 
733
+ body = body if isinstance(body, dict) else {}
734
+ label = " ".join(str(body.get("label") or "").split())[:120]
735
+ import aios_grid
736
+ defs = shared_fields(st=session.runtime) or {}
737
+ requested_key = str(body.get("field") or "").strip()
738
+ if requested_key:
739
+ key = requested_key
740
+ elif label:
741
+ key = _route_slug(label)
742
+ else:
743
+ label = _next_destination_label(defs, aios_grid.FIELDS)
744
+ key = _route_slug(label)
745
+ if not key:
746
+ raise err(400, "bad_request", "a name is required for the route order column")
747
  if not key.startswith(ROUTE_KEY_PREFIX):
748
  raise err(400, "bad_field_key",
749
  f"a route order column's key starts with '{ROUTE_KEY_PREFIX}', so it cannot "
750
  f"collide with a column this database already owns")
751
+ if key in {f.get("key") for f in aios_grid.FIELDS}:
752
+ raise err(400, "field_key_taken",
753
+ "this database already has a column with that key")
754
+
755
+ existing = defs.get(key) if isinstance(defs.get(key), dict) else None
 
 
756
  if existing is not None:
757
  # β›”β›” A REFUSAL MUST NOT DESCRIBE A COLUMN THE CALLER CANNOT SEE. The two refusals below
758
  # name the column's KIND and its CREATOR, which is exactly the information the field wall
web/src/customer-grid/CustomerGrid.tsx CHANGED
@@ -1933,8 +1933,12 @@ function CustomerGridSurface({
1933
  // Wave-6 item 10 β€” how this view displays. A WINDOWED table is always the grid: list/
1934
  // calendar/kanban compute over the whole matched set, and one page is not it (CG-3's rule,
1935
  // the same reason grouping is off there).
1936
- const displaySpec = cleanDisplay(config.display);
1937
- const displayMode: DisplayMode = serverWindowed ? "grid" : displaySpec?.mode ?? "grid";
 
 
 
 
1938
 
1939
  // ═══════════════════════════════════════════════════════════════════════════════════════
1940
  // ⭐⭐ WAVE 30 Β· W30-T42 (contract C2) β€” PAGING A READ-THROUGH GRID.
@@ -6394,9 +6398,12 @@ function CustomerGridSurface({
6394
  calendarMetrics={displaySpec?.calendarMetrics}
6395
  // The numeric family, exactly what C-DISP makes eligible β€” and the same memo the map's
6396
  // bubble-size picker feeds from, so "what can be totalled" has one definition.
6397
- metricChoices={sizeFieldChoices}
6398
- onCalendarMetrics={setCalendarMetrics}
6399
- />
 
 
 
6400
  );
6401
  // ⭐ Wave-23 C7 β€” the open document, resolved exactly like the picker's value below it:
6402
  // the OPTIMISTIC edit wins over the raw record, so a save the server has not echoed yet is
@@ -7360,10 +7367,12 @@ function CustomerGridSurface({
7360
  if (mapCoordField && canEditField(mapCoordField))
7361
  patchAndRecord(w.pid, { [mapCoordField.key]: w.value }, "a lookup");
7362
  }}
7363
- selectedPids={selectedPids}
7364
- onSelectPids={selectPids}
7365
- onOpen={setDetailPid}
7366
- />
 
 
7367
  )}
7368
  {/* Owner item 19 β€” the hover-only Expand. The COUNTERPART to item 17: the single
7369
  click that used to open a record now highlights it, and this is where opening
 
1933
  // Wave-6 item 10 β€” how this view displays. A WINDOWED table is always the grid: list/
1934
  // calendar/kanban compute over the whole matched set, and one page is not it (CG-3's rule,
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 [routeOpenSignal, setRouteOpenSignal] = useState(0);
1939
+ const [routeOpen, setRouteOpen] = useState(false);
1940
+ const openRoute = useCallback(() => setRouteOpenSignal((current) => current + 1), []);
1941
+ const onRouteOpenChange = useCallback((open: boolean) => setRouteOpen(open), []);
1942
 
1943
  // ═══════════════════════════════════════════════════════════════════════════════════════
1944
  // ⭐⭐ WAVE 30 Β· W30-T42 (contract C2) β€” PAGING A READ-THROUGH GRID.
 
6398
  calendarMetrics={displaySpec?.calendarMetrics}
6399
  // The numeric family, exactly what C-DISP makes eligible β€” and the same memo the map's
6400
  // bubble-size picker feeds from, so "what can be totalled" has one definition.
6401
+ metricChoices={sizeFieldChoices}
6402
+ onCalendarMetrics={setCalendarMetrics}
6403
+ routeOpen={routeOpen}
6404
+ onOpenRoute={displayMode === "map" ? openRoute : undefined}
6405
+ routeDisabled={selectedPids.size < 2}
6406
+ />
6407
  );
6408
  // ⭐ Wave-23 C7 β€” the open document, resolved exactly like the picker's value below it:
6409
  // the OPTIMISTIC edit wins over the raw record, so a save the server has not echoed yet is
 
7367
  if (mapCoordField && canEditField(mapCoordField))
7368
  patchAndRecord(w.pid, { [mapCoordField.key]: w.value }, "a lookup");
7369
  }}
7370
+ selectedPids={selectedPids}
7371
+ onSelectPids={selectPids}
7372
+ onOpen={setDetailPid}
7373
+ routeOpenSignal={routeOpenSignal}
7374
+ onRouteOpenChange={onRouteOpenChange}
7375
+ />
7376
  )}
7377
  {/* Owner item 19 β€” the hover-only Expand. The COUNTERPART to item 17: the single
7378
  click that used to open a record now highlights it, and this is where opening
web/src/customer-grid/MapView.tsx CHANGED
@@ -213,10 +213,12 @@ export function MapView({
213
  colorField,
214
  sizeField,
215
  selectedPids,
216
- onSelectPids,
217
- onOpen,
218
- onGeocoded,
219
- }: {
 
 
220
  /** DISTINCT data rows from the full pipeline, overlay edits layered β€” the
221
  * calendar/kanban contract, verbatim. */
222
  rows: Row[];
@@ -250,14 +252,18 @@ export function MapView({
250
  * that should own one. Absent callback = the control does not render at all, so there is no
251
  * arrangement in which a person can run a lookup whose results have nowhere to land.
252
  */
253
- onGeocoded?: (writes: { pid: number; value: string }[]) => void;
254
- }) {
 
 
255
  const [hoverPid, setHoverPid] = useState<number | null>(null);
256
  // I18-R β€” the route planner. Off until asked for: a route drawn over a
257
  // selection nobody asked to route is just clutter.
258
- const [routeOn, setRouteOn] = useState(false);
259
- const [roundTrip, setRoundTrip] = useState(false);
260
- const [routeStartPid, setRouteStartPid] = useState<number | null>(null);
 
 
261
  /**
262
  * W37-T36 β€” A HAND-PICKED STOP ORDER, pids in visiting sequence, or null for the planner's.
263
  *
@@ -299,10 +305,9 @@ export function MapView({
299
  const [routeCols, setRouteCols] = useState<
300
  { key: string; label: string; inputsHash: string; mine: boolean; depot?: RouteDepot | null }[] | null
301
  >(null);
302
- /** Which saved column a save writes to. `""` = a new one, named by `saveName`. */
303
- const [saveTarget, setSaveTarget] = useState("");
304
- const [saveName, setSaveName] = useState("");
305
- const [saveBusy, setSaveBusy] = useState(false);
306
  const [saveMsg, setSaveMsg] = useState<string | null>(null);
307
  const [saveErr, setSaveErr] = useState<string | null>(null);
308
  /**
@@ -575,11 +580,33 @@ export function MapView({
575
  () =>
576
  selectedPids.size < 2
577
  ? []
578
- : points
579
  .filter((p) => selectedPids.has(p.pid) && isPlottable(p.lat, p.lon))
580
- .sort((a, b) => a.pid - b.pid),
581
  [points, selectedPids]
582
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  /** The depot joins BOTH index-parallel arrays below at position zero, and only there. */
584
  const depotPoint = useMemo((): MapPoint | null => {
585
  if (!depot || !isPlottable(depot.lat, depot.lon)) return null;
@@ -768,8 +795,7 @@ export function MapView({
768
  * plan change; only the ones a CLICK armed do anything. That distinction is R3: a selection
769
  * change recomputes the plan and must not spend a request.
770
  */
771
- const askRoadRef = useRef(false);
772
- useEffect(() => {
773
  if (!askRoadRef.current || !plan) return;
774
  askRoadRef.current = false;
775
  void fetchRoad();
@@ -822,13 +848,13 @@ export function MapView({
822
  const res = await fetch("/api/v1/customers/route-order", {
823
  method: "POST",
824
  credentials: "same-origin",
825
- headers: { "Content-Type": "application/json" },
826
- body: JSON.stringify({
827
- field: saveTarget || undefined,
828
- label: saveTarget
829
- ? (routeCols || []).find((f) => f.key === saveTarget)?.label || saveTarget
830
- : saveName.trim(),
831
- ranks,
832
  inputsHash: plan.fingerprint,
833
  roundTrip,
834
  startPid: plan.startPid,
@@ -846,9 +872,8 @@ export function MapView({
846
  );
847
  return;
848
  }
849
- setSaveTarget(String(body?.field || ""));
850
- setSaveName("");
851
- setSaveMsg(
852
  `Saved ${Number(body?.stops || 0).toLocaleString()} visit numbers to ` +
853
  `${body?.label || "the column"}` +
854
  (body?.cleared ? `, and cleared ${Number(body.cleared).toLocaleString()} that dropped out` : "")
@@ -859,7 +884,7 @@ export function MapView({
859
  } finally {
860
  setSaveBusy(false);
861
  }
862
- }, [plan, saveTarget, saveName, roundTrip, routeCols, loadRouteCols]);
863
 
864
  /**
865
  * The saved column selected for writing, and whether what is on screen would solve differently.
@@ -1645,31 +1670,15 @@ export function MapView({
1645
  ))}
1646
  </select>
1647
  </label>
1648
- {!saveTarget && (
1649
- <input
1650
- type="text"
1651
- /* ⚠ The SELECT's class, deliberately: `index.css` is outside this
1652
- change's fence, and `.cg-map-route-start` is already the bar's
1653
- input styling (border, radius, 22 px, inherited font). A new class
1654
- would render unstyled until somebody remembered the stylesheet. */
1655
- className="cg-map-route-start"
1656
- value={saveName}
1657
- placeholder="Name this order"
1658
- aria-label="Name this visit order column"
1659
- maxLength={60}
1660
- onChange={(e) => setSaveName(e.target.value)}
1661
- />
1662
- )}
1663
- <button
1664
  type="button"
1665
  className="cg-map-route-go"
1666
- disabled={saveBusy || (!!depotAddress.trim() && !plan.depot) ||
1667
- (!saveTarget && !saveName.trim())}
1668
  onClick={() => void saveRouteOrder()}
1669
  title={
1670
  saveTarget
1671
  ? "Write these visit numbers into the saved column, for everyone it is shared with"
1672
- : "Save these visit numbers as a column your colleagues can be given"
1673
  }
1674
  >
1675
  {saveBusy ? "Saving" : saveTarget ? "Update visit order" : "Save visit order"}
 
213
  colorField,
214
  sizeField,
215
  selectedPids,
216
+ onSelectPids,
217
+ onOpen,
218
+ onGeocoded,
219
+ routeOpenSignal,
220
+ onRouteOpenChange,
221
+ }: {
222
  /** DISTINCT data rows from the full pipeline, overlay edits layered β€” the
223
  * calendar/kanban contract, verbatim. */
224
  rows: Row[];
 
252
  * that should own one. Absent callback = the control does not render at all, so there is no
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
+ routeOpenSignal?: number;
257
+ onRouteOpenChange?: (open: boolean) => void;
258
+ }) {
259
  const [hoverPid, setHoverPid] = useState<number | null>(null);
260
  // I18-R β€” the route planner. Off until asked for: a route drawn over a
261
  // selection nobody asked to route is just clutter.
262
+ const [routeOn, setRouteOn] = useState(false);
263
+ const [roundTrip, setRoundTrip] = useState(false);
264
+ const [routeStartPid, setRouteStartPid] = useState<number | null>(null);
265
+ const routeOpenSignalSeen = useRef<number | undefined>(routeOpenSignal);
266
+ const askRoadRef = useRef(false);
267
  /**
268
  * W37-T36 β€” A HAND-PICKED STOP ORDER, pids in visiting sequence, or null for the planner's.
269
  *
 
305
  const [routeCols, setRouteCols] = useState<
306
  { key: string; label: string; inputsHash: string; mine: boolean; depot?: RouteDepot | null }[] | null
307
  >(null);
308
+ /** Which saved column a save writes to. `""` = a new, automatically named destination field. */
309
+ const [saveTarget, setSaveTarget] = useState("");
310
+ const [saveBusy, setSaveBusy] = useState(false);
 
311
  const [saveMsg, setSaveMsg] = useState<string | null>(null);
312
  const [saveErr, setSaveErr] = useState<string | null>(null);
313
  /**
 
580
  () =>
581
  selectedPids.size < 2
582
  ? []
583
+ : points
584
  .filter((p) => selectedPids.has(p.pid) && isPlottable(p.lat, p.lon))
585
+ .sort((a, b) => a.pid - b.pid),
586
  [points, selectedPids]
587
  );
588
+ useEffect(() => {
589
+ if (routeOpenSignal == null || routeOpenSignal === routeOpenSignalSeen.current) return;
590
+ routeOpenSignalSeen.current = routeOpenSignal;
591
+ if (customerRoutable.length < 2) return;
592
+ setRouteOn(true);
593
+ setRouteOrder(null);
594
+ askRoadRef.current = true;
595
+ }, [routeOpenSignal, customerRoutable.length]);
596
+
597
+ useEffect(() => {
598
+ onRouteOpenChange?.(routeOn);
599
+ }, [routeOn, onRouteOpenChange]);
600
+
601
+ useEffect(() => {
602
+ if (routeOn && customerRoutable.length < 2) {
603
+ setRouteOn(false);
604
+ setRouteOrder(null);
605
+ setRoad(null);
606
+ setRoadErr(null);
607
+ }
608
+ }, [routeOn, customerRoutable.length]);
609
+
610
  /** The depot joins BOTH index-parallel arrays below at position zero, and only there. */
611
  const depotPoint = useMemo((): MapPoint | null => {
612
  if (!depot || !isPlottable(depot.lat, depot.lon)) return null;
 
795
  * plan change; only the ones a CLICK armed do anything. That distinction is R3: a selection
796
  * change recomputes the plan and must not spend a request.
797
  */
798
+ useEffect(() => {
 
799
  if (!askRoadRef.current || !plan) return;
800
  askRoadRef.current = false;
801
  void fetchRoad();
 
848
  const res = await fetch("/api/v1/customers/route-order", {
849
  method: "POST",
850
  credentials: "same-origin",
851
+ headers: { "Content-Type": "application/json" },
852
+ body: JSON.stringify({
853
+ field: saveTarget || undefined,
854
+ ...(saveTarget
855
+ ? { label: (routeCols || []).find((f) => f.key === saveTarget)?.label || saveTarget }
856
+ : {}),
857
+ ranks,
858
  inputsHash: plan.fingerprint,
859
  roundTrip,
860
  startPid: plan.startPid,
 
872
  );
873
  return;
874
  }
875
+ setSaveTarget(String(body?.field || ""));
876
+ setSaveMsg(
 
877
  `Saved ${Number(body?.stops || 0).toLocaleString()} visit numbers to ` +
878
  `${body?.label || "the column"}` +
879
  (body?.cleared ? `, and cleared ${Number(body.cleared).toLocaleString()} that dropped out` : "")
 
884
  } finally {
885
  setSaveBusy(false);
886
  }
887
+ }, [plan, saveTarget, roundTrip, routeCols, loadRouteCols]);
888
 
889
  /**
890
  * The saved column selected for writing, and whether what is on screen would solve differently.
 
1670
  ))}
1671
  </select>
1672
  </label>
1673
+ <button
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1674
  type="button"
1675
  className="cg-map-route-go"
1676
+ disabled={saveBusy || (!!depotAddress.trim() && !plan.depot)}
 
1677
  onClick={() => void saveRouteOrder()}
1678
  title={
1679
  saveTarget
1680
  ? "Write these visit numbers into the saved column, for everyone it is shared with"
1681
+ : "Save these visit numbers as the next Destination field"
1682
  }
1683
  >
1684
  {saveBusy ? "Saving" : saveTarget ? "Update visit order" : "Save visit order"}
web/src/customer-grid/map.css CHANGED
@@ -104,13 +104,17 @@
104
  * picture would hide the answer they are reordering against.
105
  */
106
 
107
- .cg-map-stoplist {
108
- display: inline-flex;
109
- align-items: center;
110
- gap: 4px;
111
- flex-wrap: wrap;
112
- max-width: 460px;
113
- }
 
 
 
 
114
 
115
  .cg-map-stopitem {
116
  display: inline-flex;
 
104
  * picture would hide the answer they are reordering against.
105
  */
106
 
107
+ .cg-map-stoplist {
108
+ display: inline-flex;
109
+ align-items: center;
110
+ gap: 4px;
111
+ flex: 0 0 auto;
112
+ flex-wrap: nowrap;
113
+ max-width: min(720px, 100%);
114
+ overflow-x: auto;
115
+ padding-bottom: 2px;
116
+ scrollbar-width: thin;
117
+ }
118
 
119
  .cg-map-stopitem {
120
  display: inline-flex;
web/src/customer-grid/viewModes.tsx CHANGED
@@ -104,9 +104,12 @@ export function ModeSwitch({
104
  calendarMode = "records",
105
  onCalendarMode,
106
  calendarMetrics = [],
107
- metricChoices = [],
108
- onCalendarMetrics,
109
- }: {
 
 
 
110
  mode: DisplayMode;
111
  onMode: (m: DisplayMode) => void;
112
  /**
@@ -171,9 +174,12 @@ export function ModeSwitch({
171
  onCalendarMode?: (next: "records" | "summary") => void;
172
  /** Item 4 β€” the chosen per-day totals, and the numeric-family fields on offer. */
173
  calendarMetrics?: { id: string; field: string; agg: string }[];
174
- metricChoices?: Field[];
175
- onCalendarMetrics?: (next: { id: string; field: string; agg: string }[]) => void;
176
- }) {
 
 
 
177
  // Wave-7 item W12: the switcher is a DROPDOWN in the toolbar-button family β€” the
178
  // same Popover component Fields/Filter/Sort use, radio rows inside (the Rows/Color
179
  // panel pattern), with the current mode named on the trigger chip.
@@ -266,7 +272,26 @@ export function ModeSwitch({
266
  date field and a board without a stack field are not modes, so the picker is never
267
  in its placeholder state here unless the view names a field the table has lost β€”
268
  which it now SHOWS rather than silently replacing with the first choice. */}
269
- {mode === "calendar" && dateChoices.length > 0 && (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  <FieldSelectButton
271
  className="cg-mode-field"
272
  ariaLabel="Calendar date field"
 
104
  calendarMode = "records",
105
  onCalendarMode,
106
  calendarMetrics = [],
107
+ metricChoices = [],
108
+ onCalendarMetrics,
109
+ routeOpen = false,
110
+ onOpenRoute,
111
+ routeDisabled = false,
112
+ }: {
113
  mode: DisplayMode;
114
  onMode: (m: DisplayMode) => void;
115
  /**
 
174
  onCalendarMode?: (next: "records" | "summary") => void;
175
  /** Item 4 β€” the chosen per-day totals, and the numeric-family fields on offer. */
176
  calendarMetrics?: { id: string; field: string; agg: string }[];
177
+ metricChoices?: Field[];
178
+ onCalendarMetrics?: (next: { id: string; field: string; agg: string }[]) => void;
179
+ routeOpen?: boolean;
180
+ onOpenRoute?: () => void;
181
+ routeDisabled?: boolean;
182
+ }) {
183
  // Wave-7 item W12: the switcher is a DROPDOWN in the toolbar-button family β€” the
184
  // same Popover component Fields/Filter/Sort use, radio rows inside (the Rows/Color
185
  // panel pattern), with the current mode named on the trigger chip.
 
272
  date field and a board without a stack field are not modes, so the picker is never
273
  in its placeholder state here unless the view names a field the table has lost β€”
274
  which it now SHOWS rather than silently replacing with the first choice. */}
275
+ {mode === "map" && onOpenRoute && (
276
+ <button
277
+ type="button"
278
+ className={"cg-tb-btn cg-route-nav" + (routeOpen ? " is-active" : "")}
279
+ aria-pressed={routeOpen}
280
+ disabled={routeDisabled}
281
+ onClick={onOpenRoute}
282
+ title={
283
+ routeDisabled
284
+ ? "Select at least two records to plan a route"
285
+ : routeOpen
286
+ ? "The route planner is open below the map toolbar"
287
+ : "Plan a route from the selected records"
288
+ }
289
+ >
290
+ <ModeIcon mode="map" />
291
+ <span className="cg-tb-label">Route</span>
292
+ </button>
293
+ )}
294
+ {mode === "calendar" && dateChoices.length > 0 && (
295
  <FieldSelectButton
296
  className="cg-mode-field"
297
  ariaLabel="Calendar date field"
web/src/index.css CHANGED
@@ -4915,14 +4915,19 @@ a.cg-map-ctl-b { text-decoration: none; }
4915
  /* Wave-9 I18-R β€” the route planner. Sequencing is ours (free arithmetic); the
4916
  roads are Google's, reached by the same key-less URL as the rest of the
4917
  hand-off. Nothing here fetches anything. */
4918
- .cg-map-route {
4919
- display: inline-flex;
4920
- align-items: center;
4921
- gap: 10px;
4922
- flex: 0 1 auto;
4923
- font-size: var(--lp-fs-3xs);
4924
- min-width: 0;
4925
- }
 
 
 
 
 
4926
  .cg-map-route-go {
4927
  flex: 0 0 auto;
4928
  height: 22px;
 
4915
  /* Wave-9 I18-R β€” the route planner. Sequencing is ours (free arithmetic); the
4916
  roads are Google's, reached by the same key-less URL as the rest of the
4917
  hand-off. Nothing here fetches anything. */
4918
+ .cg-map-route {
4919
+ display: flex;
4920
+ align-items: center;
4921
+ gap: 10px;
4922
+ flex: 1 1 100%;
4923
+ width: 100%;
4924
+ font-size: var(--lp-fs-3xs);
4925
+ min-width: 0;
4926
+ flex-wrap: nowrap;
4927
+ overflow-x: auto;
4928
+ padding-bottom: 2px;
4929
+ scrollbar-width: thin;
4930
+ }
4931
  .cg-map-route-go {
4932
  flex: 0 0 auto;
4933
  height: 22px;