Skip to content

fix: traceroute interval persistence and disable option#101

Merged
Yeraze merged 1 commit into
mainfrom
fix-traceroute-interval-persistence
Oct 5, 2025
Merged

fix: traceroute interval persistence and disable option#101
Yeraze merged 1 commit into
mainfrom
fix-traceroute-interval-persistence

Conversation

@Yeraze

@Yeraze Yeraze commented Oct 5, 2025

Copy link
Copy Markdown
Owner

Summary

Fixes #99 - Traceroute interval setting now persists across restarts and can be disabled

Changes

Bug Fix - Persistence

  • Server startup (src/server/server.ts:92-100): Load saved traceroute interval from database before connecting to Meshtastic node
  • Setting now properly persists across container/server restarts

Feature - Disable Option

  • Backend (src/server/meshtasticManager.ts):
    • Accept 0 as valid interval value (0-60 range instead of 1-60)
    • Skip scheduler when interval is 0 (disabled)
    • Add logging when traceroute is disabled
  • Server endpoints (src/server/server.ts):
    • Update validation to accept 0-60 range
    • Apply to both single endpoint and batch settings endpoint
  • UI (src/components/SettingsTab.tsx):
    • Update input min value from 1 to 0
    • Add description: "(0 = disabled). Requires container restart to take effect."
    • Update reset dialog to clarify disable option

Testing

  • ✅ All 278 tests passing
  • ✅ Verified setting persists after container restart
  • ✅ Tested with value of 5 minutes - successfully loaded from database
  • ✅ Container logs confirm: ✅ Loaded saved traceroute interval: 5 minutes

Impact

🤖 Generated with Claude Code

@claude

claude Bot commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

Claude finished @Yeraze's task —— View job


Pull Request Review

I've completed my comprehensive review of PR #101. Here are my findings:

Overall Assessment: EXCELLENT

This is a well-implemented fix that addresses the persistence issue and adds the requested disable functionality. The code quality is high with proper error handling and clear user feedback.

✅ Code Quality & Best Practices

  • Input validation: Proper range validation (0-60) with clear error messages
  • Error handling: Comprehensive try-catch blocks throughout
  • Logging: Excellent logging with clear indicators (✅, 🗺️) and descriptive messages
  • Type safety: Consistent TypeScript usage with proper type validation
  • Code organization: Changes are well-structured and follow existing patterns

✅ Bug Fixes - Persistence Issue

  • Root cause addressed: Loading settings from database before connecting to node (src/server/server.ts:92-100)
  • Proper initialization: Settings now persist correctly across container restarts
  • Database integration: Uses existing databaseService.getSetting() API consistently

✅ Feature Implementation - Disable Option

  • Backend validation: Updated range from 1-60 to 0-60 in both endpoints (src/server/server.ts:900, src/server/server.ts:944)
  • Scheduler logic: Properly skips scheduling when interval is 0 (src/server/meshtasticManager.ts:232-235)
  • UI feedback: Clear description "(0 = disabled). Requires container restart to take effect." (src/components/SettingsTab.tsx:244)
  • Reset dialog: Updated to clarify disable option (src/components/SettingsTab.tsx:105)

✅ Security & Performance

  • No security concerns: Input validation prevents malicious values
  • Performance: Minimal impact - only affects startup and settings endpoints
  • Resource management: Proper cleanup of intervals when disabled

✅ Test Coverage

  • All 278 tests passing ✅
  • Author verified persistence after container restart ✅
  • Manual testing with 5-minute interval confirmed ✅

Minor Suggestions (Optional improvements):

  1. Consider validation helper: The range validation intervalMinutes >= 0 && intervalMinutes <= 60 appears in multiple places - could be extracted to a helper function
  2. UI enhancement: Could add visual indicator when traceroute is disabled in the UI beyond the description text

Files Changed Analysis:

  • package.json: Version bump to 1.13.1 ✅
  • SettingsTab.tsx: UI updates for disable option ✅
  • meshtasticManager.ts: Core disable logic implementation ✅
  • server.ts: Persistence fix and endpoint validation ✅

🎯 Recommendation: APPROVE

This PR successfully fixes the persistence bug and implements the disable feature as requested in issue #99. The implementation is robust, well-tested, and follows best practices. No blocking issues identified.


Fixes #99

- Load saved traceroute interval from database on server startup
- Support setting interval to 0 to disable automatic traceroutes
- Update UI to allow min value of 0 with helpful description
- Update server endpoint validation to accept 0-60 range
- Add proper logging when traceroute is disabled
- Add note that setting requires container restart to take effect

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Yeraze Yeraze force-pushed the fix-traceroute-interval-persistence branch from 82acf80 to 46f1eae Compare October 5, 2025 12:06
@Yeraze Yeraze changed the title fix: traceroute interval persistence and disable option (v1.13.1) fix: traceroute interval persistence and disable option Oct 5, 2025
@claude

claude Bot commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

Claude finished @Yeraze's task —— View job


Pull Request Review

I've completed my comprehensive review of PR #101. Here are my findings:

Overall Assessment: EXCELLENT

This PR successfully addresses both the persistence issue (#99) and implements the disable functionality with high code quality and thorough implementation.

✅ Code Quality & Best Practices

Strong Points:

  • Input validation: Proper range validation (0-60) with clear error messages at src/server/server.ts:900 and src/server/server.ts:944
  • Error handling: Comprehensive try-catch blocks throughout the codebase
  • Logging: Excellent logging with clear indicators (✅, 🗺️) and descriptive messages
  • Type safety: Consistent TypeScript usage with proper type validation
  • Code organization: Changes follow existing patterns and architecture

Code Style:

  • Clean, readable code with consistent formatting
  • Appropriate variable naming and function structure
  • Good separation of concerns between UI, server, and manager layers

✅ Bug Fixes - Persistence Issue

Root Cause Addressed:

  • Critical fix: Loading settings from database before connecting to Meshtastic node (src/server/server.ts:92-100)
  • Proper initialization sequence: Settings now persist correctly across container restarts
  • Database integration: Uses existing databaseService.getSetting() API consistently

The fix ensures the traceroute interval is loaded and applied before the scheduler starts, which was the core issue.

✅ Feature Implementation - Disable Option

Backend Implementation:

  • Validation updated: Range changed from 1-60 to 0-60 in both endpoints
  • Scheduler logic: Properly skips scheduling when interval is 0 (src/server/meshtasticManager.ts:232-235)
  • Clear feedback: Logs when traceroute is disabled vs enabled

Frontend Implementation:

  • UI updates: Input min value changed from 1 to 0 (src/components/SettingsTab.tsx:249)
  • User guidance: Clear description text about disable option and restart requirement
  • Reset dialog: Updated to clarify disable option (src/components/SettingsTab.tsx:105)

✅ Security & Performance

Security:

  • Input validation: Prevents malicious values with proper range checking
  • No security vulnerabilities: No exposure of sensitive data or unsafe operations
  • Type safety: Consistent TypeScript usage prevents type-related issues

Performance:

  • Minimal impact: Only affects startup sequence and settings endpoints
  • Resource management: Proper cleanup of intervals when disabled
  • Efficient implementation: No unnecessary polling or processing when disabled

✅ Test Coverage & Verification

  • ✅ All 278 tests passing
  • ✅ Author verified persistence after container restart
  • ✅ Manual testing with 5-minute interval confirmed
  • ✅ Container logs confirm proper loading: ✅ Loaded saved traceroute interval: 5 minutes

✅ Implementation Details Analysis

Persistence Fix (src/server/server.ts:92-100):

const savedInterval = databaseService.getSetting('tracerouteIntervalMinutes');
if (savedInterval !== null) {
  const intervalMinutes = parseInt(savedInterval);
  if (!isNaN(intervalMinutes) && intervalMinutes >= 0 && intervalMinutes <= 60) {
    meshtasticManager.setTracerouteInterval(intervalMinutes);
    console.log(`✅ Loaded saved traceroute interval: ${intervalMinutes} minutes${intervalMinutes === 0 ? ' (disabled)' : ''}`);
  }
}
  • Proper null checking and validation
  • Clear logging for debugging
  • Range validation consistent with endpoints

Disable Logic (src/server/meshtasticManager.ts):

if (this.tracerouteIntervalMinutes === 0) {
  console.log('🗺️ Automatic traceroute is disabled');
  return;
}
  • Clean early return pattern
  • Clear logging for operational visibility

Minor Suggestions (Optional improvements):

  1. Validation helper: The range validation intervalMinutes >= 0 && intervalMinutes <= 60 appears multiple times - could be extracted to a helper function for consistency
  2. UI enhancement: Could add visual indicator in the UI when traceroute is disabled (beyond description text)

Files Changed Analysis:

  • SettingsTab.tsx: UI updates for disable option and clear user feedback
  • meshtasticManager.ts: Core disable logic with proper scheduler management
  • server.ts: Persistence fix and consistent endpoint validation

🎯 Recommendation: APPROVE

This PR successfully fixes the persistence bug and implements the disable feature as requested in issue #99. The implementation is robust, well-tested, and follows best practices. The code quality is excellent with proper error handling, input validation, and clear user feedback.

Key Strengths:

  • Addresses root cause of persistence issue
  • Clean implementation of disable functionality
  • Excellent code quality and testing
  • Clear user feedback and logging
  • No security or performance concerns

No blocking issues identified.


@Yeraze Yeraze merged commit d50ad79 into main Oct 5, 2025
12 checks passed
@Yeraze Yeraze deleted the fix-traceroute-interval-persistence branch October 5, 2025 12:14
@tonicb78

tonicb78 commented Oct 5, 2025

Copy link
Copy Markdown

Thanks!

Yeraze added a commit that referenced this pull request Oct 12, 2025
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Traceroute interval 3 minutes when restarting

2 participants