#19717: fix: load plugin registry before channel commands run
cli
size: XS
trusted-contributor
Cluster:
Plugin Management Enhancements
Fixes #19697
## What changed
Added `ensurePluginRegistryLoaded()` call in the `runChannelsCommand` function in `src/cli/channels-cli.ts`. This ensures the plugin registry is loaded before running any channel commands (like `channels add`), which allows Discord and other extension-based channels to be properly discovered and registered.
## AI-assisted contribution
This fix was generated by an AI agent (OpenClaw cron: gh-issues-fix)
- Testing depth: validated with pnpm build && pnpm check && pnpm test
- The fix addresses the root cause described in the issue by ensuring the plugin registry is initialized before channel lookups occur
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds a defensive `ensurePluginRegistryLoaded()` call in `runChannelsCommand` so the plugin registry is guaranteed to be loaded before channel subcommands execute. This is a belt-and-suspenders fix — the preAction hook in `src/cli/program/preaction.ts` already loads the registry for all `channels` commands via `PLUGIN_REQUIRED_COMMANDS`. The idempotency guard in `ensurePluginRegistryLoaded()` makes the duplicate call harmless.
- The fix applies only to `runChannelsCommand` but misses `runChannelsCommandWithDanger` (used by `login`/`logout`), which similarly depends on the plugin registry for extension-based channels.
- The overall change is low-risk due to the existing preAction coverage and the idempotency guard.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge — the change is idempotent and redundant with existing preAction coverage, making it low-risk.
- The added call is guarded by an idempotency check and the preAction hook already ensures plugin loading for all channels commands. The only concern is the inconsistency with `runChannelsCommandWithDanger`, but it's not a runtime issue due to the existing preAction hook.
- src/cli/channels-cli.ts — `runChannelsCommandWithDanger` should also call `ensurePluginRegistryLoaded()` for consistency.
<sub>Last reviewed commit: e6a59d5</sub>
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#7090: fix: plugin install uses manifest ID for folder name (#2796)
by dial481 · 2026-02-02
75.3%
#12084: fix: prevent false duplicate plugin warning for bundled channel plu...
by shadril238 · 2026-02-08
74.9%
#14795: fix: skip disabled channel plugins in cross-context messaging checks
by explainanalyze · 2026-02-12
74.6%
#2556: fix(plugin-install): handle existing plugins and filter workspace deps
by longmaba · 2026-01-27
74.5%
#21660: fix(plugins): require explicit allowlist for non-bundled plugins
by AI-Reviewer-QS · 2026-02-20
73.8%
#19735: fix: inject CLAWD_URL/CLAWD_TOKEN env vars in Lobster plugin
by MisterGuy420 · 2026-02-18
73.4%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
73.4%
#5391: fix(commands): prevent webchat/tui from inheriting messaging channe...
by Glucksberg · 2026-01-31
73.4%
#18966: fix(config): downgrade unknown bundled plugin references to warnings
by moxunjinmu · 2026-02-17
73.2%
#15618: fix(plugins): reject async plugin registration instead of silently ...
by AI-Reviewer-QS · 2026-02-13
73.1%