logs.gokuls.in

1 pull request merged across 1 repo

bahdotsh/feedr

Summary

  • The "What's New since last visit" summary was sorting feeds by new-item count only, which is not a total order. Two feeds tied on count came out in whatever order Rust's HashMap happened to iterate that frame; since the summary re-renders on every tick, tied feeds visibly shuffled several times per second.
  • Fix is one line in get_summary_stats: chain a name tie-breaker after the count comparison (b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0))) — count descending, then name ascending. Preserves the existing UX (highest count first) and gives ties a stable, intuitive order.
  • The reporter's suggested snippet (sort_by_key(|(name, count)| (count, name))) would have inverted the dominant ordering — the then_with form keeps it descending and survives the existing sorting test.

Clippy cleanup

  • The repo had 16 pre-existing clippy::collapsible_match warnings in src/events.rs and src/config_tui.rs blocking -D warnings. Most are technically safe to collapse, but the demo-feed shortcuts (KeyCode::Char('1'/'2'/'3')) cannot be — CLAUDE.md notes those number keys are intentionally hardcoded as no-ops, and collapsing would let user-configured bindings on those keys fire when feeds are present.
  • Clippy itself classifies the suggestions as MaybeIncorrect (so cargo clippy --fix skips them). Added function-scoped #[allow(clippy::collapsible_match)] on handle_key_event, handle_mouse_event, and run_editor, with a comment explaining the rationale on the most-affected handler.

Test plan

  • cargo fmt --all -- --check — clean
  • cargo clippy --all-targets --all-features -- -D warnings — clean
  • cargo test — 81 unit + 4 integration tests pass, including the new test_get_summary_stats_tie_break_by_name which calls get_summary_stats twice and asserts the output is identical (regression guard against HashMap-induced flicker)
  • Manual verification: open the "What's New" screen with two or more feeds tied on new-item count and confirm the order no longer shifts between frames