Repository navigation
Support for travel time / isochrone elements - #147
Conversation
dnomadb
left a comment
There was a problem hiding this comment.
Looks good. Nothing breaks at runtime: tsc, vitest and the full npm run check pass on the branch, with no drift in the generated docs or API report. The app half in felt/felt#22386 lines up: the mode names map correctly, the tool settings round-trip, and setTool already accepts "isochrone". Two type-level suggestions, neither blocking:
1. The types accept a Polygon with both coordinates and isochrone, but the runtime rejects it (src/modules/elements/types.ts)
This compiles, because both union members share type: "Polygon" and the excess-property check allows keys from either:
const both: ElementCreate = { type: "Polygon", coordinates: ring, isochrone: iso };
const upd: PolygonElementUpdate = { id, type: "Polygon", coordinates: ring, isochrone: iso };The "both" test has no @ts-expect-error, while the "neither" test does. Extensions and agents only find out when createElement rejects, and llms-full.txt doesn't state the either/or rule for create. Adding isochrone?: never to PolygonElementCreate and coordinates?: never to IsochronePolygonElementCreate would make the rule visible in the types. The same could apply to the update type.
2. Narrowing an ElementCreate to "Polygon" no longer gives access to .coordinates, in a minor release
if (e.type === "Polygon") e.coordinates;
// TS2339: Property 'coordinates' does not exist on type 'IsochronePolygonElementCreate'felt/felt#22386 already had to work around this in mappers/Polygon.ts, and external consumers that switch on ElementCreate will hit the same error. The ?: never change above also fixes this, since e.coordinates becomes readable again as LngLatTuple[][] | undefined. Otherwise, it's worth noting the break in the changeset.
Smaller things:
PolygonElementUpdate.coordinatesdoesn't say what happens toisochronewhen you set coordinates on an isochrone polygon. Does reading it back still return the old travel time alongside a hand-drawn shape?{ type: "Polygon" }fails with "…not both", which reads as if the caller passed both.
🤖 Generated with Claude Code
…ile time PolygonElementUpdate now refuses an isochrone, and the new IsochronePolygonElementUpdate refuses coordinates. The tests check each polygon error message exactly and cover the update rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* adds isochrone polygons & tool * update for pnpm * address review comments * Reject polygon updates with both coordinates and an isochrone at compile time PolygonElementUpdate now refuses an isochrone, and the new IsochronePolygonElementUpdate refuses coordinates. The tests check each polygon error message exactly and cover the update rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 7b69a0f)
Extensions can now create a Polygon from a travel time. Passing
isochrone: { origin, mode, minutes }instead ofcoordinatesmakes Felt compute the reachable area and use it as the shape. The new"isochrone"tool works withsetToolandsetToolSettings.The isochrone form is a separate type,
IsochronePolygonElementCreate, soPolygonElementCreatestill requirescoordinates. A Polygon with both or neither is rejected.Also updates the linking steps in DEVELOPING.md for pnpm.
Test plan
isochrone: { origin, mode: "driving", minutes: 15 }. Observe a shape around the origin.minutesto 30. Observe that the shape grows."isochrone"tool withsetTooland click the map. Observe an isochrone, and anonElementCreateEndevent for it.