Skip to content

Fix cloned service lookups - #10416

Closed
imzihuailin wants to merge 1 commit into
omacom:quattrofrom
imzihuailin:fix/clone-aware-service-lookups
Closed

imzihuailin wants to merge 1 commit into
omacom:quattrofrom
imzihuailin:fix/clone-aware-service-lookups

Conversation

@imzihuailin

Copy link
Copy Markdown
Contributor

Fixes #10404.

Cloning a service plugin registers its instance under the clone’s manifest ID, while consumers keep looking it up by the built-in ID. serviceFor() now resolves an enabled clone before looking up the service, with the original ID retained as a compatibility fallback.

Reproduced on Omarchy 4.0.2-1, the latest released build: cloning omarchy.idle leaves the Stay Awake indicator unable to read or toggle the running service.

This also fixes the same lookup path for cloned night light, notifications, and media services.

Validation:

  • Added service lookup coverage for idle, night light, notifications, and media.
  • Verified each service cloned individually, after shell restart, and after restoring the built-in service.
  • Verified all four cloned together, including Stay Awake, Night Light, Do Not Disturb, media bar widget, and audio panel.
  • Confirmed visually in a disposable VM that the indicators and media controls behave correctly.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed, nothing blocking found. Recommending this to the maintainer as the fix for the cloned-service-lookup bug.

What was checked. Read the diff against quattro (merge-base 959e49dc), then every other reader of a plugin id in shell/shell.qml and shell/services/PluginRegistry.qml to see whether this is a one-call-site fix of a five-call-site problem. It is not: firstPartyServiceFor delegates to serviceFor, and the panel loader's item.service = shell.serviceFor(panelEntry.pluginId) at shell/shell.qml:663 goes through the same function, so all five hardcoded consumers named in #10404 are covered by the one change. ensureService, _syncServices, serviceKeepLoaded, the barWidgetRegistry population and listPlugins all take a concrete already-resolved manifest id and are correctly left raw.

Tests. Ran on a disposable VM built from the Omarchy ISO, with the compositor pointed at this branch (quickshell -n -p .../omarchy-pr-10416/shell confirmed before trusting the run), not on a machine that only greps the QML:

  • test/shell.d/service-lookup-test.sh — 32 passed
  • test/shell.d/indicator-contract-test.sh — passed, real compositor
  • plugins-test.sh, plugin-clone-test.sh, bar-widget-contract-test.sh, manifest-entrypoints-test.sh — all passed
  • ./test/cli — 112 passed, 0 failed

Then mutated serviceFor back to the old return _services[String(pluginId)] || null on the worker and re-ran: service-lookup-test.sh fails with idle: built-in lookup reaches enabled clone / expected: [object Object] / actual: null, and indicator-contract-test.sh fails too. So the new tests genuinely fail without the fix rather than passing regardless — which is worth saying explicitly, because it is the thing that distinguishes them from a test that only asserts the source text still contains a given call.

Reverse regression. Checked what happens when a user has both the original and the clone installed, since that is the normal reason to clone. Through the supported CLI the two are mutually exclusive: setEnabled calls activeCloneFor then restoreCloneSource, so omarchy plugin enable omarchy.idle drops the clone's entry rather than leaving both live. Forced both-enabled by hand, serviceFor("omarchy.idle") returns the clone — which is the same answer summon, hide, toggle and callIfLoaded already give through resolveEnabledId, so this makes the service path agree with the IPC path rather than diverging from it. No regression found.

Second opinion. Codex at xhigh reviewed it independently and found no defect either. Its independence is not currently guaranteed — it can read this session's transcript — so where it merely agreed with a conclusion already reached, that agreement is worth less than it looks. It did contribute one mechanism that had not been reasoned about, which stands on its own: unloadPluginServices (shell/shell.qml:369) preserves every keepLoaded instance without consulting isEnabled, and omarchy.idle, omarchy.media and omarchy.notifications are all keepLoaded. So between reloadPlugins calling it and onScanFinished calling _syncServices, the disabled original is still in _services while the clone's instance does not exist yet, and the || _services[String(pluginId)] fallback returns the stock service during that window. That was verified against the source and it is real, but it is not a defect: the window is bounded by one manifest rescan, _syncServices then prunes the original regardless of keepLoaded, and the behaviour inside the window is exactly what ships today. The fallback is the conservative choice there — without it the indicator goes transiently null instead.

Two things for the maintainer, not for you to act on. This says Fixes #10404, but #10023 and #10439 report the same root cause with the same five consumers and the same suggested fix, so all three close on this. And #10429 is a competing fix for the same bug; choosing between them is the maintainer's call and neither PR has been touched. Reviewed by Claude Opus 5 in Claude Code and by Codex at xhigh reasoning.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-checked against current quattro (821ae589), and the bug this fixes is already fixed there, so this looks ready to close rather than merge. That updates the earlier review here, which predated the change below.

What fixed it. firstPartyServiceFor() on quattro now resolves the enabled clone before looking up the service (shell/shell.qml:881, return serviceFor(shell.pluginRegistry.resolveEnabledId(pluginId))). That came in with 203e163, which landed through #9618 on 7 September. Stay Awake, Night Light, Do Not Disturb, the media widget and the audio panel all look services up through that function. #10404, #10023 and #10439 are already closed.

What was run. On a disposable VM built from the Omarchy ISO, with the compositor-backed tests wired to its session, this branch's own tests ran against two trees: quattro with this pull request merged, and the same tree with shell/shell.qml put back to quattro's, so only this change's serviceFor edit is missing.

  • indicator-contract-test.sh, the real-compositor indicator test this pull request extends, passes on both. Without this change, the indicators still reach the cloned service.
  • service-lookup-test.sh passes 32 of 32 with the change. Without it, the "built-in lookup reaches enabled clone" assertions still pass. The first failure is clone wins while original still exists, which asserts that raw serviceFor("omarchy.idle") prefers the clone while the disabled original is still loaded. That is the short keepLoaded window between a plugin reload and the next service sync, and it behaves the same as before the reported bug.
  • plugins-test.sh, plugin-clone-test.sh, plugin-auth-boundary-test.sh and runtime-smoke-test.sh pass on both.

What is left. Two callers on quattro still pass a built-in id to serviceFor(): the media/notification shortcuts (shell/shell.qml:1583) and the volume keys (:1590). With a cloned service, both miss it and fall back to omarchy-shell <target> <method> and omarchy-audio-output-volume. Cloning keeps the IPC target names, so the shortcuts still reach the clone, and the script still changes the volume and shows the OSD. That costs an extra process per keypress but does not break anything a user would see. If that is worth changing, it is a small change to those two lookups, not to serviceFor() itself.

Second opinion. Codex Medium reviewed the same questions against quattro. It agreed that the bug is already fixed and that nothing user-visible remains, and its independence is not guaranteed. It also traced the fix to 203e163 and went through each remaining raw serviceFor() caller and its fallback. Merging this onto quattro introduces no defect that either review found.

Waiting on the maintainer to decide whether to close this. Reviewed by Claude Opus 5.5 in Claude Code and by Codex Medium.

@imzihuailin imzihuailin closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloned service plugins are invisible to firstPartyServiceFor() (breaks Stay Awake indicator after cloning omarchy.idle)

2 participants