feat: add flapping service detection and visual styling - #176
Conversation
- Add is_flapping field to ServiceEntry for tracking unstable services - Implement flapping detection based on session history (3+ short sessions) - Add color-blind friendly visual styling in list view (darker background + underline) - Add flapping status to details view with combined status line (Online/Offline, Flapping) - Include is_flapping in JSON state export for debugging/analysis - Add comprehensive tests for flapping detection and styling
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis PR introduces flapping detection for services—a feature that identifies when a service is rapidly cycling between online and offline states. The change adds flapping status tracking to service entries, implements detection logic based on session history, and updates rendering to visually highlight flapping services with distinct colors and underline styling. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Poem
Look, I gotta be straight with you here: this is a solid feature addition. The flapping detection logic is doing real work—analyzing session history to identify problematic services that keep cycling. The integration into the service lifecycle is thorough, hitting all the right state transitions. Tests are there. The rendering changes are clean and purpose-built. The only thing I'd double-check in review is whether the flapping detection threshold (what counts as "multiple short completed sessions") is actually tuned right for real-world mDNS behavior. You don't want false positives on services that legitimately restart. But the implementation itself? It's solid. No fires here. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/tui_app.rs`:
- Around line 247-275: The flapping math in is_flapping_service misclassifies
because integer division and low completed session counts let 1-of-3 or 0-of-1
pass; update the logic to (1) require a minimum number of completed sessions
(e.g., add const MIN_COMPLETED_SESSIONS = 3 and check completed_sessions >=
MIN_COMPLETED_SESSIONS) and (2) compute the "half" correctly using either
short_sessions * 2 >= completed_sessions or short_sessions >=
(completed_sessions + 1) / 2 so you don't undercount due to truncation; keep
counting only sessions with end_time present as you already do and return
flapping only when both the min completed threshold and the corrected half
condition are met in is_flapping_service.
- Require minimum 3 completed sessions before checking flapping - Use multiplication instead of division to correctly compute half - Update test to match new requirements
Summary
Summary by CodeRabbit