Epic: M1 — Smart waypoint insertion #2

Open
opened 2026-07-27 11:03:55 +00:00 by jmz · 6 comments
Owner

Problem: clicking a new point appends it to the end of the route; it should insert into the nearest existing segment (Komoot behavior), avoiding manual drag-reordering.

Design: the anchor model already supports splice at any index with a changeset/undo stack (web/src/lib/stores/valhalla_store.svelte.ts:117). The change is choosing the insertion index = segment minimizing added detour (perpendicular/added-distance), instead of pushing to the end.

Acceptance: clicking near a mid-route segment inserts the anchor there; start/finish clicks still extend ends; drag + undo/redo unaffected.

  • Upstream issue/discussion first (gauge receptivity)
  • Insertion-index algorithm + unit tests
  • Wire into map click handler (append → smart insert), preserve undo/redo
  • Manual + e2e (playwright) test
  • Upstream PR — atomic, disclosed AI-assisted
**Problem:** clicking a new point appends it to the *end* of the route; it should insert into the **nearest existing segment** (Komoot behavior), avoiding manual drag-reordering. **Design:** the anchor model already supports `splice` at any index with a changeset/undo stack (`web/src/lib/stores/valhalla_store.svelte.ts:117`). The change is *choosing the insertion index* = segment minimizing added detour (perpendicular/added-distance), instead of pushing to the end. **Acceptance:** clicking near a mid-route segment inserts the anchor there; start/finish clicks still extend ends; drag + undo/redo unaffected. - [ ] Upstream issue/discussion first (gauge receptivity) - [x] Insertion-index algorithm + unit tests - [x] Wire into map click handler (append → smart insert), preserve undo/redo - [ ] Manual + e2e (playwright) test - [ ] Upstream PR — atomic, disclosed AI-assisted
Author
Owner

Design confirmed + reframed after reading the code.

Mid-route insertion already exists via line-drag (splitSegment, valhalla_store.svelte.ts:223 — re-routes both halves). The real gap: a click always appends. So M1 = smart click.

Agreed behavior: min-detour insertion with automatic endpoint guard — a clicked point lands at the anchor gap that grows total route length the least; extending wins at the ends, refining wins in the middle. Algorithm + unit tests done in #11.

**Design confirmed + reframed after reading the code.** Mid-route insertion **already exists** via **line-drag** (`splitSegment`, `valhalla_store.svelte.ts:223` — re-routes both halves). The real gap: a **click always appends**. So M1 = *smart click*. Agreed behavior: **min-detour insertion with automatic endpoint guard** — a clicked point lands at the anchor gap that grows total route length the least; extending wins at the ends, refining wins in the middle. Algorithm + unit tests done in #11.
Author
Owner

M1.3 wiring done (#12, commit f0ea569e). The smart-insertion feature is code-complete on feat/smart-insertion (M1.2 chooser + M1.3 wiring), typechecked and unit-tested. Remaining for M1: browser/e2e validation (needs M0.2 deploy or local dev), then the upstream issue (#10) and PR (#13).

**M1.3 wiring done** (#12, commit `f0ea569e`). The smart-insertion feature is **code-complete** on `feat/smart-insertion` (M1.2 chooser + M1.3 wiring), typechecked and unit-tested. Remaining for M1: browser/e2e validation (needs M0.2 deploy or local dev), then the upstream issue (#10) and PR (#13).
Author
Owner

🚀 Deployed to wanderer.ziefle.org (web image oss/wanderer-web:si-f0ea569e, commit f0ea569e). Ready for browser testing of smart insertion. After the user validates the UX, remaining: upstream issue (#10) + PR (#13). Behavior may be tuned against real clicks first.

🚀 **Deployed to `wanderer.ziefle.org`** (web image `oss/wanderer-web:si-f0ea569e`, commit `f0ea569e`). Ready for browser testing of smart insertion. After the user validates the UX, remaining: upstream issue (#10) + PR (#13). Behavior may be tuned against real clicks first.
Author
Owner

🔧 Redeployed si-5e20f773 with route-editor fixes found during testing (see the new bug ticket): track now clears correctly on anchor removal, and undo of point-adds restores the anchor list instead of wiping the track. Mid-insert is now a single clean undo step too. Live at wanderer.ziefle.org.

🔧 Redeployed `si-5e20f773` with route-editor fixes found during testing (see the new bug ticket): track now clears correctly on anchor removal, and undo of point-adds restores the anchor list instead of wiping the track. Mid-insert is now a single clean undo step too. Live at wanderer.ziefle.org.
Author
Owner

✅ Undo round 2 fixed (deploy b98b47e1):

  • Marker sync: applyAnchorSnapshot() now removes the undone anchor's marker from the map and re-adds restored ones on redo — previously the anchor left the list but its marker stayed drawn.
  • First anchor undoable: placing the first point records an anchor-only undo entry (pushAnchorOnlyChange), so undo is enabled and actually removes it (was greyed / a no-op).

Live at wanderer.ziefle.org — please re-test: (1) drop one point → undo removes it; (2) two points → undo removes the 2nd point + its marker + the segment.

✅ **Undo round 2 fixed** (deploy `b98b47e1`): - **Marker sync:** `applyAnchorSnapshot()` now removes the undone anchor's marker from the map and re-adds restored ones on redo — previously the anchor left the list but its **marker** stayed drawn. - **First anchor undoable:** placing the first point records an anchor-only undo entry (`pushAnchorOnlyChange`), so undo is enabled and actually removes it (was greyed / a no-op). Live at wanderer.ziefle.org — please re-test: (1) drop one point → undo removes it; (2) two points → undo removes the 2nd point + its marker + the segment.
Author
Owner

Design change — 2026-07-27 (decided with the user). Always-on smart-insert misfires when planning loops (a click meant to extend the route lands geometrically near an early segment and gets inserted mid-route). New design:

  • Plain click = append (default, = upstream's current behavior; zero surprise).
  • Insert at nearest segment = opt-in, via BOTH: a panel toggle (Append ▸ Insert) and Alt/⌘-click for a one-off insert.

This makes the feature purely additive over upstream (better odds of acceptance). Implementing now on our fork first; the pr/smart-insertion branch + PR text will be re-staged around the append-default design before any upstream submission.

**Design change — 2026-07-27 (decided with the user).** Always-on smart-insert misfires when planning **loops** (a click meant to extend the route lands geometrically near an early segment and gets inserted mid-route). New design: - **Plain click = append** (default, = upstream's current behavior; zero surprise). - **Insert at nearest segment = opt-in**, via BOTH: a panel **toggle** (Append ▸ Insert) and **Alt/⌘-click** for a one-off insert. This makes the feature purely additive over upstream (better odds of acceptance). **Implementing now on our fork first; the `pr/smart-insertion` branch + PR text will be re-staged around the append-default design before any upstream submission.**
Sign in to join this conversation.
No labels
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#2
No description provided.