omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Menu extension override blanks stock fields it doesn't set (icon, label, aliases, provider)

Open Lifferado opened this issue 3 weeks ago • 2 comments

System details

  • Omarchy 4.0.0.r7677.ge56f833-1
  • Lenovo ThinkPad E14 Gen 7, Intel Core Ultra 5 225U, Intel iGPU

What happens

The template ~/.config/omarchy/extensions/omarchy-menu.jsonc (from config/omarchy/extensions/omarchy-menu.jsonc) says:

Example: replace the default About action by reusing the same id. Existing fields are kept unless overridden.

They aren't kept. An override that sets only action leaves the row with an empty icon, no aliases, no provider, and the raw id as its label.

Steps to reproduce

  1. Add to ~/.config/omarchy/extensions/omarchy-menu.jsonc:
    "apps": {"action":"omarchy-launch-about"}
    
  2. Open the Omarchy menu.
  3. The Apps row has no icon, while Learn, Appearance, Trigger, etc. still do. Searching for applications no longer finds the row.

Expected

Fields the override doesn't mention (icon, label, aliases, provider, ...) keep their stock values, as the template comment says.

Cause

shell/plugins/menu/MenuModel.js: normalizeItem() gives every field a default (icon: value.icon || "", label: value.label || id, aliases: [], provider: "", ...). mergeMenuSources() then copies every key of the user's entry over the stock one (for (var k2 in entry) merged[k2] = entry[k2]), so these defaults overwrite the stock values.

You can reproduce it without the shell (run with node from any directory):

const fs = require('fs'), vm = require('vm');
const src = fs.readFileSync('/usr/share/omarchy/shell/plugins/menu/MenuModel.js', 'utf8')
  .replace(/^\.pragma.*$/m, '').replace(/^\.import.*$/mg, '');
const ctx = {}; vm.createContext(ctx); vm.runInContext(src, ctx);
const def = ctx.parseMenuJsonc('{"apps":{"icon":"X","label":"Apps","aliases":["app"],"provider":"apps","action":"a"}}');
const usr = ctx.parseMenuJsonc('{"apps":{"action":"b"}}');
const r = ctx.mergeMenuSources(def, usr).items.apps;
console.log(JSON.stringify({icon: r.icon, label: r.label, aliases: r.aliases, provider: r.provider, action: r.action}));
// {"icon":"","label":"apps","aliases":[],"provider":"","action":"b"}

The same code is on master.

Possible fix

Let a user entry override only the keys it actually sets: have normalizeItem record which raw keys were present, and have mergeMenuSources copy only those (id/parent/kind would still need recomputing). kind needs care: today an action-only override of a submenu correctly turns it into an action.

If replacing the whole row is the intended behaviour, the template comment should say so instead: "repeat every field you want to keep".

Workaround

Repeat the stock fields in the override:

"apps": {"icon":"󰀻","label":"Apps","aliases":["app","applications"],"action":"..."}

Lifferado avatar Nov 10 '26 20:11 Lifferado

I read the menu normalization and merge code and the extension template on quattro at d54cde78f; no reproduction or tests ran. My review (GPT-6 High in Codex) treats this as a bug report, but the configured classification model, deepseek-v4p1-flash, returned no classification. Classification remains unsettled, and this is waiting for maintainer review before verification or a fix proceeds.

omarchybot avatar Nov 19 '26 02:11 omarchybot

This duplicates the earlier open report #11211. Both describe a partial menu override losing the stock fields it omits: normalizeItem() fills those fields with defaults before mergeMenuSources() copies every field over the stock row. Changing only action here and only icon in #11211 expose the same cause and need the same correction.

I compared both reports and read the parser, merge code and extension template on quattro at 3ae299b2cf; no reproduction or tests ran. Checked by GPT-6 in Codex (effort not exposed), with Opus 5.5 High separately comparing the reports and agreeing they duplicate one another; reviewer independence is not guaranteed.

Closing this report to keep tracking in #11211. If this case differs in a way the earlier report does not cover, it can be reopened with a note on the difference.

omarchybot avatar Nov 23 '26 10:11 omarchybot