Skip to content

fix(discover): pick a stable example command per bucket - #4330

Open
amandeavor wants to merge 1 commit into
rtk-ai:developfrom
amandeavor:fix/discover-stable-example
Open

amandeavor wants to merge 1 commit into
rtk-ai:developfrom
amandeavor:fix/discover-stable-example

Conversation

@amandeavor

Copy link
Copy Markdown
Contributor

Summary

  • Choose each bucket's display command by frequency, with a lexicographic tie-break so equal counts do not flip between runs.
  • Sort discovered session paths before scanning so first-seen paths are filesystem-order independent.
  • Apply the same stable pick to unsupported examples.

Fixes #4313

Test plan

  • cargo test --bin rtk most_frequent / discover:: (Rust 1.91)
  • cargo fmt --all && cargo clippy --all-targets && cargo test

When two spellings share the top count, HashMap::max_by_key left the
example to iteration order, so the same history flipped labels between
runs. Pick the most frequent spelling and break ties lexicographically,
sort session paths before scanning, and apply the same rule to
unsupported examples.

Fixes rtk-ai#4313
Copilot AI lite review requested due to automatic review settings September 28, 2026 03:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes non-deterministic 'rtk discover' reports by picking each bucket's example command based on frequency with a lexicographic tie-break instead of relying on HashMap/filesystem iteration order. Also sorts discovered session paths before scanning so first-seen paths are order-independent, and applies the same stable pick logic to unsupported command examples.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4313


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

discover: the example command shown for a bucket changes between runs on the same history

2 participants