Skip to content

Add plugin lifecycle hooks after add and remove - #13743

Open
Susensio wants to merge 2 commits into
omacom:quattrofrom
Susensio:fix/plugin-lifecycle-hooks
Open

Susensio wants to merge 2 commits into
omacom:quattrofrom
Susensio:fix/plugin-lifecycle-hooks

Conversation

@Susensio

Copy link
Copy Markdown
Contributor

Summary

  • Emit plugin-added (manifest id and source URL) as soon as a clone is installed, and plugin-removed (id) as soon as a plugin is removed; both run before shell rescan so a later shell/enable failure does not lose the event.
  • Make the shell rescan best-effort so plugin add can succeed before a fresh machine starts its shell.
  • Document both events, ship sample hooks, and test success/failure paths and event order.

Verification

  • bash test/shell.d/plugin-lifecycle-hooks-test.sh — 9/9 pass
  • All plugin-focused shell tests pass. Full ./test/shell has 15 failures and ./test/cli has 1 failure, reproduced unchanged on origin/quattro (environmental/baseline).

This allows user hooks to keep a portable source list for marketplace plugins without overriding Omarchy commands.

omarchy-plugin-add runs `omarchy-hook plugin-added <id> <url>` right after the
clone is moved into place, and omarchy-plugin-remove runs
`omarchy-hook plugin-removed <id>` right after the plugin is deleted or moved
aside. Both fire at the filesystem transition, before the shell rescan and
before an added plugin is optionally enabled, so a later rescan or enable
failure cannot leave the hook state stale.

The rescan that follows is now best-effort (`omarchy-shell -q`), so an add with
no running shell completes instead of reporting failure after the clone landed.

Ships plugin-added.d and plugin-removed.d sample hooks, documents both events,
and adds a scratch-HOME regression test for the events, their ordering, their
absence on a failed operation, and headless add.
@Susensio

Copy link
Copy Markdown
Contributor Author

I trimmed the explanations out of the command bodies to match their existing terse style. The hook calls sit immediately after the clone is moved into place or the plugin is removed: those filesystem changes have already happened even if the following shell rescan (or optional enable) fails. The -q rescan makes that IPC call best-effort when the shell is not running, so a headless plugin add can report a successful install. The events carry the manifest id and original Git URL on add, and the id on remove.

@sanjyay

sanjyay commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

This is an independent community review and unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Tested commit 7596e60caaf0bc59f5c6fdde66384e454a9ab0e8 in a clean Omarchy test environment.

Verification Summary

  • Base Verification (origin/quattro): On the base branch, running test/shell.d/plugin-lifecycle-hooks-test.sh failed as expected:
    shell shell rescanPlugins
    not ok - plugin add fires plugin-added with the id, URL, and the installed clone
    
    Additionally, running omarchy-plugin-add in a headless environment without an active Quickshell instance caused the command to fail on rescanPlugins despite having already staged and moved the repository into place.
  • PR Branch Verification (pr-13743):
    • omarchy-hook plugin-added "$id" "$url" and omarchy-hook plugin-removed "$id" fire reliably at the filesystem transition point before the shell rescan and before any optional enablement.
    • Using omarchy-shell -q makes the IPC rescan call best-effort, allowing headless plugin operations to succeed cleanly when no compositor/shell is running.
    • Sample hooks (config/omarchy/hooks/*.d/*.sample) and documentation updates in default/agents/skills/omarchy/hooks.md and manual/31-dotfiles.md match the runtime behavior.
    • All 9 checks in test/shell.d/plugin-lifecycle-hooks-test.sh pass.
    • All sibling plugin suites (plugin-picker-test.sh, plugin-add-test.sh, plugin-clone-test.sh, plugin-enable-test.sh, plugin-validation-test.sh, and plugin-manifests-test.sh) pass.
    • omarchy commands --check passed across 467 commands.
Verification output
$ ./test/shell.d/plugin-lifecycle-hooks-test.sh
ok - plugin add fires plugin-added once the clone is in place
ok - plugin-added fires before the shell rescan
ok - plugin add fires no plugin-added when the add fails
ok - plugin-added fires before the rescan and the optional enable
ok - plugin remove fires plugin-removed once the plugin is gone
ok - plugin-removed fires before the shell rescan
ok - plugin remove fires no plugin-removed when the remove fails
ok - plugin add records the plugin and succeeds with no running shell
ok - plugin remove records the removal and succeeds when the shell dies before the rescan

$ omarchy commands --check
Command metadata check passed (467 commands)

If you'd prefer not to receive these independent reviews on your PRs, reply to this comment and say so, and I won't review your future PRs.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants