Skip to content

fix(render_map_tool): apply baseStyle changes on render, not just construction - #261

Merged
mattpodwysocki merged 1 commit into
mainfrom
fix-render-map-basestyle-switch
Sep 17, 2026
Merged

mattpodwysocki merged 1 commit into
mainfrom
fix-render-map-basestyle-switch

Conversation

@mattpodwysocki

Copy link
Copy Markdown
Contributor

Summary

  • render_map_tool's baseStyle (e.g. "standard-satellite") was silently ignored on every real call. It was only ever applied at map-construction time from a server-embedded #initial-data script tag, but MapAppUIResource never actually passes initialData when serving the map HTML — so that tag is always empty, the map always constructs with the default "standard" style, and the real payload (with baseStyle) arrives later via the ui/notifications/tool-result → render(payload) path, which never handled baseStyle at all (only baseMapConfig color/theme properties).
  • Caught live in Claude Desktop: requesting a baseStyle: "standard-satellite" render produced a map correctly labeled "satellite view" that was still the standard vector style underneath.
  • render() now detects when payload.baseStyle differs from the style the map is currently on and switches via map.setStyle(...), deferring the rest of the render (layers/markers/camera/etc.) until style.load fires — matching how a style swap normally works in GL JS, since it replaces sources/layers.

Test plan

  • Added a regression test reproducing the original bug (baseStyle arriving via a tool-result render, not initial data — the actual real-world path) — confirmed it fails without the fix (git stash the source change, rerun, see setStyleCalls come back empty)
  • Added a test confirming setStyle is not called when a render repeats the already-active style (no-op case)
  • npx vitest run — full suite, 947 tests pass
  • npx tsc --noEmit — clean

🤖 Generated with Claude Code

…struction

baseStyle was only ever read at map-construction time from a server-embedded
#initial-data script tag, but MapAppUIResource never actually seeds that tag
-- so the map always constructs with the default "standard" style, and the
real payload (with baseStyle) arrives later via the tool-result -> render()
path, which never touched baseStyle at all. Caught live: a "standard-satellite"
request rendered a map labeled "satellite view" that was still the standard
vector style.

render() now detects a baseStyle change and switches via map.setStyle(...),
deferring the rest of the render until style.load fires. Added regression
tests, confirmed to fail without the fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki requested a review from a team as a code owner September 17, 2026 03:18
@ox-security

ox-security Bot commented Sep 17, 2026

Copy link
Copy Markdown

OX Security Logo

OX Security reviewed this pull request — nothing to fix.

✔ No issues found

Branch fix-render-map-basestyle-switch → main

View scan in OX Security →

@mattpodwysocki
mattpodwysocki merged commit cd84fbd into main Sep 17, 2026
5 checks passed
@mattpodwysocki
mattpodwysocki deleted the fix-render-map-basestyle-switch branch September 17, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants