feat: add project-aware agent workspace
This commit is contained in:
@@ -40,6 +40,7 @@ export type WorkbenchDrawingAnnotation = {
|
||||
};
|
||||
|
||||
type UseWorkbenchDrawingOptions = {
|
||||
selectionEnabled?: boolean;
|
||||
mapRef: RefObject<MapLibreMap | null>;
|
||||
mapReady: boolean;
|
||||
activeMode: WorkbenchDrawMode | null;
|
||||
@@ -47,6 +48,7 @@ type UseWorkbenchDrawingOptions = {
|
||||
};
|
||||
|
||||
export function useWorkbenchDrawing({
|
||||
selectionEnabled = true,
|
||||
mapRef,
|
||||
mapReady,
|
||||
activeMode,
|
||||
@@ -134,7 +136,7 @@ export function useWorkbenchDrawing({
|
||||
|
||||
useEffect(() => {
|
||||
const map = mapRef.current;
|
||||
if (!mapReady || !map || activeMode) {
|
||||
if (!mapReady || !map || activeMode || !selectionEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,6 +169,9 @@ export function useWorkbenchDrawing({
|
||||
});
|
||||
|
||||
return () => {
|
||||
// The map owner may already have disposed this instance during project switching.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- Read the live owner ref to detect map disposal.
|
||||
if (mapRef.current !== activeMap) return;
|
||||
DRAWING_INTERACTIVE_LAYER_IDS.forEach((layerId) => {
|
||||
if (activeMap.getLayer(layerId)) {
|
||||
activeMap.off("click", layerId, handleDrawingClick);
|
||||
@@ -175,7 +180,7 @@ export function useWorkbenchDrawing({
|
||||
}
|
||||
});
|
||||
};
|
||||
}, [activeMode, mapReady, mapRef]);
|
||||
}, [activeMode, mapReady, mapRef, selectionEnabled]);
|
||||
|
||||
const updateDraft = useCallback(
|
||||
(draft: DrawingDraftState | null) => {
|
||||
|
||||
Reference in New Issue
Block a user