feat(ag-ui): AdvancedMarkerElement + Map ID for the App-mode map#745
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @blove's task in 3m 0s —— View job Code Review
Overall: looks good. The migration from Checked — no issues:
One observation (inline comment posted on line 109): |
| `; | ||
| writeFileSync(targetPath, contents); | ||
| console.log(`[inject-env] wrote generated-keys.local.ts (key length: ${key.length})`); | ||
| console.log(`[inject-env] wrote generated-keys.local.ts (key length: ${key.length}, mapId: ${mapId ? 'set' : 'unset'})`); |
| stop: s, | ||
| position: { lat: s.lat!, lng: s.lng! }, | ||
| content: this.makePin(s.day), | ||
| })), |
There was a problem hiding this comment.
makePin allocates a new HTMLElement for every stop on every execution of this computed. stopsWithCoords() recomputes whenever any stop mutates — including text-only changes (agent renames a place, adds a note) — so all pin nodes are silently replaced even when no day or position changed. The old elements handed to the Maps API are detached and GC'd, so it's not a correctness bug, but it's more aggressive DOM churn than the @for track m.id rhythm implies.
An easy guard: key the element by (s.id, s.day) with a Map cache so pins are only rebuilt when the day (i.e., colour) actually changes:
| })), | |
| protected readonly markerViews = computed(() => { | |
| const prev = this._pinCache; | |
| const next = new Map<string, HTMLElement>(); | |
| return this.stopsWithCoords().map((s) => { | |
| const cacheKey = `${s.id}:${s.day}`; | |
| const content = prev.get(cacheKey) ?? this.makePin(s.day); | |
| next.set(cacheKey, content); | |
| this._pinCache = next; | |
| return { id: s.id, stop: s, position: { lat: s.lat!, lng: s.lng! }, content }; | |
| }); | |
| }); | |
| private _pinCache = new Map<string, HTMLElement>(); |
Or, if you prefer a lighter touch, just leave a comment clarifying that "stops change" includes text edits, so readers aren't surprised.
Salvages the genuinely-unique map-rendering improvements from #738 onto main's current (shipped) App-mode layout — without #738's competing layout rewrite (which reverts #737's shipped absolute-background approach + reintroduces the removed launcher hint). #738's layout commits are intentionally dropped; this keeps the verified layout and lands only the rendering upgrades.
Cherry-picked from #738 (4 commits):
GOOGLE_MAPS_MAP_IDthrough the env mechanism (env → inject-env → generated-keys)markerlibrary<map-marker>→<map-advanced-marker>(MapAdvancedMarker, custom pincontent), drop the inlineDARK_STYLEarray in favor of a cloud-based style tied to the Map ID (falls back to Google'sDEMO_MAP_IDso a fresh clone still runs — light map)GOOGLE_MAPS_API_KEY+GOOGLE_MAPS_MAP_IDDeliberately NOT included: #738's fitBounds-with-panel-insets (coupled to its layout + a
map-bounds.tsutil; it's the already-deferred POL.1) and all of #738's App-mode layout commits (superseded by #737).Verified: lint 0 errors, unit ✓, build ✓, ag-ui e2e 28/28, and live in Chrome — 3 advanced markers render on the shipped layout, marker library loaded, no console errors (only a benign
gmp-clickhint from the Angular wrapper). Dark cockpit style activates when a dark-styled Map ID is set in.env.Supersedes #738 (which I'll close).
🤖 Generated with Claude Code