feat(mqtt-bridge): interactive map editor for filter geographic bounding box#3064
Conversation
…ing box
The mqtt_bridge filter's geographic bounding box previously had only
four free-text inputs (minLat / maxLat / minLng / maxLng). Pulling a
useful Florida-sized box out of those numbers required jumping over to
Google Maps or some other tool to read off coordinates, then typing
them back into the modal. That's a poor user experience for what is
fundamentally a spatial operation.
Adds `src/components/BBoxMapEditor.tsx`: a Leaflet-backed rectangular
bbox editor.
- No bbox set: hint reads "click two corners on the map to draw the
bounding box". First click drops a yellow marker at corner A; mouse
movement paints a dashed preview rectangle from A to the cursor; the
second click finalizes the bbox.
- Defined bbox: rendered as a solid blue rectangle with four draggable
corner handles (SW / NW / NE / SE). Dragging any handle resizes —
the opposite corner stays fixed.
- Two-way bound with the four numeric inputs (kept beneath the map for
precise tuning) via `bboxFromForm()` helper. Drag the map, the
numbers update; type a number, the rectangle re-renders.
- "Clear" button reverts to undefined.
Wired into the existing geo-bbox fieldset on the Add/Edit Source modal
in DashboardPage, only rendering when the user has the "Restrict to
geographic bounding box" checkbox enabled.
`BBoxMapEditor` deliberately owns its own data model
(`{ minLat, maxLat, minLng, maxLng }`) instead of growing a bbox
variant on the auto-responder's `GeofenceShape` discriminated union.
That type powers a separate feature (geofence triggers) with its own
geometry helpers; the MQTT filter is rectangular by definition and
shouldn't pull in circles/polygons.
All 9967 vitest tests still pass; tsc clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review: Interactive Map Editor for MQTT Bridge BBoxReview Progress
Overall Assessment: ✅ High Quality ImplementationThis PR introduces a well-architected interactive map editor that significantly improves UX for configuring geographic bounding boxes. The implementation follows React and Leaflet best practices with clean separation of concerns. Code Quality & Best Practices✅ StrengthsComponent Architecture
React Best Practices
Leaflet Integration
Code Organization
🔧 Minor ImprovementsTypeScript: Consider stricter type for corners array at lines 131-168: const corners: ReadonlyArray<{
readonly pos: L.LatLng;
readonly updateFromDrag: (p: L.LatLng) => BBoxValue;
}> = [...]Performance: The corner drag logic could be optimized to reduce redundant calculations by memoizing the update functions. Potential Issues & Edge Cases
|
When the bridge filter has a geographic bbox configured, gate ALL portnums (not just POSITION_APP) on the sender's last known bbox membership. A node is considered "inside" only after we've decoded a position payload for it that fell within the bbox. Senders we haven't classified — including those we've never seen a position for — are dropped fail-closed. Without this, a node 1000km outside the bbox could still pollute the local broker with TEXT, TELEMETRY, NODEINFO, NEIGHBORINFO, etc., because the bbox only ever filtered POSITION payloads. Combined with the interactive editor in 089a734, the bbox now actually keeps out-of-area traffic out. - MqttPacketFilter learns membership from postFilterPosition(position, fromNum) and gates non-position traffic via passesMembership(fromNum) - Membership cache is per-filter (per-bridge), FIFO-evicted at 10k entries - Ingestion + bridge handleDownlink both apply the gate before persist/republish - Drops increment the existing geo drop counter Tests: - 11 new MqttPacketFilter unit tests covering fail-closed semantics, position-learns-membership, half-open bboxes, no-bbox no-op, and instance isolation - 7 new ingestion tests proving the gate short-circuits TEXT/NODEINFO/ TELEMETRY before any database call Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @Yeraze's task —— View job PR Code Review: Interactive Map Editor for MQTT Bridge BBoxReview Progress
Overall Assessment: ✅ High Quality ImplementationThis PR introduces a well-architected interactive map editor that significantly improves UX for configuring geographic bounding boxes. The implementation follows React and Leaflet best practices with clean separation of concerns. Code Quality & Best Practices✅ StrengthsComponent Architecture
React Best Practices
Leaflet Integration
Code Organization
🔧 Minor ImprovementsTypeScript: Consider stricter type for corners array at lines 131-168: const corners: ReadonlyArray<{
readonly pos: L.LatLng;
readonly updateFromDrag: (p: L.LatLng) => BBoxValue;
}> = [...]Performance: The corner drag logic could be optimized to reduce redundant calculations by memoizing the update functions. Potential Issues & Edge Cases
|
System Test ResultsMeshMonitor System Test ResultsTest Run: 2026-05-17 22:31:04 EDT ❌ Overall Result: FAILEDAborted on first failing test (fail-fast mode). Remaining tests skipped. Failed Test
|
System Test ResultsMeshMonitor System Test ResultsTest Run: 2026-05-17 22:44:13 EDT Test Summary
✅ Overall Result: PASSEDAll deployment configurations are working correctly! Test DetailsConfiguration Import:
Quick Start Test:
Security Test:
V1 API Test:
Reverse Proxy Test:
Reverse Proxy + OIDC Test:
Virtual Node CLI Test:
Backup & Restore Test:
Database Migration Test:
DB Backing Consistency Test:
|
Summary
Replace the four free-text bbox inputs on the MQTT Bridge source-config modal with a Leaflet-backed interactive editor. Click two corners to draw, drag any corner handle to resize, "Clear" to start over. The numeric inputs stay beneath the map for precise tuning and are two-way bound — drag the map, the numbers update; type a number, the rectangle re-renders.
Why
Pulling a useful Florida-sized bbox out of
minLat / maxLat / minLng / maxLngtext boxes required jumping over to Google Maps to read coordinates, then typing them back into the modal. The bbox is a fundamentally spatial filter, so editing it should be spatial too.Design notes
src/components/BBoxMapEditor.tsx(not a variant of the existingGeofenceMapEditor). The auto-responder'sGeofenceShapediscriminated union (circle | polygon) already powers a separate geofence-triggers feature; growing it to includebboxwould force changes acrosssrc/utils/geometry.ts,GeofenceTriggersSection.tsx, and the geofence test suite for no MQTT-side benefit. Keeping the MQTT filter's rectangular data model ({ minLat, maxLat, minLng, maxLng }) self-contained is cleaner.GeofenceMapEditorfor visual consistency.minLat + minLng; NE stays put).bboxFromForm()helper tolerates partial / NaN values in the text inputs so a user mid-typing doesn't break the map.Test plan
tsc --noEmitclean🤖 Generated with Claude Code