feat: extend map targeting and overlay controls

Support batch feature targeting and clear map highlights and overlays from the More panel. Remove misleading action chevrons and unused configuration export entries.

Validated the isolated patch with lint, typecheck, 36 focused tests and 5 browser cases using mocked data.
This commit is contained in:
2026-10-28 14:47:33 +08:00
parent e57e0f099f
commit 5b710d1247
17 changed files with 666 additions and 202 deletions
@@ -55,15 +55,25 @@ export function useInvestigationPresentation(options: Options) {
const [highlightLayers, setHighlightLayers] = useState<string[]>([]);
const followerRef = useRef<InvestigationPresentationFollower | null>(null);
const manualRequestRef = useRef<AbortController | null>(null);
const mapCommandsRef = useRef(new AbortController());
const scene = useMemo(() => new InvestigationMapPresentation(() => options.mapRef.current, () => valuesRef.current.getPadding()), [options.mapRef]);
const taskId = options.task?.task_id ?? null;
const subscribe = options.sync.subscribePresentationEvents;
const clear = useCallback(() => {
scene.clear(); setCharts([]); setOverlay(null); setHighlightLayers([]);
valuesRef.current.onClearLayers();
const clearMapOverlays = useCallback((discardPending = true) => {
mapCommandsRef.current.abort();
mapCommandsRef.current = new AbortController();
manualRequestRef.current?.abort();
if (discardPending) followerRef.current?.discardPendingMapCommands();
scene.clear(); setOverlay(null); setHighlightLayers([]);
}, [scene]);
const clear = useCallback(() => {
// New task generations retain their first queued map command.
clearMapOverlays(false); setCharts([]);
valuesRef.current.onClearLayers();
}, [clearMapOverlays]);
useEffect(() => {
manualRequestRef.current?.abort();
cameraPausedRef.current = false;
@@ -77,26 +87,35 @@ export function useInvestigationPresentation(options: Options) {
stopPulse: () => scene.stopPulse(),
onStatus: (next, message) => { setStatus(next); setError(message ?? null); },
execute: async (command, signal) => {
const sourceSignal = signal;
if (command.action !== "open_chart" && command.action !== "close_chart") {
signal = AbortSignal.any([signal, mapCommandsRef.current.signal]);
}
signal.throwIfAborted();
if (command.action === "highlight_features") {
const collection = await valuesRef.current.controller.queryPresentationFeatures(command.layer, command.feature_ids, signal);
signal.throwIfAborted();
scene.highlight(collection, command.effect === "pulse", !cameraPausedRef.current);
setHighlightLayers([command.layer]);
} else if (command.action === "clear_highlights") {
scene.clearHighlights(); setHighlightLayers([]);
} else if (command.action === "open_chart") {
setCharts((current) => [...current.filter((item) => item.chart_id !== command.chart_id).slice(-5), command]);
await waitForChart(command.chart_id, signal);
} else if (command.action === "close_chart") {
setCharts((current) => current.filter((item) => item.chart_id !== command.chart_id));
await frame(signal);
} else if (command.action === "set_overlay") {
const next = { ...command, visible: true };
scene.setOverlay(next, !cameraPausedRef.current); setOverlay(next);
} else {
scene.clearOverlay(command.overlay_id);
setOverlay((current) => current?.overlay_id === command.overlay_id ? null : current);
try {
if (command.action === "highlight_features") {
const collection = await valuesRef.current.controller.queryPresentationFeatures(command.layer, command.feature_ids, signal);
signal.throwIfAborted();
scene.highlight(collection, command.effect === "pulse", !cameraPausedRef.current);
setHighlightLayers([command.layer]);
} else if (command.action === "clear_highlights") {
scene.clearHighlights(); setHighlightLayers([]);
} else if (command.action === "open_chart") {
setCharts((current) => [...current.filter((item) => item.chart_id !== command.chart_id).slice(-5), command]);
await waitForChart(command.chart_id, signal);
} else if (command.action === "close_chart") {
setCharts((current) => current.filter((item) => item.chart_id !== command.chart_id));
await frame(signal);
} else if (command.action === "set_overlay") {
const next = { ...command, visible: true };
scene.setOverlay(next, !cameraPausedRef.current); setOverlay(next);
} else {
scene.clearOverlay(command.overlay_id);
setOverlay((current) => current?.overlay_id === command.overlay_id ? null : current);
}
} catch (cause) {
if (signal.aborted && !sourceSignal.aborted) return;
throw cause;
}
}
});
@@ -138,7 +157,7 @@ export function useInvestigationPresentation(options: Options) {
}, [pauseCamera, scene]);
return {
charts, overlay, cameraPaused, status, error, highlightLayers,
charts, overlay, cameraPaused, status, error, highlightLayers, clearMapOverlays,
pauseCamera,
resumeCamera: () => { cameraPausedRef.current = false; setCameraPaused(false); },
locateTargets,