fix(meshcore): honor packet-monitor Max count setting in the live list (#3690)#3693
Conversation
#3690) The MeshCore Packet Monitor list endpoint (GET /api/sources/:id/meshcore/packets) ignored the user-configured meshcore_packet_log_max_count setting. It used a hard-coded default limit of 100, clamped only by MESHCORE_PACKET_MAX_LIMIT (1000), so the monitor showed at most ~200 rows (the client's PAGE_LIMIT) regardless of the configured retention cap. The export endpoint already read getMaxCount() correctly, producing inconsistent behavior. Fix: the list endpoint now reads meshcorePacketLogService.getMaxCount() and uses it as the effective query limit when the client does not supply an explicit ?limit, mirroring the export endpoint exactly. An explicit smaller client-supplied limit still wins; both are clamped by the MESHCORE_PACKET_MAX_LIMIT ceiling. The frontend view no longer hard-codes limit=200 on load, so the server-side setting governs. Adds list-endpoint tests asserting: the configured max count (500) is used as the limit, the cap is clamped to 1000, and an explicit smaller client limit (50) is honored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBLhGGNh35oMwTL53va1Y5
|
Claude finished @Yeraze's task —— View job PR Review: fix(meshcore): honor packet-monitor Max count setting in the live listTasks:
SummaryClean, targeted fix that resolves the inconsistency between the list and export endpoints. The approach is sound and the test coverage is appropriate. A few observations below. Code Quality
The logic is correct, but there's a subtle edge case worth noting: if a client passes const effectiveLimit = Number.isFinite(requestedLimit) && requestedLimit > 0 ? requestedLimit : maxCount;...could return up to
The PR description mentions deduplication of the
The The removal of Test CoverageThe three new tests in
Missing test case: There's no test covering an explicit client-supplied Minor Observations
VerdictApprove with suggestions. The core fix is correct and the tests cover the primary behavior. The edge case around client limits larger than |
Root cause
The MeshCore Packet Monitor live-list endpoint
GET /api/sources/:id/meshcore/packetsignored the user-configuredmeshcore_packet_log_max_countsetting. It applied a hard-coded default limit of100, clamped only byMESHCORE_PACKET_MAX_LIMIT(1000), against whateverlimitthe client sent. The frontend always sentlimit=200(PAGE_LIMIT), so the monitor showed at most ~200 packets regardless of the configured Max count.The export endpoint (
GET .../packets/export) already readmeshcorePacketLogService.getMaxCount()and used it as the query limit — so the two endpoints behaved inconsistently, and the live monitor never honored the setting users could change in the UI.Fix
meshcorePacketLogService.getMaxCount()and uses it as the effective query limit when the client does not supply an explicit?limit, mirroring the export endpoint precisely. An explicit, smaller client-suppliedlimitstill wins so a caller can request fewer rows; both are clamped by theMESHCORE_PACKET_MAX_LIMITceiling (1000). The previously-fetchedmaxCountin the responsePromise.allwas deduplicated into the new single read.MeshCorePacketMonitorView.tsxno longer hard-codeslimit=200on load, so the server-side setting governs the page size. The unusedPAGE_LIMITconstant was removed; the liveMAX_BUFFER(2000) cap is unchanged.The setting-read mirrors export exactly:
(
getMaxCount()reads the globalmeshcore_packet_log_max_countsetting viadatabaseService.getSettingAsync, defaulting toDEFAULT_MAX_COUNTwhen unset/invalid.)Tests
Added a
GET .../packets (list)describe block inmeshcoreRoutes.test.tsasserting the list endpoint:limit: 500whengetMaxCount()returns 500 (no explicit client limit),limit=50.Full Vitest suite: 7373 passed, 0 failed, 0 failed suites (
success: true).tsc --noEmitreports no new errors in the touched files.🤖 Generated with Claude Code