Skip to content

feat: improve map visualization and traceroute scheduling#93

Merged
Yeraze merged 1 commit into
mainfrom
feat/map-viz-traceroute-improvements
Oct 4, 2025
Merged

feat: improve map visualization and traceroute scheduling#93
Yeraze merged 1 commit into
mainfrom
feat/map-viz-traceroute-improvements

Conversation

@Yeraze

@Yeraze Yeraze commented Oct 4, 2025

Copy link
Copy Markdown
Owner

Summary

  • Map Visualization: Display nodes without traceroute in grey (instead of red), always show local node in green, and clarify map control labels
  • Traceroute Scheduler: Implement smart retry intervals (3h for untraced nodes, 24h for traced nodes) with random selection to prevent targeting same nodes repeatedly
  • Message Display: Preserve linebreaks in messages for better readability of multi-line content (e.g., weather forecasts)

Changes

Map Visualization Improvements

  • Nodes with no traceroute data now display in grey (#9ca3af) instead of red
  • Local/connected node always displays in green (0 hops)
  • Updated map legend to show "Local Node" and "No Traceroute" entries
  • Renamed map controls for clarity:
    • "Show Paths" → "Show Route Segments"
    • "Show Route" → "Show Traceroute"
    • "Show Motion" → "Show Position History"

Traceroute Scheduler Enhancements

  • Smart retry intervals:
    • Nodes without successful traceroute: retry every 3 hours
    • Nodes with successful traceroute: retry every 24 hours
  • Random node selection from all eligible nodes (prevents continuously retrying same node)
  • Updated getNodeNeedingTraceroute() to query based on traceroute existence and age
  • Added comprehensive tests for new time-based retry logic

Message Display Fix

  • Added whiteSpace: 'pre-line' to all message displays (channel and DM messages)
  • Preserves linebreaks (\n) while collapsing other whitespace
  • Significantly improves readability of multi-line messages from weather bots and other sources

Test Plan

  • Verify grey color appears for nodes without traceroute data
  • Verify local node displays in green
  • Verify map legend shows all color categories correctly
  • Verify traceroute scheduler selects different nodes randomly
  • Verify 3h/24h retry intervals work correctly
  • Verify multi-line messages display with proper linebreaks
  • All unit tests pass (29/29 in database.extended.test.ts)

🤖 Generated with Claude Code

Map Visualization:
- Display nodes without traceroute data in grey instead of red
- Always show local node in green (0 hops)
- Update map legend to reflect new color scheme
- Rename map controls for clarity (Route Segments, Traceroute, Position History)

Traceroute Scheduler:
- Implement smart retry intervals: 3 hours for nodes without traceroute, 24 hours for nodes with successful traceroute
- Add random selection from eligible nodes to prevent repeatedly targeting same node
- Update tests to validate new time-based retry logic

Message Display:
- Preserve linebreaks in all messages using whiteSpace: pre-line
- Improves readability of multi-line messages (e.g., weather bot forecasts)

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

Co-Authored-By: Claude <noreply@anthropic.com>
@claude

claude Bot commented Oct 4, 2025

Copy link
Copy Markdown
Contributor

Claude finished @Yeraze's task —— View job


PR Code Review Analysis

This is a well-implemented PR with solid improvements to map visualization, traceroute scheduling, and message display. Here's my comprehensive review:

Todo List:

  • Read and analyze all changed files
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Review test coverage
  • Provide comprehensive feedback

✅ Strengths

Excellent Code Quality:

  • Clean, readable implementation with clear variable names and logic flow
  • Good separation of concerns between UI components and database logic
  • Comprehensive test coverage with 29 passing tests covering complex edge cases

Smart Traceroute Scheduling:

  • Well-designed retry intervals (3h for untraced, 24h for traced nodes) in database.ts:1117-1167
  • Random node selection prevents targeting same nodes repeatedly
  • Proper SQL query structure with appropriate indexing considerations

Thoughtful UI Improvements:

  • Grey color (#9ca3af) for no-traceroute nodes is more intuitive than red
  • Clear map legend updates in MapLegend.tsx:6,10
  • Better control labeling (e.g., "Show Route Segments" vs "Show Paths")

🔍 Areas for Consideration

Performance & Database:

  • The getNodeNeedingTraceroute query (database.ts:1126-1149) executes multiple subqueries. Consider adding composite indexes on (fromNodeNum, toNodeNum) for the traceroutes table to optimize performance
  • Query complexity grows with node count - monitor performance with larger datasets

Code Robustness:

  • In mapIcons.ts:14, the special case for hops === 999 could be made more explicit with a named constant:
    const NO_TRACEROUTE_HOPS = 999;
    if (hops === NO_TRACEROUTE_HOPS) return '#9ca3af';

Message Display:

  • The whiteSpace: 'pre-line' implementation in App.tsx:2186,2492 is correct and preserves formatting well

🧪 Test Coverage Assessment

Excellent Coverage:

  • Comprehensive tests for traceroute scheduling logic covering both 3h and 24h retry scenarios
  • Edge cases well tested (excluding local node, handling missing data)
  • Test setup properly uses in-memory database for isolation

Minor Suggestions:

  • Consider adding tests for the new map color logic in mapIcons.ts
  • Test the random selection behavior to ensure proper distribution

🛡️ Security Review

No Security Concerns Identified:

  • No user input sanitization issues
  • No SQL injection vulnerabilities (proper use of prepared statements)
  • No sensitive data exposure in client-side code

🚀 Performance Considerations

Generally Good:

  • Database queries use appropriate indexes
  • Random selection is efficient
  • No obvious memory leaks or performance bottlenecks

Optimization Opportunities:

  • Consider caching traceroute eligibility results if this query runs frequently
  • The Math.random() selection could use a more deterministic approach for testing

📝 Minor Code Quality Notes

  1. Consistency: The PR maintains existing code style and patterns well
  2. Error Handling: Proper error handling in database operations
  3. Type Safety: Good TypeScript usage throughout

🎯 Overall Assessment

This is a high-quality PR that demonstrates:

  • Thoughtful problem-solving (smart retry intervals)
  • Good UX design (intuitive color coding)
  • Comprehensive testing
  • Clean implementation

The changes are well-tested, properly implemented, and provide clear value to users. The traceroute scheduling improvements are particularly well-designed and should significantly improve network discovery efficiency.

Recommendation: ✅ Approve - This PR is ready for merge with excellent code quality and comprehensive testing.

@Yeraze Yeraze merged commit 55b7793 into main Oct 4, 2025
12 checks passed
@Yeraze Yeraze deleted the feat/map-viz-traceroute-improvements branch October 4, 2025 03:17
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.

1 participant