Skip to content

Give the plugin commands an IPC budget that fits a reload - #11118

Open
Mario-Mohar wants to merge 1 commit into
omacom:quattrofrom
Mario-Mohar:plugin-ipc-budget
Open

Mario-Mohar wants to merge 1 commit into
omacom:quattrofrom
Mario-Mohar:plugin-ipc-budget

Conversation

@Mario-Mohar

Copy link
Copy Markdown

Fixes #9304.

The problem

omarchy-plugin-enable, -disable and -remove each hang on a single IPC call, made in a command substitution under set -euo pipefail:

result=$(omarchy-shell shell enablePlugin "$id" "$placement")

omarchy-shell wraps every call in timeout ${OMARCHY_SHELL_IPC_TIMEOUT:-2s} and exits 1 when it expires, so the substitution fails and set -e ends the command right there with omarchy-shell is not responding.

These commands are normally run inside the exact window where that happens. omarchy-plugin-add and omarchy-plugin-clone call enable a step after their own rescanPlugins, and saving a file under ~/.config/omarchy/plugins/ starts the same reload through inotify. Rebuilding every plugin instance blocks the shell's IPC for longer than two seconds, so the call expires and the command reports an unreachable shell, when the shell is busy with the very work the command is waiting on.

#9304 reports the user-visible half of this: omarchy plugin add --enable leaves the plugin installed but disabled, and running omarchy plugin enable <id> a few seconds later works every time.

Reproducing it

does.not.exist is used deliberately: no outcome changes anything, so the only variable is which error comes back. Run against a live shell while a real plugin update is reloading:

installed  exit=1 | omarchy-shell is not responding
patched    exit=1 | omarchy-plugin-enable: plugin 'does.not.exist' is not known; run: omarchy-shell shell rescanPlugins

Same command, same moment. Without the change the shell never gets asked; with it, the question is answered correctly.

The window is real but timing dependent. It opens only when the shell has plugin code to reload: a rescan with nothing to load answers in 0.05 s, one right after a real plugin update takes 1.65 s, and one arriving while another is still rebuilding took 7.32 s on this machine with 9 git managed plugins.

The change

export OMARCHY_SHELL_IPC_TIMEOUT="${OMARCHY_SHELL_IPC_TIMEOUT:-15s}"

in those three commands, with a comment explaining why they are the ones that need it.

Three things this deliberately does not do:

  • It does not use -q. A failed enable is a real failure, and swallowing it would leave result empty and produce fail "". Only a genuinely best-effort call may be quieted, which is what Make the closing plugin rescan best-effort #11117 does for the closing rescan.
  • It does not slow down a dead shell. qs reports a missing connection as a connection error, not a timeout, so omarchy-shell still fails at once on its "is not running" path. The budget only applies to a shell that is up and busy.
  • It does not override an explicit OMARCHY_SHELL_IPC_TIMEOUT. Someone who set one keeps it.

15 s comes from the 7.32 s worst case measured here, doubled. #9304 reports a slower reload still with 15 third-party plugins installed.

Testing

New test/shell.d/plugin-ipc-budget-test.sh. Its omarchy-shell stub keeps the part under test: the caller's budget wraps the call through a real timeout, and expiry becomes is not responding on exit 1. A stub shell that takes 3 s to answer is longer than the old 2 s default and shorter than the new budget, so the same call fails or succeeds purely on the budget. Four assertions: enable and disable both ride out the busy shell, remove asks for the raised budget, and an explicitly set budget is left alone.

Each of the three changes was reverted on its own to confirm the test fails without it:

without omarchy-plugin-disable  exit=1  not ok - plugin disable waits out a shell that is rebuilding plugins
without omarchy-plugin-enable   exit=1  not ok - plugin enable waits out a shell that is rebuilding plugins
without omarchy-plugin-remove   exit=1  not ok - plugin remove asks for the raised budget

./test/all fails the same 6 of its test files before and after, none of them plugin related: config, locate, runtime-smoke, screenshot-sanity, snapper, unowned-system-paths. They want an omarchy-pkgs checkout or a live compositor, neither of which this machine has.

Relation to #11117

Same root cause, opposite remedy, and they are independent. #11117 quiets the closing rescanPlugins in add, clone, remove and update, where the call is genuinely best effort and its failure should not be fatal. This one gives the calls whose result actually matters enough time to arrive. Both touch bin/omarchy-plugin-remove, in different places; whichever lands second may need a trivial rebase.

Unrelated thing noticed while testing

omarchy-shell shell setPluginEnabled <unknown-id> false answers ok, where enablePlugin correctly answers unknown. So omarchy plugin disable <typo> prints Disabled <typo> and exits 0 without doing anything. That is shell side and out of scope here; I can file it separately if it is not already known.

`omarchy-plugin-enable`, `-disable` and `-remove` each depend on a single IPC
call, made in a command substitution under `set -e`. They are normally run right
after something started a plugin reload: add and clone call them a step after
their own rescan, and saving a file under ~/.config/omarchy/plugins/ starts the
same reload through inotify.

Rebuilding every plugin instance blocks the shell's IPC for seconds, which is
longer than the 2s default budget. The call expires inside that window and the
command reports a shell that is not responding, when the shell is merely busy
with the very work the command is waiting on. For enable that is the difference
between a plugin being activated and being left installed but disabled.

Raise the default budget to 15s in these three commands. A shell that is
genuinely not running still fails at once, because that is a connection error
rather than a timeout, and an explicitly set OMARCHY_SHELL_IPC_TIMEOUT is left
alone.
@Mario-Mohar

Copy link
Copy Markdown
Author

Filed the setPluginEnabled observation from the last section as #11119. It is independent of this PR and present without it.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at af0ec3e. The bug is real, it still exists on current quattro, and this change fixes it. Nothing needs changing from you.

Reproduced on a worker built from the Omarchy ISO, against its running shell. I installed a plugin whose bar widget blocks the event loop for 5 s when it is created, enabled it, triggered rescanPlugins, and ran omarchy-plugin-enable on a second plugin half a second later, while the shell was rebuilding:

base (8ea515163)    exit=1 took=2.01s | omarchy-shell is not responding
this PR             exit=0 took=9.78s | Enabled acme.target
PR, export removed  exit=1 took=2.01s | omarchy-shell is not responding
quattro (821ae5890) exit=1 took=2.01s | omarchy-shell is not responding
quattro + the fix   exit=0 took=9.79s | Enabled acme.target

On every failing run the enable did take effect once the shell came back. The command still exits 1, and under set -e that is what stops omarchy-plugin-add --enable partway. quattro now tries the shell's own socket before falling back to qs ipc (#13435), and both paths take OMARCHY_SHELL_IPC_TIMEOUT. So the raised budget applies on either path. A stale socket or a missing shell still fails straight away, because that is a connection error rather than a timeout.

Tests, on the worker: ./test/cli and these shell tests, all green at the head: the new plugin-ipc-budget-test.sh, plugin-enable, plugin-add, plugin-clone, plugins, menu-plugin, plugin-auth-boundary, plugin-registry-contract and plugin-validate. I also merged the head into current quattro and ran the same set. The plugin tests pass there too. ./test/cli has one failure, vscode generated theme references current theme file, and bare quattro fails it the same way. The full ./test/shell suite was not run, and this PR has no CI results.

Size: proportionate. It adds one default in each of the three commands whose answer matters, and a test. #11117 handles the closing rescanPlugins calls with -q and is independent of this; the two touch bin/omarchy-plugin-remove in different places. One small inaccuracy in the comment: in bin/omarchy-plugin-remove it says add and clone call this command, which is true of enable and disable but not of remove. It doesn't affect behaviour.

Reviewed by: Claude Opus 5.5 only. No second opinion ran: the configured reviewer, Codex Medium, had used up its daily review budget. That is why this is labelled verified and not ready. It is waiting on a second review and on the maintainer.

@Sha01in

Sha01in commented Oct 10, 2026

Copy link
Copy Markdown

Another data point for this, from a 2017 Pixelbook (Core i5-7Y57, 4.5 W): omarchy plugin clone omarchy.osd failed with "omarchy-shell is not responding" at the enable step, and the failure path is worse than a spurious error. The clone's cleanup trap deleted ~/.config/omarchy/plugins/<user>.osd, but enable had already written shell.json (disabledPlugins: ["omarchy.osd"], the clone in plugins, cloneSourceRestores), so the shell was left with no OSD at all until I removed those entries by hand. With OMARCHY_SHELL_IPC_TIMEOUT=15s the same clone went through.

So besides the larger budget here, omarchy-plugin-clone's cleanup may need to undo the enable, or only delete the clone once it knows enable didn't change shell.json. A slow reload can still land in that window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

3 participants