From ef77b312fa31c05d9950c6a639106d423a30d755 Mon Sep 17 00:00:00 2001 From: Maurice Date: Wed, 21 Oct 2026 21:50:49 +0200 Subject: [PATCH] fix(assistant): camera listens on the canvas container, plugin facts regenerated - the assistant's GL camera reads the user's own moves from the map's canvas container, which both engines have and which leaves marker clicks out, so the GL map test needs no extra mock and stays at its size - plugin-sdk host facts list the ai_assistant addon --- client/src/components/Map/MapViewGL.test.tsx | 2 -- client/src/components/Map/useAssistantCameraGL.test.ts | 2 +- client/src/components/Map/useAssistantCameraGL.ts | 5 +++-- plugin-sdk/src/generated/host-facts.ts | 1 + 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/components/Map/MapViewGL.test.tsx b/client/src/components/Map/MapViewGL.test.tsx index d8b327e8d..6a1b4a0ac 100644 --- a/client/src/components/Map/MapViewGL.test.tsx +++ b/client/src/components/Map/MapViewGL.test.tsx @@ -47,8 +47,6 @@ const glMap = vi.hoisted(() => ({ getStyle: vi.fn().mockReturnValue({ layers: [] }), isStyleLoaded: vi.fn().mockReturnValue(true), getCanvasContainer: vi.fn(() => glCanvasContainer), - // The assistant's camera listens on the map's container for the user's own moves. - getContainer: vi.fn(() => glCanvasContainer), getLayer: vi.fn().mockReturnValue(null), queryRenderedFeatures: vi.fn().mockReturnValue([]), querySourceFeatures: vi.fn().mockReturnValue([]), diff --git a/client/src/components/Map/useAssistantCameraGL.test.ts b/client/src/components/Map/useAssistantCameraGL.test.ts index ba7abed83..cdbb885db 100644 --- a/client/src/components/Map/useAssistantCameraGL.test.ts +++ b/client/src/components/Map/useAssistantCameraGL.test.ts @@ -31,7 +31,7 @@ function camera(key: string, over: Partial = {}): AssistantCame function setup(first: AssistantCamera | null, inside = false) { const container = document.createElement('div'); const map = { - getContainer: () => container, + getCanvasContainer: () => container, getBounds: () => ({ contains: () => inside }), fitBounds: vi.fn(), easeTo: vi.fn(), diff --git a/client/src/components/Map/useAssistantCameraGL.ts b/client/src/components/Map/useAssistantCameraGL.ts index 27ece44bf..5278b001d 100644 --- a/client/src/components/Map/useAssistantCameraGL.ts +++ b/client/src/components/Map/useAssistantCameraGL.ts @@ -5,7 +5,8 @@ import type { AssistantCamera } from './mapViewContract'; /** The slice of the GL map the camera drives. */ export interface CameraMap { - getContainer: () => HTMLElement; + /** Where the user drags, wheels and pinches the map; marker clicks are not moves. */ + getCanvasContainer: () => HTMLElement; getBounds: () => { contains: (lngLat: [number, number]) => boolean } | null; fitBounds: (bounds: unknown, options: { padding: ViewportPadding; maxZoom: number; duration: number }) => unknown; easeTo: (options: { center: [number, number]; duration: number }) => unknown; @@ -32,7 +33,7 @@ interface AssistantCameraOptions { * Leaflet map (one GL zoom step is a raster step lower). */ export function useAssistantCameraGL({ mapRef, mapReady, gl, camera, padding }: AssistantCameraOptions): void { - const getContainer = useCallback(() => mapRef.current?.getContainer() ?? null, [mapRef]); + const getContainer = useCallback(() => mapRef.current?.getCanvasContainer() ?? null, [mapRef]); const userMovedAt = useUserMoveClock(getContainer, mapReady); const request = useCameraRequest(camera, userMovedAt); diff --git a/plugin-sdk/src/generated/host-facts.ts b/plugin-sdk/src/generated/host-facts.ts index acdd0936a..3ebba1e5d 100644 --- a/plugin-sdk/src/generated/host-facts.ts +++ b/plugin-sdk/src/generated/host-facts.ts @@ -409,6 +409,7 @@ export const KNOWN_ADDONS: string[] = [ 'collections', 'roadtrip', 'tours', + 'ai_assistant', ]; /**