Menu search: installed app loses short-prefix ranking to same-labeled menu actions (e.g. "chr" for Google Chrome)
What happened
In the Omarchy menu (Super+Space), typing a short prefix of an installed app's second word — e.g. chr or chro for "Google Chrome" — ranks several unrelated menu actions above the actual installed app. Only typing the full word chrome correctly puts the app first.
Repro on this machine (Google Chrome installed via google-chrome package):
Query: "chr" or "chro"
1. Setup › Defaults › Browser › Chrome (action)
2. Install › Service › Chromium Account (action, unrelated)
3. Remove › Browser › Chrome (action)
4. Apps › Google Chrome (the actual app)
Query: "chrome"
1. Apps › Google Chrome (correct)
2. Setup › Defaults › Browser › Chrome
3. Remove › Browser › Chrome
Expected
The installed app should rank at or near the top for any reasonable prefix of its name, not just the full word.
Root cause
In shell/plugins/menu/MenuModel.js, searchScore():
if (label === needle) score = entry.parent === "root" ? 2 : 0
else if (entry.kind === "app" && label.split(/\s+/).indexOf(needle) >= 0) score = 0
else if (label.indexOf(needle) === 0) score = 10
else if (label.indexOf(needle) >= 0) score = 30
...
if (entry.kind === "app") score -= 5
The app-outranking discount (score -= 5 for kind === "app") only fires once a tier is already assigned. For a prefix query shorter than the full app name, a menu item whose label is literally the single word "Chrome" hits the label.indexOf(needle) === 0 ("starts with") tier (10), while an app labeled "Google Chrome" only hits the label.indexOf(needle) >= 0 ("contains") tier (30 - 5 = 25). 25 > 10, so the app loses, even though it's very clearly what the user is searching for.
The existing "app row" comment even acknowledges the intent to fix exactly this kind of tie:
// App rows sort after all menu items, so they lose the tiebreak below to an // equal match. Outrank those, but stay inside the tier so better ones win.
but the fix only covers the exact whole-word case, not the prefix case, which is the far more common way people actually type into a launcher.
This isn't specific to Chrome — any app whose display name has a distinguishing word later in the label (not the first word) will lose short-prefix searches to any menu action/link/menu item that happens to start with that same prefix.
Reproduction script
Since the scoring module is plain CommonJS-exportable, I built a small harness that loads the real MenuModel.js, the real merged JSONC config (default + user), the real installed .desktop files (respecting NoDisplay and hidden-entries.sh), and evaluates real when/checked guards via an actual shell run — then replicates rebuildDisplay()'s search path exactly. Output above is real output from this machine's actual config/app set.
repro.js (run from a copy of shell/plugins/menu/MenuModel.js)
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const os = require('os');
const M = require('./MenuModel.js');
const OMARCHY_PATH = process.env.OMARCHY_PATH || '/usr/share/omarchy';
const HOME = os.homedir();
function readIfExists(p) {
try { return fs.readFileSync(p, 'utf8'); } catch (e) { return ''; }
}
const defaultRaw = readIfExists(path.join(OMARCHY_PATH, 'default/omarchy/omarchy-menu.jsonc'));
const userRaw = readIfExists(path.join(HOME, '.config/omarchy/extensions/omarchy-menu.jsonc'));
const defaultItems = M.parseMenuJsonc(defaultRaw);
const userItems = M.parseMenuJsonc(userRaw);
let merged = M.mergeMenuSources(defaultItems, userItems);
let items = merged.items;
let itemOrder = merged.itemOrder;
const guardScript = M.guardScript(items);
let guardOut = '';
if (guardScript) {
guardOut = execSync('bash', { input: guardScript, encoding: 'utf8', shell: false });
}
const whenResults = {};
const checkedResults = {};
for (const line of guardOut.split('\n')) {
const m = line.match(/^(.*):(w|c):(0|1)$/);
if (!m) continue;
const [, id, tag, val] = m;
(tag === 'w' ? whenResults : checkedResults)[id] = val === '1';
}
function parseDesktopFile(file) {
const raw = readIfExists(file);
if (!raw) return null;
const lines = raw.split('\n');
let inMainSection = false;
const entry = { name: '', genericName: '', comment: '', keywords: [], noDisplay: false, icon: '', id: path.basename(file, '.desktop') };
for (const line of lines) {
if (/^\[/.test(line)) { inMainSection = line.trim() === '[Desktop Entry]'; continue; }
if (!inMainSection) continue;
const m = line.match(/^([A-Za-z0-9]+)(\[[^\]]+\])?=(.*)$/);
if (!m) continue;
const [, key, locale, value] = m;
if (locale) continue;
if (key === 'Name') entry.name = value;
else if (key === 'GenericName') entry.genericName = value;
else if (key === 'Comment') entry.comment = value;
else if (key === 'Icon') entry.icon = value;
else if (key === 'NoDisplay') entry.noDisplay = value.trim().toLowerCase() === 'true';
else if (key === 'Keywords') entry.keywords = value.split(';').filter(Boolean);
else if (key === 'Type' && value.trim() !== 'Application') entry._notApp = true;
}
if (entry._notApp) return null;
return entry;
}
function listDesktopFiles(dir) {
try { return fs.readdirSync(dir).filter(f => f.endsWith('.desktop')).map(f => path.join(dir, f)); }
catch (e) { return []; }
}
const desktopDirs = ['/usr/share/applications', path.join(HOME, '.local/share/applications')];
const seenIds = new Set();
const rawEntries = [];
for (const dir of desktopDirs) {
for (const f of listDesktopFiles(dir)) {
const e = parseDesktopFile(f);
if (!e || !e.name) continue;
if (seenIds.has(e.id)) continue;
seenIds.add(e.id);
rawEntries.push(e);
}
}
let hiddenIds = new Set();
try {
const desktopEnv = [process.env.XDG_CURRENT_DESKTOP, process.env.XDG_SESSION_DESKTOP, process.env.DESKTOP_SESSION].filter(Boolean).join(':');
const out = execSync(`bash ${JSON.stringify(path.join(OMARCHY_PATH, 'shell/services/hidden-entries.sh'))} ${JSON.stringify(desktopEnv)}`, { encoding: 'utf8' });
for (const line of out.split('\n')) {
const id = line.trim().replace(/\.desktop$/, '');
if (id) hiddenIds.add(id);
}
} catch (e) { }
const launcherHidesRaw = readIfExists(path.join(OMARCHY_PATH, 'default/omarchy/launcher.hides'));
for (const line of launcherHidesRaw.split('\n')) {
const id = line.trim().replace(/\.desktop$/, '');
if (id) hiddenIds.add(id);
}
function entryName(e) { return e.name || e.id || ''; }
function entrySubtext(e) { return e.genericName || ''; }
function entrySortKey(e) { return entryName(e).toLowerCase(); }
const visibleApps = rawEntries.filter(e => !e.noDisplay && !hiddenIds.has(e.id) && entryName(e));
visibleApps.sort((a, b) => {
const ka = entrySortKey(a), kb = entrySortKey(b);
if (ka < kb) return -1;
if (ka > kb) return 1;
return 0;
});
const appRows = visibleApps.map(entry => {
const subtext = entrySubtext(entry);
let aliases = subtext ? [subtext] : [];
if (Array.isArray(entry.keywords)) aliases = aliases.concat(entry.keywords);
return {
id: 'apps.' + entry.id, parent: 'apps', kind: 'app', icon: '',
appIcon: entry.icon || '', appId: entry.id, label: entryName(entry),
title: '', target: '', description: subtext, action: '', provider: '',
aliases, when: '', checked: '', order: 0,
};
});
const mergedApps = M.mergeAppRows(items, itemOrder, appRows);
items = mergedApps.items;
itemOrder = mergedApps.itemOrder;
function isVisible(entry) { return M.isVisible(items, itemOrder, whenResults, entry, 0); }
function matchesQuery(entry, query) { return M.matchesQuery(entry, query, isVisible(entry)); }
function searchScore(entry, query) { return M.searchScore(items, entry, query); }
function search(query, active) {
active = active || 'root';
const currentRows = [];
const drilldownRows = [];
for (const id of itemOrder) {
const entry = items[id];
if (!entry || entry.id === 'root') continue;
if (!M.isDescendantOf(items, entry.id, active)) continue;
if (!matchesQuery(entry, query)) continue;
const detail = M.parentPathFor(items, entry.id);
const row = M.displayRow(items, itemOrder, checkedResults, entry, detail, searchScore(entry, query));
if (entry.parent === active) currentRows.push(row);
else drilldownRows.push(row);
}
const sortFn = (a, b) => (a.score !== b.score ? a.score - b.score : a.path.localeCompare(b.path));
currentRows.sort(sortFn);
drilldownRows.sort(sortFn);
return currentRows.concat(drilldownRows);
}
for (const q of process.argv.slice(2)) {
console.log('=== query: "' + q + '" ===');
search(q).slice(0, 10).forEach((r, i) => {
console.log(`${i + 1}. score=${r.score} kind=${r.kind} label=${JSON.stringify(r.label)} path=${r.path}`);
});
}
Run with: node repro.js chr chro chrome from a directory containing a copy of the real MenuModel.js.
System info
- Omarchy: 4.0.3-1
- Kernel: 7.2.3-arch1-3
- Hyprland: 0.56.2
- Distro: Omarchy (Arch Linux)
Possible fix direction
Extend the app-outranking discount to prefix matches too, e.g. give kind === "app" a bigger discount, or add a dedicated tier for "app label's own word starts with the query" that sits below (better than) the generic "starts with" tier for non-app menu items. Happy to try a PR if a maintainer confirms the intended tier ordering.
Followed up on this and the fix I had in mind does not hold up, so here are the numbers in case they save someone else the detour.
The obvious patch is a scoring tier in searchScore() for "query starts one of an app's own label words". It does fix this report: chr then puts Google Chrome above the three Chrome rows. Sweeping it over the shipped menu with 60 installed apps shows what it costs:
| query | new top result | demoted |
|---|---|---|
vi |
Document Viewer, Image Viewer | Setup › Defaults › Editor › Vim |
ba |
LibreOffice Base | Learn › Bash |
ze |
Avahi Zeroconf Browser | Setup › Defaults › Browser › Zen |
dr |
LibreOffice Draw | Install › Service › Dropbox |
That is not a tuning problem. searchScore() sees one entry at a time, and the two cases are the same shape:
chr: app "Google Chrome", query prefixes the second word, against an action labelled "Chrome", query starts the whole label.vi: app "Document Viewer", query prefixes the second word, against an action labelled "Vim", query starts the whole label.
Any tier value that lifts Chrome over its action row lifts Document Viewer over Vim by exactly the same amount. Query length and match coverage do not separate them either: bas covers 75% of "Base" while chr covers 50% of "Chrome", so any threshold that admits Chrome admits Base over Bash.
What actually separates the two is not text. The Chrome rows manage the app that matched; the Vim row does not. That is cross-row information, so it belongs where the whole result set is visible (rebuildDisplay()) rather than in a per-entry tier. Collapsing or demoting a management row when the app it manages is itself a hit would fix this report without touching unrelated queries.
Leaving the design call to you. Closing my PR, since what is in it is the wrong shape.
#11730 lands the narrow half: an app now outranks the actions that manage it, so chr puts Google Chrome above its three Chrome rows. It does not put Chrome first. Setup › Defaults › Browser › Chromium still leads on a machine without Chromium, because a label that starts with the query beats one that contains it regardless of kind, and "Chromium" starts with chr exactly as "Chrome" does. On a stock install the Chromium app itself takes first, which is a fair answer to an ambiguous prefix.
Getting an installed app to first on a short prefix needs a rule that installed apps beat prefix-matching actions in general. That is a scoring policy call, so it stays out of #11730 and sits here for you. The cost, measured over the shipped menu with 60 installed apps in the comment above, is four queries where an app moves over an action people type those letters for: vi (Document Viewer over Vim), ba (LibreOffice Base over Bash), ze (Avahi Zeroconf Browser over Zen), dr (LibreOffice Draw over Dropbox). A softer variant that breaks ties inside the starts-with tier toward the shorter matched word ("chrome" over "chromium") still flips Draw over Dropbox. If either trade reads as acceptable, I will do the PR with the full sweep attached.
Separately: omarchy-remove-browser has no chromium branch, so a hand-removed Chromium leaves ~/.config/chromium-flags.conf behind and Install › Service › Chromium Account keeps showing on a machine with no Chromium. That can be its own issue if you want it tracked.
Checked against quattro at 9480d1b6. The mechanism is as described: for chr, searchScore() in shell/plugins/menu/MenuModel.js puts every action labelled Chrome or Chromium in the starts-with tier (10) and Google Chrome in the contains tier less the app bonus (25), and Menu.qml sorts ascending, so the actions lead. The whole-word app rule at line 351 explains why chrome works and chr does not. Nothing on quattro has changed this yet.
#11730 is the open fix, and it already names this issue, so it closes this one when it merges. It adds a pass over the result set that moves an action whose whole label is a word of a matching app to directly behind that app, which fixes the Chrome rows and leaves Vim ahead of Document Viewer on vi. It does not touch the Chromium rows, which start with chr and share no word with the app. It currently has merge conflicts with quattro. It is reviewed as its own item.
What is left after #11730 is the policy question you raised: whether an installed app should beat a prefix-matching action in general. Codex Medium, reviewing separately, agreed with the mechanism and found one point the earlier comments do not cover: a single per-row score can separate chr from vi if a word-prefix match is scored by how much of the word the query covers, which puts Google Chrome over Chrome and keeps Vim over Document Viewer. The same rule still puts LibreOffice Base over Bash on ba, though, so it changes the trade rather than removing it. Either way it is a ranking decision, so this waits on the maintainer.
Looks like the same ranking gap as #10340 / #7630 — short prefixes lose to same-labeled menu actions. #12223 (fix(menu): rank installed apps above menu entries in search) and #10457 (word-prefix matching) look like the right fixes.
If those don't cover the chr/chro case once merged, we can reopen with a minimal repro.
Rechecked against quattro at 256e05bd. Nothing there has changed searchScore(), so the bug is still present: for chr, Google Chrome scores in the contains tier less the app bonus (25) and the Chrome and Chromium actions in the starts-with tier (10).
My last comment named only #11730. Three open pull requests address this, and I traced each one's scoring for chr, chro, vi, ba and font against the shipped menu. I read the source and ran nothing:
- #11730 fixes only part of it. It moves an action whose whole label is a word of the app ("Chrome") behind the app.
Setup › Defaults › Browser › ChromiumandInstall › Service › Chromium Accountstill start withchrand still lead. It leavesvi,baandfontas they are. It names this issue and currently has merge conflicts withquattro. - #10457 adds a tier for an app whose later word starts with the query, equal to the starts-with tier, and the app bonus then breaks the tie. Google Chrome comes first for
chrandchro. It also puts Document Viewer over Vim onviand LibreOffice Base over Bash onba, which are the trades described above, and it keeps Style › Font over FontForge onfont. It names this issue. - #12223 ranks every matching installed app above every menu entry, in both
searchScore()andMenu.qml. Google Chrome comes first, and so do Document Viewer, LibreOffice Base and FontForge (over an exactFontmatch). It names #10340 but not this issue, and I did not add the link because it is a feature nobody has assigned to omabot.
#10457 and #12223 each fix this report, and each makes the policy call this issue left open, to a different extent. Which one lands is the maintainer's decision. The pull requests are reviewed as their own items. Codex Medium, reviewing separately from the diffs, reached the same score for every query above. It also pointed out that #12223's divider test checks a hand-built array rather than the real Menu.qml partition. This waits on the maintainer.
Still reproducing this on Omarchy 4.0.4-1. Super+Space, query chr, Google Chrome installed:
- Chrome ✓ — Setup › Defaults › Browser
- Chromium Account — Install › Service
- Chrome — Remove › Browser
- Google Chrome — Apps
- Tether — Apps
Enter on the first row does not launch Chrome. The app is the fourth row.
Please rank the installed app first. The Defaults, Install, and Remove rows can stay in the list, after the app, so the top hit is the thing you came to open.
#12223 does that: any matching app sorts above menu entries. That is the behavior I want for this search. The narrower #11730 still leaves the Chromium actions above Google Chrome for chr, which is the same problem.