Skip to content

feat: add --no-debounce CLI option to disable flapping service debouncing - #173

Merged
hrzlgnm merged 2 commits into
mainfrom
feat/no-debounce-cli-option
Feb 11, 2026
Merged

hrzlgnm merged 2 commits into
mainfrom
feat/no-debounce-cli-option

Conversation

@hrzlgnm

@hrzlgnm hrzlgnm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add new --no-debounce CLI flag to disable automatic debouncing of flapping services
  • When enabled, services are marked offline immediately upon ServiceRemoved events
  • Useful for debugging flapping service scenarios where services rapidly go online/offline

Changes

  • CLI: Added --no-debounce boolean flag with help text
  • Core Logic: Modified ServiceRemoved event handler to check the flag
  • State Management: Added no_debounce field to AppState struct
  • Cleanup: Made cleanup timer conditional on debouncing being enabled
  • Testing: Added 5 comprehensive tests covering all new functionality
  • Documentation: Updated README.md and manpage with new option and examples

Testing

  • All existing tests continue to pass (197/197)
  • New functionality covered by 4 dedicated tests
  • Manual testing confirms CLI option works correctly
  • Code formatting and linting pass all checks

Backward Compatibility

  • Fully backward compatible - default behavior unchanged
  • Existing CLI behavior preserved when flag is not used
  • No breaking changes to existing APIs

Summary by CodeRabbit

  • New Features

    • Added a --no-debounce CLI option to disable automatic debouncing so service disappearances are shown immediately.
  • Documentation

    • README updated with examples for --no-debounce.
    • Man page updated to document the new option and examples.
  • Tests

    • Added and updated tests to cover no-debounce initialization, cloning, and runtime behavior.

…cing

Add new --no-debounce command line flag that disables the automatic debouncing
of flapping services for debugging purposes. When enabled, services are marked
offline immediately upon ServiceRemoved events instead of waiting 1 second for
potential recovery.

Changes:
- Add no_debounce field to AppState struct
- Modify ServiceRemoved event handler to check flag
- Update cleanup logic to skip expired removals when disabled
- Add comprehensive tests for new functionality
- Update README.md and manpage with new option
- Update all test calls to include new parameter
@github-actions github-actions Bot added the enhancement New feature or request label Feb 11, 2026
@hrzlgnm

hrzlgnm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A new --no-debounce CLI flag is introduced and threaded from main.rs into run_tui and AppState in tui_app.rs. When enabled, the flag bypasses scheduled debounce removals and skips debounce-driven cleanup/metrics processing. README and the man page are updated to document the flag.

Changes

Cohort / File(s) Summary
Documentation
README.md, mdns-tui-browser.1
Added examples and OPTIONS documentation for the new --no-debounce flag; man page release date incremented.
CLI surface
src/main.rs
Added no_debounce: bool to Cli with --no-debounce help; threaded cli.no_debounce into run_tui.
TUI / debounce logic
src/tui_app.rs
Added no_debounce: bool to AppState (constructor and Clone). run_tui signature updated. ServiceRemoved handling now immediately marks services offline when no_debounce is true and skips scheduling removals; global cleanup task skips pending-removal processing and metrics when flag set. Tests updated/added to cover flag propagation and behavior.

Sequence Diagram(s)

sequenceDiagram
  participant User as rgba(60,90,180,0.5) User/CLI
  participant RunTui as rgba(20,160,100,0.5) run_tui
  participant App as rgba(200,80,120,0.5) AppState
  participant Cleanup as rgba(180,130,40,0.5) CleanupTask
  participant Registry as rgba(90,90,90,0.5) ServiceRegistry

  User->>RunTui: starts with --no-debounce flag
  RunTui->>App: AppState::new(user_types, no_debounce)
  App->>Registry: receive ServiceRemoved event
  alt no_debounce == true
    App->>Registry: mark service offline immediately
  else no_debounce == false
    App->>App: schedule_service_removal (pending_removals)
  end
  Cleanup->>App: periodic cleanup tick
  alt no_debounce == false
    Cleanup->>App: process_expired_removals -> update metrics
  else no_debounce == true
    Cleanup->>App: skip debounce processing
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

A tiny flag cuts the wait and hum,
Debounce be gone — the updates come.
Services fall or stand in line,
You chose the fate with one small sign. 🎛️✨

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature: adding a --no-debounce CLI option to control flapping service debouncing, which is the central change across all files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/no-debounce-cli-option

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tui_app.rs (1)

2791-2806: ⚠️ Potential issue | 🟡 Minor

Add a doc comment to run_tui. Oh boy someone is gonna get fired today.
This is a public entry point and the signature changed, so it needs a concise /// doc.

📝 Proposed fix
+/// Run the TUI event loop.
+///
+/// `user_service_types` are normalized and pre-seeded; set `no_debounce` to mark
+/// services offline immediately.
 pub async fn run_tui(
     user_service_types: HashSet<String>,
     no_debounce: bool,
 ) -> Result<(), Box<dyn std::error::Error>> {
As per coding guidelines: “Add doc comments to public functions with `///` syntax; include examples in doc comments when helpful; keep documentation concise and focused.”
🤖 Fix all issues with AI agents
In `@src/tui_app.rs`:
- Around line 1869-1875: When handling ServiceEvent::ServiceRemoved, if
state.no_debounce is true you call state.mark_service_offline(&fullname) but
never notify the UI—after mark_service_offline(&fullname) emit a
Notification::ServiceChanged (or call whatever notifier is used in this module)
so the UI repaints; leave the existing schedule_service_removal(&fullname) path
unchanged for the debounced case and ensure the Notification::ServiceChanged is
sent immediately only in the no_debounce branch.

Comment thread src/tui_app.rs
When no_debounce is enabled, mark_service_offline() was called but
no notification was sent to trigger UI repaint. This resulted in services
appearing to remain online in the UI until the next async event occurred.

Fix ensures Notification::ServiceChanged is sent immediately when a service is
successfully marked offline in the no_debounce code path.
@hrzlgnm

hrzlgnm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Fixed a critical issue where the UI wasn't updating when services were marked offline immediately with --no-debounce flag. Now the UI will repaint properly when services are removed in real-time.

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

@hrzlgnm Ah, so you found the classic "I changed the data but forgot to tell the UI about it" bug. Yeah, that's what happens when you bypass a code path that was doing more than you thought it was doing. The debouncing logic was probably also handling the repaint, and when you short-circuited it, the UI just sat there like an idiot staring at stale data.

Good catch fixing the repaint. That's the kind of thing that would've driven users crazy - "Hey, I turned off debouncing and now nothing updates!"

Let me review the new changes to see how you fixed it.


🧠 Learnings used
Learnt from: CR
Repo: hrzlgnm/mdns-tui-browser PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-11T18:29:51.296Z
Learning: Use conventional commit format for commit messages (e.g., `feat:`, `fix:`, `docs:`); after creating or updating a pull request, trigger reviews with comment `coderabbitai review`
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tui_app.rs (1)

2793-2808: ⚠️ Potential issue | 🟡 Minor

Add a doc comment for the new public run_tui signature.
Public API changed; document what no_debounce does. Oh boy someone is gonna get fired today.

✍️ Suggested doc comment
+/// Run the TUI event loop.
+///
+/// `no_debounce` disables flapping-service debouncing and marks removals offline immediately.
 pub async fn run_tui(
     user_service_types: HashSet<String>,
     no_debounce: bool,
 ) -> Result<(), Box<dyn std::error::Error>> {

As per coding guidelines, Add doc comments to public functions with /// syntax; include examples in doc comments when helpful; keep documentation concise and focused.

@hrzlgnm
hrzlgnm merged commit 716f932 into main Feb 11, 2026
23 checks passed
@hrzlgnm
hrzlgnm deleted the feat/no-debounce-cli-option branch February 11, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant