Skip to content

fix(cli): wire --tray Unix path through the runtime systray2 loader (#4605) - #5276

Merged
diegosouzapw merged 1 commit into
release/v3.8.40from
fix/4605-tray-runtime-loader
Jun 29, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.40from
fix/4605-tray-runtime-loader

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

Closes #4605

Problem

omniroute server --tray shows no tray on macOS/Linux with no error printed.

The wired Unix tray path (serve.mjs → tray/index.mjs → traySystray.mjs) loaded systray2 via an inline loader that called require("module") inside an ESM .mjs file (package "type":"module"). require is undefined in ESM → ReferenceError: require is not defined, swallowed by a bare catch {} → loadSystray2() returned null → no tray, no diagnostic. Regressed in v3.8.34. Even had it loaded, systray2 is not in node_modules — it is lazily installed into ~/.omniroute/runtime by trayRuntime.ts. The maintained tray.ts/trayRuntime.ts path that does this correctly existed but was never wired in.

Fix (Unix path only — Windows trayWindows.mjs untouched)

  • initSystrayUnix is now async and delegates loading to trayRuntime.ts::loadSystray (lazy-installs + chmods + imports systray2 from the runtime dir).
  • Icon path corrected: icon.png (the previous icons/icon.png never existed → empty icon).
  • isTemplateIcon: false — the full-color RGBA icon rendered as a solid white square under macOS template mode (looked "missing" even when loaded).
  • serve.mjs now surfaces tray-start failures to stderr instead of swallowing them, so "--tray shows nothing" is diagnosable.

index.mjs::initTray and serve.mjs::maybeStartTray await the now-async init.

Validation (Hard Rule #18 — TDD)

tests/unit/tray-systray-loader-4605.test.ts: the native Go binary can't run in a unit test (same constraint as cli-tray-systray2.test.ts), so the test drives the loader seam via an injected ctor and asserts the menu (5 items incl. "Show Logs"), non-empty icon (path fix), and isTemplateIcon === false. Fail-before proven by restoring the broken require() loader (test 1 → ✖). All 21 tray-suite tests pass.

⚠️ Native macOS validation deferred: the unit test covers the loader/menu plumbing; the actual menu-bar icon appearance must be confirmed on a real mac (CI is headless Linux).

…4605)

The wired tray path (serve.mjs -> tray/index.mjs -> traySystray.mjs) loaded
systray2 via an inline loader calling require("module") inside an ESM .mjs file
(package type:module), which throws ReferenceError: require is not defined and
was silently swallowed -> no tray, no diagnostic (regressed in v3.8.34). Even
when fixed, systray2 is not in node_modules; it is lazily installed into
~/.omniroute/runtime by trayRuntime.ts.

initSystrayUnix now delegates loading to trayRuntime.ts::loadSystray (async),
fixes the icon path (icon.png, not icons/icon.png), sets isTemplateIcon:false
(full-color icon rendered as a white square under macOS template mode), and
serve.mjs surfaces tray-start failures to stderr instead of swallowing them.

TDD: tray-systray-loader-4605.test.ts drives the loader seam via an injected
ctor (native binary can't run in unit tests) and asserts the menu/icon/template
invariants; fail-before confirmed by restoring the broken require() loader.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@diegosouzapw
diegosouzapw merged commit ba38e31 into release/v3.8.40 Jun 29, 2026
7 checks passed
@diegosouzapw diegosouzapw mentioned this pull request Jun 29, 2026
@diegosouzapw
diegosouzapw deleted the fix/4605-tray-runtime-loader branch June 29, 2026 01:05
@diegosouzapw diegosouzapw mentioned this pull request Jun 29, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…iegosouzapw#4605) (diegosouzapw#5276)

The wired tray path (serve.mjs -> tray/index.mjs -> traySystray.mjs) loaded
systray2 via an inline loader calling require("module") inside an ESM .mjs file
(package type:module), which throws ReferenceError: require is not defined and
was silently swallowed -> no tray, no diagnostic (regressed in v3.8.34). Even
when fixed, systray2 is not in node_modules; it is lazily installed into
~/.omniroute/runtime by trayRuntime.ts.

initSystrayUnix now delegates loading to trayRuntime.ts::loadSystray (async),
fixes the icon path (icon.png, not icons/icon.png), sets isTemplateIcon:false
(full-color icon rendered as a white square under macOS template mode), and
serve.mjs surfaces tray-start failures to stderr instead of swallowing them.

TDD: tray-systray-loader-4605.test.ts drives the loader seam via an injected
ctor (native binary can't run in unit tests) and asserts the menu/icon/template
invariants; fail-before confirmed by restoring the broken require() loader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant