feat: export MeshCore packet monitor log as JSONL (#3391)#3394
Conversation
Add a JSON(L) export to the MeshCore Packet Monitor, mirroring the Meshtastic packet-monitor export. - meshcoreRoutes.ts: new GET /api/sources/:id/meshcore/packets/export route streaming the OTA packet log as one JSON object per line (newest first), honoring the same payload_type / route_type / since filters as the list endpoint. Same optionalAuth + packetmonitor:read permission, timestamped attachment filename (…-filtered-… when filters are active). - MeshCorePacketMonitorView.tsx: Download toolbar button + handleExport blob download, carrying the active payload/route filters. - meshcoreRoutes.test.ts: mock meshcorePacketLogService; cover JSONL output + headers, filter pass-through/filename, and the per-source 404 guard. Closes #3391 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review: MeshCore Packet ExportReview Tasks
Overall Assessment ✅This is a well-implemented feature that successfully mirrors the existing Meshtastic packet export functionality for MeshCore. The implementation follows repository conventions and maintains consistency with the existing codebase. Code Quality & Best Practices ✅Strengths:
Minor observations:
Security Analysis ✅Authentication & Authorization:
Input Validation: // Line 3015-3019: Proper parameter validation
const payloadType = req.query.payload_type !== undefined ? parseInt(req.query.payload_type as string, 10) : undefined;
const routeType = req.query.route_type !== undefined ? parseInt(req.query.route_type as string, 10) : undefined;
let since = req.query.since !== undefined ? parseInt(req.query.since as string, 10) : undefined;
if (since !== undefined && since < 1e12) since = since * 1000; // Seconds to milliseconds conversion
Performance Considerations ✅Efficient Implementation:
Potential concerns:
Test Coverage ✅Comprehensive test suite (
The tests cover all critical functionality and edge cases. UI Implementation ✅Frontend changes (
Specific Technical Comments
Minor Suggestions
ConclusionThis PR successfully implements JSONL export for MeshCore packets with:
Recommendation: APPROVE 🎉 The implementation is production-ready and maintains the high quality standards of the codebase. |
Summary
Closes #3391 — adds a JSON(L) export to the MeshCore Packet Monitor, mirroring the existing Meshtastic packet-monitor export.
Changes
src/server/routes/meshcoreRoutes.ts— newGET /api/sources/:id/meshcore/packets/exportroute. Streams the source's OTA packet log as JSONL (one JSON object per line, newest first), honoring the samepayload_type/route_type/sincefilters as the list endpoint. Uses the sameoptionalAuth+packetmonitor:readpermission, and returns a timestamped attachment filename (meshcore-packet-monitor-<ts>.jsonl, or…-filtered-<ts>.jsonlwhen filters are active).src/components/MeshCore/MeshCorePacketMonitorView.tsx— a Download button in the monitor toolbar (next to Refresh/Clear) with ahandleExportblob-download handler that carries the currently-active payload/route filters. Reuses the existingcommon.exporti18n key.src/server/routes/meshcoreRoutes.test.ts— mocksmeshcorePacketLogServiceand adds coverage for: JSONL body + attachment headers, filter pass-through +-filtered-filename, and the per-source 404 guard.Behavior
Matches the Meshtastic export exactly — same JSONL format, same streaming approach, same filter-aware filename — so the two packet monitors behave identically.
Testing
npx tsc --noEmit— cleanvitest run src/server/routes/meshcoreRoutes.test.ts— 140/140 pass (incl. 3 new export tests)🤖 Generated with Claude Code