feat(meshcore): native meshcore.js backend + remove Python bridge and 3.x addon#3031
Conversation
MeshCore is a first-class source in 4.x (multi-source registry, per-source page, source-add UI). The 3.x env-var bootstrap and the addon-style overlay on the Meshtastic NodesTab no longer have a reason to exist. This deletes them outright. Backend: - server.ts: drop MESHCORE_ENABLED auto-bootstrap block - authRoutes: drop meshcoreEnabled field from /api/auth/status - meshcoreManager: drop getEnvConfig / getConfigFromEnv and the env-var fallback in connect() — config is now required - meshcoreRoutes: drop envConfig from /status and /snapshot, drop MESHCORE_FIRMWARE_TYPE fallback in /connect (read deviceType from the request body instead) - meshcoreRegistry: drop LEGACY_MESHCORE_SOURCE_ID, getOrCreateLegacyManager, getPrimaryForLegacyRoutes — the un-nested /api/meshcore/* mount was already gone Frontend: - AuthContext: drop meshcoreEnabled field - App.tsx: drop MeshCoreTab import, the activeTab === 'meshcore' branch, the search-result redirect, and the meshcoreEnabled prop - Sidebar: drop meshcoreEnabled prop - TabType / UIContext: drop 'meshcore' - NodesTab: drop the addon polling effect, the showMeshCoreNodes checkbox, the MeshCore map markers, sidebar nodes section, and all conditional fallbacks (~12 references, -250 lines) - MeshCoreSettingsView: drop env-config pre-population — always per-source now - useMeshCore: sourceId is required, singleton mode gone; drop ConnectParams, envConfig, unused fetchNodes/fetchContacts - MeshCorePage: sourceId required, drop MeshCoreTab alias - Delete MeshCore/MeshCoreTab.tsx (re-export shim) and the MeshCoreTab export from index.ts Env / docs: - .env.example: remove MESHCORE_ENABLED/SERIAL_PORT/BAUD_RATE/ FIRMWARE_TYPE; keep the two telemetry-scheduler tuning vars - docs/features/meshcore.md: remove the env-var bootstrap section and Docker Compose examples that set MESHCORE_ENABLED; add a 4.6 removal note Migrations are untouched — the meshcore-legacy-default source row still gets backfilled for upgraded databases (057, 061). Tests: 4932 pass / 535 skip / 21 todo. tsc clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
950bbae to
9bcf6e7
Compare
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @Yeraze's task —— View job PR Review: MeshCore Native JS Backend MigrationReviewing this major architectural migration from Python bridge to native JS backend for MeshCore integration. Review Tasks
Code Quality & ArchitectureExcellent refactoring - This is a well-executed migration that significantly simplifies the codebase: ✅ Architectural Improvements:
✅ Code Quality:
Error Handling & Cleanup ✅Robust disconnect logic in // Clear reconnect intent first to prevent race conditions
this.shouldReconnect = false;
// Stop heartbeat before transport teardown
this.stopHeartbeat();
// Graceful backend teardown with error logging
try {
await this.nativeBackend.disconnect();
} catch (err) {
logger.debug(`[MeshCore] Native backend disconnect threw: ${(err as Error).message}`);
}
// Clean up all pending commands with proper rejection
for (const [_id, cmd] of this.pendingCommands) {
clearTimeout(cmd.timeout);
cmd.reject(new Error('Disconnected'));
}Comprehensive heartbeat system with exponential backoff and connection state management. Security Assessment ✅Positive security changes:
No new security concerns identified. Test Coverage ✅Excellent test coverage with 17 MeshCore-related test files:
4932 passing tests as noted in PR description shows comprehensive regression testing. Migration Path & Backward Compatibility ✅Well-planned migration strategy:
Minor Suggestions
Overall AssessmentThis is an exemplary migration that significantly improves the codebase architecture while maintaining full backward compatibility. The removal of the Python bridge eliminates a major complexity source, and the native JS implementation is well-structured with proper error handling and comprehensive test coverage. Strong recommendation to merge - this represents a major step forward for MeshCore integration reliability and maintainability. |
System Test ResultsMeshMonitor System Test ResultsTest Run: 2026-05-15 14:49:50 EDT Test Summary
❌ Overall Result: FAILEDSome tests failed. Please review the failures above and fix before creating/updating PR. Failed Tests
|
System Test ResultsMeshMonitor System Test ResultsTest Run: 2026-05-15 15:08:01 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
End-to-end migration of the MeshCore integration off the legacy Python bridge and the 3.x "addon" architecture. After this branch:
@liamcottle/meshcore.js(USB serial + TCP) — no Python subprocess, nomeshcorepip dep, noMESHCORE_TRANSPORTflag.MESHCORE_ENABLEDet al.) and the addon-style overlay on the Meshtastic NodesTab are gone.activeTab === 'meshcore'view and the singleton mode ofuseMeshCorewere removed.Commits in order:
87b42408— TCP transport option in the MeshCore source modaladc90827— native JS backend behindMESHCORE_TRANSPORT=native(parallel with Python bridge)798cf5b1— wire native backend to the meshcore.js fork helpers (setAdvertLocPolicy, telemetry-mode setters, SelfInfo bridge)e7130303— explicitly callgetSelfInfoafter connectf7ecb31a— delete Python bridge, dropMESHCORE_TRANSPORTflag, native is the only path950bbae1— remove the 3.x addon-style integration (env-var bootstrap, NodesTab overlay, legacy registry helpers,meshcoreEnabledeverywhere)What's no longer supported
MESHCORE_ENABLED=false|true/MESHCORE_SERIAL_PORT/MESHCORE_BAUD_RATE/MESHCORE_TCP_HOST/MESHCORE_TCP_PORT/MESHCORE_FIRMWARE_TYPE— these env vars no longer do anything. The deprecation note is indocs/features/meshcore.mdand.env.example. Migrate by adding the MeshCore source from the Sources sidebar.MESHCORE_TRANSPORTflag — native is the only backend.meshcoreEnabledfield on/api/auth/status— clients should rely on the source list and per-source permissions.MESHCORE_TELEMETRY_INTERVAL_MSandMESHCORE_REMOTE_TELEMETRY_TICK_MS(scheduler tuning) are kept.Migrations
Untouched. Migration 057 still mints the
meshcore-legacy-defaultsource on first run against upgraded DBs and migration 061's composite-PK backfill still references that ID — both still pass their tests.Verification
npx tsc --noEmit→ 0 errorsvitest --run→ 4932 pass / 535 skip / 21 todo across 289 test filesdocker-compose.dev.yml+docker-compose.dev.local.ymlfor ttyUSB exposure) builds and starts clean/api/auth/statusconfirmed to no longer containmeshcoreEnabled[MeshCore] Auto-connecting legacy env-var sourcelog line at startupnodeuser is indialout(gid 20) and gid 46 — ready for real-hardware MeshCore source testing through the UIf7ecb31a(two sources connected + exchanged messages)Test plan
meshcore-legacy-defaultsource row exists,meshcore_nodesrows reattach to it via the composite PK/api/auth/statusresponse has nomeshcoreEnabledfield🤖 Generated with Claude Code