batch 3: editor round 3, subcategories + e2e, acceptance-bug fixes #72

Merged
maximus merged 21 commits from batch/2026-11-05-3 into deploy 2026-11-05 20:35:46 +00:00
Member

Batch 3 on top of deploy 676a7c62 (live).

Round 3 (editor): map toolbars stacked, no overlap (#66); "–" for duration/distance/D± before a route (#66); Optimise order precise mode (routed leg distances for ≤ 15 movable anchors, cached, cancellable, exact solve up to 15) (#45); no TypeError … markers on editor load; map legend never over the zoom controls, collapsible on phones.
Round 4: subcategory suggestions (Alpine / Trail vs Road running / MTB vs Road biking) from BRouter way tags or the saved trail's surface breakdown; SAC feeds category/difficulty (#49); e2e specs ported to deploy behaviour + Optimise order + basic-info specs.
Round 5 (acceptance bugs): #67 legacy saved sort resets to newest-first; #68 route edits serialised (no out-of-order legs on fast clicks); #69 one click on the route line = one anchor; #70 nameless GPX named after the filename stem; #71 TRAIL_ANALYZE_PACE_USERS grants the pace estimate only (heatmap stays on TRAIL_ANALYZE_USERS) + clear "not enabled for your account" message; Shift+P; one duration rounding; per-page select shows its value; readable undo/redo icons in dark mode.

Local verification (spl-vm05, Node 24): svelte-check 0 errors (2 old a11y warnings); vitest 1231 passed / 13 skipped, no unhandled errors; go vet ./... clean. Live e2e (10 specs for deployed features) passed before this batch; the 4 new tagged specs run after deploy.

Closes #66, #67, #68, #69, #70, #71. Refs #45, #49.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgP

Batch 3 on top of `deploy` 676a7c62 (live). **Round 3 (editor):** map toolbars stacked, no overlap (#66); "–" for duration/distance/D± before a route (#66); Optimise order **precise mode** (routed leg distances for ≤ 15 movable anchors, cached, cancellable, exact solve up to 15) (#45); no `TypeError … markers` on editor load; map legend never over the zoom controls, collapsible on phones. **Round 4:** subcategory suggestions (Alpine / Trail vs Road running / MTB vs Road biking) from BRouter way tags or the saved trail's surface breakdown; SAC feeds category/difficulty (#49); e2e specs ported to deploy behaviour + Optimise order + basic-info specs. **Round 5 (acceptance bugs):** #67 legacy saved sort resets to newest-first; #68 route edits serialised (no out-of-order legs on fast clicks); #69 one click on the route line = one anchor; #70 nameless GPX named after the filename stem; #71 `TRAIL_ANALYZE_PACE_USERS` grants the pace estimate only (heatmap stays on `TRAIL_ANALYZE_USERS`) + clear "not enabled for your account" message; Shift+P; one duration rounding; per-page select shows its value; readable undo/redo icons in dark mode. Local verification (spl-vm05, Node 24): svelte-check 0 errors (2 old a11y warnings); vitest 1231 passed / 13 skipped, no unhandled errors; `go vet ./...` clean. Live e2e (10 specs for deployed features) passed before this batch; the 4 new tagged specs run after deploy. Closes #66, #67, #68, #69, #70, #71. Refs #45, #49. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgP
- The left map edge is one column: the route tools (drawing only) at the
  top, the view-controls rail on the seam at the bottom, above the
  elevation profile like the controls on the right. They no longer
  overlap; a long Loop panel scrolls instead of running into the rail.
- The route tools are a column only on tall desktop windows (new
  `tall-md` variant: md and min-height 820px). On phones and short
  desktop windows (e.g. 1366x768 with the profile open) they form a row
  under the Route/Loop tabs, so they fit above the rail. From md up the
  panels open beside the tools, clear of the rail; on phones they open
  below and scroll within the map instead of running past its edge.
- Basic info "Est. duration" uses formatTrailDuration: "–" before a route
  exists instead of "00h 00m". formatTrailDuration also accepts the
  numeric string the edit field binds.
- Stat tiles stay hidden until a route exists (Basic info already shows
  the placeholders); documented in the template.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A "Precise (routed distances)" checkbox under the Optimise button. For
routes with up to 15 movable anchors it measures the legs between all
anchor pairs through the active router (Valhalla or BRouter, via the
routing port) and solves the order on those distances instead of
straight lines.

- route_leg_matrix: symmetric n×n matrix, each unordered pair routed once
  (at most 135 calls for 15 movable anchors, hard cap 200), 4 calls in
  flight, LRU cache per routing settings and coordinate pair, progress
  callback, AbortSignal cancel (aborts the calls in flight). A leg that
  cannot be routed falls back to the straight line; if none can, the
  router's error is shown. Off-road legs and the start-end pair need no
  call.
- Routing port: RouteRequest.signal and distanceOnly (Valhalla skips its
  /height call). Store: trackRouteRequest, trackRoutingSignature,
  routedLegDistance and legModesByAnchorPair extracted.
- The editor shows "Measuring legs n/total" with a progress bar and a
  Cancel link; the reorder is still applied as one undo entry and only
  when the routed result is shorter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Follow-up to #54: besides category and difficulty, the editor now
suggests a subcategory until the user picks one:

- Hiking/Alpine for SAC >= T4 (>= 50 m along the route) or a max
  gradient >= 40 %;
- Running/Trail vs Running/Road and Biking/MTB vs Biking/Road at 50 %
  paved (share of the known-surface part, which must cover >= 50 % of
  the route);
- only when that subcategory exists under the trail's category
  (name, seeded alias or English translation).

Way data comes from BRouter's per-leg way tags (properties.messages),
captured additively in calculateRouteBetween into a geometry-keyed
cache, or, for saved trails, from /api/v1/trail/{id}/surface while the
route keeps its saved length. Without either only the gradient rule
applies. The highest SAC grade also feeds #54's category/difficulty
heuristics. Logic is pure and unit-tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The trail editor enters draw mode as soon as the map exists, before the
trail's layer is registered (that waits for the style). startDrawing()
then read `layerManager.layers[id].markers` of a missing layer and threw
"Cannot read properties of undefined (reading 'markers')" on every editor
load. The layer is added without start/end markers in draw mode anyway,
so removing them is a no-op when the layer is missing.

removeStartEndMarkers moves to $lib/util/map_layer_markers with a
regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The track-colouring legend stacked on top of the view controls in the
bottom-right column; on phones (and 1366x768 with the profile open) that
column grew into the zoom/layer controls at the top right.

- The legend now sits left of the view controls (one row), so the
  column is never taller than the controls themselves.
- The legend is collapsible (heading button, aria-expanded) and starts
  collapsed on phones.
- On phones the view controls are a row too; their colour menu opens
  above them, capped to the map's height and scrolling, on the same
  layer as the left tool column so it is not hidden behind it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Basic info showed "0 m" for distance, elevation gain and loss on a new
trail, next to the "–" duration. They now show "–" until the trail has a
distance (basicInfoHasRoute, which also accepts the numeric string the
edit fields bind). A flat route with a real distance still shows "0 m"
for D±.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Held-Karp for 15 movable points takes about 45-65 ms here (measured by a
new test that logs the time and checks the exact order is never longer
than local search). Precise runs have paid for routed legs, so they now
solve exactly up to PRECISE_MAX_MOVABLE; straight-line runs keep the
limit of 10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Builds before #50 wrote their default sort (creation date, oldest first)
into localStorage.trailListFilter on every visit, and the restore path
treated it as the user's choice. The stored filter now carries a schema
version; unversioned or older filters lose sort/sortOrder on restore, so
the newest-first default applies unless the explicit sort/sort_order keys
hold a choice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A click while the previous leg was still routing read the anchor list and
appended its leg as soon as its own response arrived, so legs landed in
response order: straight jumps between unrelated legs and an inflated
distance. Overlapping actions also folded each other's undo entries.

recordUserAction now runs through a route-edit queue: an action starts
only once the previous one has settled, and its undo position is taken
when it starts. The map click decides append/insert inside the queued
action, and undo/redo, reverse, anchor reordering and Optimise order go
through the same queue, so undo during an in-flight leg undoes that click
once it has landed. Tests drive a mock router whose responses arrive out
of order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A press on the editable route line ran the line's own mousedown/mouseup
segment-click path and then the map's generic click, which placed a
second anchor at the same spot (0 m leg). The hover flag that was meant
to skip that click is not reliable.

The segment handler now claims the press on mouseup and the map click
handler skips a claimed press; the next mousedown drops a claim whose
click never came (drag beyond MapLibre's click tolerance). A press where
a track and an offroad segment meet hits both shared-listener layers and
is now handled once. Also fix the layer manager's mouseleave dedupe key,
which re-registered the leave listener on every route update.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gpx2trail used the full filename, extension included, as the fallback
name, and any name ending in ".gpx" counts as a placeholder, so even a
descriptive filename was replaced by the route-based "A – B". The
fallback is now the stem with "_" read as a space ("Gorges du Verdon
Hiking.gpx" → "Gorges du Verdon Hiking", kept), and placeholder matching
reads "_" as a space, so "Morning_Run" and "Activity_123" are still
replaced. Applies to the editor upload and the bulk upload API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TRAIL_ANALYZE_USERS gated both the pace engine and the personal heatmap
tiles, so granting someone pace estimates also exposed the owner's
location heatmap. Authorization is now per scope:

- heatmap tiles: TRAIL_ANALYZE_USERS only;
- pace estimate (/analyze): TRAIL_ANALYZE_USERS or the new
  TRAIL_ANALYZE_PACE_USERS.

The new list follows the same fail-closed rules, validated on its own:
unset or empty adds nobody, and any malformed entry makes it add nobody.
TRAIL_ANALYZE_ALLOW_ALL=true still opens both scopes. Tests cover a
pace-only user (200 on analyze, 403 on heatmap tiles) and the malformed
and unset cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's route-insertion spec (dropped in 66f7511a) tested append-by-default.
Ported to deploy's behaviour: shortest-path insertion by default, the
append-only toggle, Alt/Cmd one-off flip, loop close next to the start,
undo/redo strictly in creation order.

New specs:
- optimise-order: open route reorder as one undo step, "already
  optimal", 4-anchor minimum, loop direction kept; precise mode
  (@precise-optimise, needs feat/editor-round3) with a mocked detour leg
  that only routed distances reveal;
- basic-info: name/location from the ends, loop name, typed/picked
  values kept, cleared name handed back; subcategory suggestions from
  BRouter way tags (@subcategory-suggest).

route_editor_helpers.ts mocks Valhalla, BRouter (with messages way
tags) and reverse geocoding, opens the map at a fixed spot and aborts
every API write, so the specs are safe against a deployed instance with
a test account. README.md documents the full-stack and the live run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Users not on the trail-analyze allow-list saw the full "My pace" panel,
and Estimate ended in a 403 shown as "Couldn't reach the pace engine."
The root layout now tells the page whether the account may use the pace
engine (same check as the analyze route). Without access the panel keeps
its heading but shows "Pace estimates aren't enabled for your account."
instead of the Estimate button and knobs, and the map key's pace-curve
hint says the same. A 403 at estimate time (allow-list changed after the
page loaded) switches the panel to that state rather than showing an
outage. The allow-list itself is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The profile shortcut only matched a lower-case "p", so Shift+P (or Caps
Lock) did nothing. Letter shortcuts now match either case; Ctrl/Meta
combos are still left to the browser.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Basic info floored the duration ("03h 10m") while the stat tiles rounded
it in their own format ("3 h 11"). formatTimeHHMM now rounds to the
nearest minute and the tiles use formatTrailDuration, so both show
"03h 11m" for 3:10:40. The tiles' own compact formatter is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
/trails starts with 25 per page and profiles with 12, but the cards
select offers 12/24/48/96 and the list select 10/25/50/100. Without a
saved per-page value the default was left as is, matched no option, and
the select showed nothing. The default is now snapped to the display's
nearest option like a saved value; the options and snapping live in
trail_pagination.ts with tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Disabled undo/redo used text-gray-500, which nearly vanished on the dark
translucent toolbar. Use the theme content colour, muted to 55 % with a
not-allowed cursor when disabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgP
merge: feat/subcats-e2e (batch 2026-11-05-3)
All checks were successful
CI / web (push) Successful in 3m8s
CI / go (push) Successful in 15m33s
5577c7158b
maximus merged commit 5577c7158b into deploy 2026-11-05 20:35:46 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/wanderer!72
No description provided.