Skip to content

fix(map): ask Mapbox for a permanent answer where the id is stored #404

Closed

Description

@sydevs-bot

Summary

SahajCloud stores the Mapbox feature ids a client sends with a proposal, so its client contract now says those ids must be Geocoding v6 ids obtained with permanent=true (docs/rules/api-clients.md, sydevs/SahajCloud#893). This widget asks for neither place: MapSearch's <Geocoder> and reverseGeocode both run without permanent, which is temporary-use data Mapbox's terms do not allow anyone to keep.

Nothing here is broken today, because the widget sends no ids yet. #147 is the flow that will, and its PR #318 still mounts the geocoder without the option.

Approach

Permanence is a prop, not a constant inside the control: only the lookups whose answer is submitted ask for it (decision 1 below). One component serves both plain map browsing and the submit flow, so the two rules cannot live in one place.

1. Thread permanent through MapSearch — src/components/organisms/Mapbox/MapSearch.tsx:28 and :172-178

Add permanent?: boolean to MapSearchProps (:28) and spread it into the <Geocoder options> block (:172-178), beside language, country, proximity and types. options is typed Partial<GeocodingOptions> (@mapbox/search-js-react/dist/components/Geocoder.d.ts:43), and GeocodingOptions declares permanent?: boolean (@mapbox/search-js-core/dist/geocode/GeocodingCore.d.ts:86), so no cast is needed and a renamed option fails to compile.

Leave it absent by default. The header field — SearchField, src/views/shared.tsx:258-288 — passes nothing and stays temporary.

2. Set it on the submit flow's mounts — on #318's branch

claude/feat-147-submit-a-class has both mounts behind one module-private wrapper: PlaceField, src/components/organisms/ProposalForm/WhereStep.tsx:100-107, used for the offline address (types="address") and the online city (types="place"). PlaceField is that flow's only geocoder, so permanent goes on its single <MapSearch> rather than on each call site.

Those are exactly the values SahajCloud writes into user-submissions.location and matches against regions.mapboxId: proposed.address.mapboxId, plus the place, region and country context ids onRetrieve reads (#147 § The flow, step 1).

That branch has already widened MapSearchProps with types, proximity, value and onChange; permanent joins them. On main the props are still onSelect and label alone, so whichever of the two lands first adds the prop and the other consumes it.

3. The reverse lookup stays temporary — src/lib/geocode.ts:79-85

reverseGeocode keeps the options it has (language, limit, types). Its one caller is src/hooks/use-geolocate.ts:96, which fills the search field and the ?cc query parameter — a URL a visitor can share, never a row SahajCloud stores. Decision 1 leaves it billed at the temporary rate: add no permanent here, and no prop that could reach it.

4. A spec that holds it

Nothing pins the option. The type catches a renamed one; only a spec catches a dropped one. ProposalForm.pick.test.tsx on #318's branch already has the harness — renderToStaticMarkup in the node lane, with @mapbox/search-js-react mocked so the test captures what Geocoder is handed. Capture options the same way and assert both directions: permanent: true from the submit-flow mount, and no permanent from the header SearchField.

Decisions

  • 1. Which of the widget's Mapbox lookups become permanent? → A — only the lookups whose answer is submitted. The add-a-class and correction steps pass permanent: true; map browsing and reverseGeocode stay temporary. (Ardnived, 2026-11-13)

Acceptance criteria

  • Every Mapbox lookup whose answer the widget sends to SahajCloud — proposed.address.mapboxId and location.placeId / regionId / countryId — is made with permanent: true.
  • The header search field and reverseGeocode send no permanent, so plain browsing stays billed at the temporary rate.
  • No call site reaches permanent through a cast or a hand-written props type.
  • A unit spec fails when a submit-flow geocoder mounts without the option, and when the header field mounts with it.
  • docs/embedding.md needs no change: the host-facing CSP and the origins called are unchanged.

Verification checklist

  • pnpm lint && pnpm typecheck && pnpm test:run pass.
  • Remove permanent from the submit-flow mount, watch the new spec fail, then restore it.
  • On a deployed preview, open the add-a-class address step and confirm the request to api.mapbox.com/search/geocode/v6/forward carries permanent=true.
  • On the same preview, type in the header search field and confirm its forward request carries no permanent.

Notes

🤖 Written by the sydevs autonomous loop — see what this is

Activity

  1. added theissue type on Nov 13, 2026
  2. added
    proposal
    on Nov 13, 2026
  3. Ardnived commented on Nov 13, 2026

    @Ardnived
    Contributor

    @sydevs-bot revise 1A

  4. added
    bot:working
    and removed
    proposal
    on Nov 13, 2026
  5. sydevs-bot commented on Nov 13, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running
    approved by Ardnived

    recent dispatches
    • 17:35Z implement · attempt 1 · session · done
    • 17:35Z implement · attempt 1 · session
    • 23:12Z implement · attempt 1 · session · done
    • 23:12Z implement · attempt 1 · session
    • 22:18Z implement · attempt 1 · session · done

    Written by the sydevs dispatcher. Sessions never edit this comment.

  6. moved this from Awaiting to Working in SYDevelopers Technical Roadmapon Nov 13, 2026
  7. sydevs-bot commented on Nov 13, 2026

    @sydevs-bot
    ContributorAuthor

    Answered 1A: only the lookups whose answer is submitted go permanent. The body says it now.

    Permanence is a prop on MapSearchProps, not a constant in the control — one component serves both map browsing and the submit flow.

    • permanent?: boolean joins the <Geocoder options> block (MapSearch.tsx:28, :172-178). options is Partial<GeocodingOptions>, which declares it, so no cast.
    • The submit flow sets it in one place: PlaceField on feat(widget): submit or correct a class, and opt into a mailing list #318's branch (WhereStep.tsx:100-107) wraps both the address and the city mount.
    • reverseGeocode (geocode.ts:79-85) and the header SearchField stay temporary. A new criterion holds that direction too.
    • The spec reuses ProposalForm.pick.test.tsx's mocked Geocoder and asserts both directions.

    Two corrections from source: permanent?: boolean is GeocodingCore.d.ts:86, not :97, and SahajCloud's spec is tests/unit/mapbox-geocoder.spec.ts — the name the body carried does not exist.

    @sydevs-bot implement starts the work.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  8. removed
    bot:working
    on Nov 13, 2026
  9. moved this from Working to Awaiting in SYDevelopers Technical Roadmapon Nov 13, 2026
  10. Ardnived commented on Nov 13, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  11. added
    bot:working
    on Nov 13, 2026
  12. 1 remaining item

  13. removed
    bot:working
    on Nov 13, 2026
  14. added
    bot:working
    on Nov 13, 2026
  15. sydevs-bot commented on Nov 13, 2026

    @sydevs-bot
    ContributorAuthor

    Nothing is left to implement in this repo. The seam is on #407, open and awaiting review.

    Built there: MapSearch takes permanent, absent by default; the header field and reverseGeocode stay temporary; MapSearch.permanent.test.tsx pins both directions. Criteria 2, 3 and 5 are met. Criterion 1 holds vacuously — no lookup here sends an id yet.

    Criterion 1 and criterion 4's first half need PlaceField (ProposalForm/WhereStep.tsx), which exists only on #318's branch. A session may not push to a PR it does not hold, and no PR is based on another PR's branch. So #147 carries them, which § Notes already allows.

    This ticket outlives #407's merge for that reason. It is answered once #318 sets permanent on PlaceField.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  16. removed
    bot:working
    on Nov 13, 2026
  17. moved this from Working to Awaiting in SYDevelopers Technical Roadmapon Nov 13, 2026
  18. Ardnived commented on Nov 14, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement, or close this ticket if there's nothing left to implement

  19. added
    bot:working
    on Nov 14, 2026
  20. moved this from Awaiting to Working in SYDevelopers Technical Roadmapon Nov 14, 2026
  21. sydevs-bot commented on Nov 14, 2026

    @sydevs-bot
    ContributorAuthor

    Closing: this repo has nothing left to build.

    #407 merged the seam. MapSearch takes permanent, absent by default, and MapSearch.permanent.test.tsx pins the header field and country both ways. Criteria 2, 3 and 5 are met, and criterion 4's second half. Criterion 1 holds vacuously — no lookup on main sends a Mapbox id anywhere.

    Criterion 1's positive direction and criterion 4's first half need PlaceField (ProposalForm/WhereStep.tsx), which exists only on #318's branch. A session pushes to no PR it does not hold, and opens none based on another PR's branch.

    #147 carries them now, as § Notes allows — I have written the criterion there. docs/rules/mapbox.md on main states the rule for whoever mounts the next geocoder.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  22. removed
    bot:working
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    High

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions