Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

useFrecencySorting ignores how long ago an item was visited when sorting

Open Beginner friendly
#84 0 comments 0 reactions 0 assignees View on GitHub

@auraseb is already working on this.

Since Oct 19, 2026.

  • #85 by @auraseb — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start with the comparator and getNewFrecency in src/useFrecencySorting.ts; compare how the stored score is updated on visits with how items are ranked. Check the minimal repro by comparing an item last visited 60 days ago with one visited twice today. Done when sorting accounts for elapsed time and the fresh item ranks first in that case.

Written by the indexing model from the issue text.

Description

What happens

useFrecencySorting stores, for each item, a score and the time of the last visit. When the list is sorted, the stored scores are compared directly:

if (frecencyA && frecencyB) {
  return frecencyB.frecency - frecencyA.frecency;
}

The stored score is only decayed when the same item is visited again (in getNewFrecency). At sort time, a score from a year ago and a score from today are treated as if they were taken at the same moment. As a result:

  1. Two items visited once each always tie at 100, no matter whether the visit was today or a year ago, so the list falls back to the original order.
  2. An item visited 4 times two months ago (stored score 400) stays above an item visited twice today (stored score 200) forever. With the 10 day half life the old score is worth about 6 today.

Once an item has accumulated a high score it can never be overtaken by recent usage of other items unless it is reset.

What should happen

The docs say "The more often an item is visited, and the more recently an item is visited, the higher it will rank." Recent visits should outrank old ones of the same or similar weight, as in the Firefox algorithm the hook is based on.

Minimal repro

// visit "stale" 4 times, then wait 60 days, then visit "fresh" twice
const { data, visitItem } = useFrecencySorting([{ id: "stale" }, { id: "fresh" }]);
// data is [stale, fresh]; expected [fresh, stale]

Root cause

The comparator in src/useFrecencySorting.ts uses frecency without applying the decay for the time elapsed since lastVisited. Decaying both scores to the same now before comparing fixes it. getNewFrecency already has the decay formula, so it can be shared.

Dominant language
TypeScript
Stars
85
Forks
18
Avg merge
12m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raycast/utils

All issues in raycast/utils

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.