From 50b91f14b61cb007c3b39c3c3c372c317de20186 Mon Sep 17 00:00:00 2001 From: bbedward Date: Sun, 22 Feb 2026 22:34:26 -0500 Subject: [PATCH] launcher: fix frecency ranking in search results fixes #1799 --- quickshell/Modals/DankLauncherV2/Controller.qml | 13 ++++--------- quickshell/Modals/DankLauncherV2/Scorer.js | 6 +++--- quickshell/Services/AppSearchService.qml | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/quickshell/Modals/DankLauncherV2/Controller.qml b/quickshell/Modals/DankLauncherV2/Controller.qml index 3b0882cf..c730fb93 100644 --- a/quickshell/Modals/DankLauncherV2/Controller.qml +++ b/quickshell/Modals/DankLauncherV2/Controller.qml @@ -676,8 +676,6 @@ Item { var apps = searchApps(searchQuery); for (var i = 0; i < apps.length; i++) { - if (searchQuery) - apps[i]._preScored = 11000 - i; allItems.push(apps[i]); } @@ -685,14 +683,11 @@ Item { if (searchQuery && searchQuery.length >= 2) { _pluginPhasePending = true; _phase1Items = allItems.slice(); + _pluginPhaseForceFirst = shouldResetSelection; pluginPhaseTimer.restart(); - if (allItems.length === 0) { - _pluginPhaseForceFirst = shouldResetSelection; - isSearching = true; - searchCompleted(); - return; - } - _pluginPhaseForceFirst = false; + isSearching = true; + searchCompleted(); + return; } else if (!searchQuery) { var emptyTriggerOrdered = getEmptyTriggerPluginsOrdered(); for (var i = 0; i < emptyTriggerOrdered.length; i++) { diff --git a/quickshell/Modals/DankLauncherV2/Scorer.js b/quickshell/Modals/DankLauncherV2/Scorer.js index affc1ad7..17d5783b 100644 --- a/quickshell/Modals/DankLauncherV2/Scorer.js +++ b/quickshell/Modals/DankLauncherV2/Scorer.js @@ -3,7 +3,7 @@ const Weights = { exactMatch: 10000, prefixMatch: 5000, - wordBoundary: 1000, + wordBoundary: 3000, substring: 500, fuzzy: 100, frecency: 2000, @@ -99,8 +99,8 @@ function getTimeBucketWeight(daysSinceUsed) { function calculateTextScore(name, query) { if (name === query) return Weights.exactMatch if (name.startsWith(query)) return Weights.prefixMatch - if (name.includes(query)) return Weights.substring if (hasWordBoundaryMatch(name, query)) return Weights.wordBoundary + if (name.includes(query)) return Weights.substring if (query.length >= 3) { var fs = fuzzyScore(name, query) @@ -140,7 +140,7 @@ function score(item, query, frecencyData) { if (textScore === 0) return 0 - var usageBonus = frecencyData ? Math.min(frecencyData.usageCount * 10, Weights.frecency) : 0 + var usageBonus = frecencyData ? Math.min(frecencyData.usageCount * 50, Weights.frecency) : 0 return textScore + usageBonus + typeBonus } diff --git a/quickshell/Services/AppSearchService.qml b/quickshell/Services/AppSearchService.qml index 2329f8c1..c6b4913a 100644 --- a/quickshell/Services/AppSearchService.qml +++ b/quickshell/Services/AppSearchService.qml @@ -494,7 +494,7 @@ Singleton { textScore = 5000; matchType = "prefix"; } else if (wordBoundaryMatch(name, queryLower)) { - textScore = 1000; + textScore = 3000; matchType = "word_boundary"; } else if (name.includes(queryLower)) { textScore = 500; @@ -551,7 +551,7 @@ Singleton { } for (const result of results) { - const frecencyBonus = result.frecency > 0 ? Math.min(result.frecency / 10, 2000) : 0; + const frecencyBonus = result.frecency > 0 ? Math.min(result.frecency, 2000) : 0; const recencyBonus = result.daysSinceUsed < 1 ? 1500 : result.daysSinceUsed < 7 ? 1000 : result.daysSinceUsed < 30 ? 500 : 0; const finalScore = result.textScore + frecencyBonus + recencyBonus;