Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 1856369a14b7834be5f53ebac94bf4a035407a5a and 1a4cc8b. 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThis PR adds a comprehensive out-of-process plugin system for the Electron app. It introduces shared plugin manifest, protocol, and registry contracts; a forked plugin-host entrypoint and runtime that loads third-party code in isolation; main-process plugin discovery, enablement, first-run consent, and IPC/RPC wiring; a preload 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (9)
src/shared/plugins/plugin-panel-bridge.ts (1)
42-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
z.ZodTypeAnyis deprecated in Zod 4 — usez.ZodType.Per Zod's v4 migration guide,
ZodTypeAnyis now just a deprecated alias forZodType. Functionally harmless today, but worth switching before a future major version drops the alias.♻️ Suggested change
-export const PANEL_ACTION_PARAM_SCHEMAS: Record<PluginPanelAction, z.ZodTypeAny> = { +export const PANEL_ACTION_PARAM_SCHEMAS: Record<PluginPanelAction, z.ZodType> = {examples/plugins/model-shift/panel.html (1)
129-141: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueConsider verifying
event.sourceon incoming panel messages.The listener trusts any message with the right
type, without checkingevent.source === window.parent. Impact here is limited to cosmetic UI state, but as a reference implementation for third-party plugin panels, this pattern will likely be copied as-is.🔒 Suggested origin/source check
window.addEventListener('message', function (event) { + if (event.source !== window.parent) return var data = event.data if (!data || data.type !== 'orca-panel-action-result') returnsrc/main/plugins/plugin-service.ts (1)
96-107: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winParallelize plugin activation during startup.
Approved plugins are activated one at a time; each
activatePlugincall forks a real child process, so N approved plugins add up serially to app startup latency. Since each plugin has its own independent host/registry entry, activating them concurrently is safe.⚡ Proposed parallelization
- for (const plugin of this.discovered) { - if (isInvalidDiscoveredPlugin(plugin)) { - continue - } - if (this.getActivationState(plugin.pluginId) !== 'approved') { - continue - } - await this.activatePlugin(plugin) - } + await Promise.all( + this.discovered + .filter( + (plugin): plugin is ValidDiscoveredPlugin => + !isInvalidDiscoveredPlugin(plugin) && this.getActivationState(plugin.pluginId) === 'approved' + ) + .map((plugin) => this.activatePlugin(plugin)) + )src/main/plugins/plugin-host-process.test.ts (1)
43-121: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing coverage for the force-kill fallback in
dispose().No test exercises the case where a host ignores the
shutdownmessage and must beSIGKILLed afterPLUGIN_HOST_SHUTDOWN_GRACE_MS. Given this is the safety-net path preventing orphaned plugin processes, it's worth a dedicated fixture (e.g., a host that ignoresshutdownbut reacts toSIGKILL).src/main/plugins/plugin-enablement.ts (1)
8-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider validating
pluginIdin this shared write path.The doc comment states this is the single write path used by the desktop IPC handler, the headless RPC method, and the first-run consent prompt. IPC and RPC callers both validate
pluginIdat their boundary, butplugin-first-run-consent.tsisn't in this review batch to confirm it does too. Since this function is meant to be the canonical entry point, adding a guard here would make the contract self-enforcing rather than depending on every caller remembering to validate.♻️ Proposed guard
const { store, pluginService, pluginId, enabled } = input + if (!pluginId) { + return pluginService.listPlugins() + } const settings = store.getSettings()src/main/runtime/rpc/methods/plugins.ts (1)
79-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract
invokeCodeProvider/readPanelEntryinto shared helpers likeexecutePluginPanelAction.Both handlers duplicate the logic in
src/main/ipc/plugins.ts'splugins:invokeCodeProviderandplugins:readPanelEntryIPC handlers almost verbatim (resolve → validate → apply/read). The PR already extractedpanelActionandsetEnabledinto shared modules specifically for IPC/RPC parity — the same treatment here would keep both surfaces in sync automatically instead of relying on manual duplication.♻️ Sketch of extraction
+// plugin-code-provider-invoke.ts +export async function invokePluginCodeProvider(input: { + pluginService: PluginService + pluginId: string + providerId?: string + method: string + args: unknown[] +}): Promise<unknown> { /* shared body */ } + +// plugin-panel-entry.ts +export async function readPluginPanelEntry(input: { + pluginService: PluginService + pluginId: string + panelId: string +}): Promise<{ html: string } | null> { /* shared body */ }Then both
src/main/ipc/plugins.tsandsrc/main/runtime/rpc/methods/plugins.tscall these instead of duplicating the logic.Also applies to: 118-134
src/main/runtime/rpc/methods/plugins.test.ts (1)
1-150: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for
plugins.invokeCodeProviderandplugins.readPanelEntry.This suite tests
panelActionandsetEnabledwell but doesn't exercise the other two methods added/touched inplugins.ts(method resolution, unknown-method error, missing-provider error, and the panel entry read/null/error paths). Worth mirroring the pattern used forpanelActionhere.src/main/plugins/plugin-first-run-consent.ts (1)
26-42: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winUnhandled rejection mid-loop skips prompting remaining pending plugins.
If
showMessageBoxorapplyEnablementthrows for one plugin (e.g. astore.updateSettingsfailure), thefor...ofloop aborts and no further pending plugins are prompted this session — the caller (src/main/index.ts) only logs a warning via.catch(). Since pending status persists until explicitly resolved, wrapping each iteration in try/catch would let one failure not block prompting for the rest.🐛 Proposed fix
for (const plugin of pending) { - const { response } = await input.showMessageBox({ - type: 'question', - buttons: ['Enable Plugin', 'Keep Disabled'], - // Why: enabling runs third-party code with full system access, so the - // safe answer (and Esc) must be the default. - defaultId: 1, - cancelId: 1, - title: 'New Orca plugin found', - message: `Enable plugin "${plugin.name}"?`, - detail: - `Version ${plugin.version} (${plugin.pluginId}) was found in your plugins folder. ` + - 'Plugins run with the same system access as Orca itself — only enable plugins you trust.' - }) - await input.applyEnablement(plugin.pluginId, response === 0) + try { + const { response } = await input.showMessageBox({ + type: 'question', + buttons: ['Enable Plugin', 'Keep Disabled'], + defaultId: 1, + cancelId: 1, + title: 'New Orca plugin found', + message: `Enable plugin "${plugin.name}"?`, + detail: + `Version ${plugin.version} (${plugin.pluginId}) was found in your plugins folder. ` + + 'Plugins run with the same system access as Orca itself — only enable plugins you trust.' + }) + await input.applyEnablement(plugin.pluginId, response === 0) + } catch (error) { + console.warn(`[plugins] failed to prompt for consent on ${plugin.pluginId}:`, error) + } }src/main/runtime/orca-runtime.ts (1)
8531-8565: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winUse a real active-tab signal for the fallback. The
this.tabs.values()loop returns the first tab with anyactiveLeafIdin Map insertion order, so this can pick an arbitrary worktree instead of the last-focused one. If there’s an active/selected tab field available, prefer that here; otherwiseworkspace.readContextcan expose the wrong path/branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7b8edac0-6c7b-4018-809b-ab6470729bd7
📥 Commits
Reviewing files that changed from the base of the PR and between 6a4b897 and 0ff8bb066af9663158fe229dfb550beeb707e3ea.
📒 Files selected for processing (60)
config/electron-builder.config.cjselectron.vite.config.tsexamples/plugins/hello-orca/main.jsexamples/plugins/hello-orca/orca-plugin.jsonexamples/plugins/hello-orca/panel.htmlexamples/plugins/model-shift/orca-plugin.jsonexamples/plugins/model-shift/panel.htmlsrc/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/service.test.tssrc/main/index.tssrc/main/ipc/plugins.tssrc/main/ipc/register-core-handlers.tssrc/main/persistence-right-sidebar-tab.test.tssrc/main/persistence.tssrc/main/plugins/example-plugin-probe.test.tssrc/main/plugins/plugin-code-provider-proxy.tssrc/main/plugins/plugin-discovery.test.tssrc/main/plugins/plugin-discovery.tssrc/main/plugins/plugin-enablement.test.tssrc/main/plugins/plugin-enablement.tssrc/main/plugins/plugin-first-run-consent.test.tssrc/main/plugins/plugin-first-run-consent.tssrc/main/plugins/plugin-host-entry.tssrc/main/plugins/plugin-host-process.test.tssrc/main/plugins/plugin-host-process.tssrc/main/plugins/plugin-host-runtime.test.tssrc/main/plugins/plugin-host-runtime.tssrc/main/plugins/plugin-panel-actions.test.tssrc/main/plugins/plugin-panel-actions.tssrc/main/plugins/plugin-service.test.tssrc/main/plugins/plugin-service.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/index.tssrc/main/runtime/rpc/methods/plugins.test.tssrc/main/runtime/rpc/methods/plugins.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/right-sidebar/PluginPanel.test.tsxsrc/renderer/src/components/right-sidebar/PluginPanel.tsxsrc/renderer/src/components/right-sidebar/index.tsxsrc/renderer/src/components/right-sidebar/plugin-panel-activity-items.tssrc/renderer/src/components/right-sidebar/plugin-panel-bridge-host.test.tssrc/renderer/src/components/right-sidebar/plugin-panel-bridge-host.tssrc/renderer/src/components/right-sidebar/right-sidebar-activity-visibility.test.tssrc/renderer/src/components/right-sidebar/right-sidebar-effective-tab.test.tssrc/renderer/src/components/right-sidebar/right-sidebar-panel-content.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/store/plugin-panels.tssrc/renderer/src/store/right-sidebar-route.test.tssrc/renderer/src/store/right-sidebar-route.tssrc/shared/constants.tssrc/shared/plugins/code-provider.tssrc/shared/plugins/plugin-extension-registry.test.tssrc/shared/plugins/plugin-extension-registry.tssrc/shared/plugins/plugin-host-protocol.tssrc/shared/plugins/plugin-manifest.test.tssrc/shared/plugins/plugin-manifest.tssrc/shared/plugins/plugin-panel-bridge.test.tssrc/shared/plugins/plugin-panel-bridge.tssrc/shared/types.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/plugins/plugin-code-provider-proxy.ts (1)
26-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFork-boundary validation now correctly enforced.
The
decode()helper properly rejects malformed plugin results viasafeParsebefore they reach consumers, addressing the previously flagged issue abouthost.invoke(...)results being treated as opaque.One small improvement: the thrown error discards
parsed.error, so debugging a real malformed plugin response requires re-deriving which field failed. Consider attaching the zod issues as the errorcause.♻️ Optional improvement to surface validation details
const decode = <T>(method: string, schema: z.ZodType<T>, value: unknown): T => { const parsed = schema.safeParse(value) if (!parsed.success) { - throw new Error(`plugin returned a malformed ${method} result`) + throw new Error(`plugin returned a malformed ${method} result`, { cause: parsed.error }) } return parsed.data }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e6228495-6056-4e19-84e6-4679ce2fa2f8
📥 Commits
Reviewing files that changed from the base of the PR and between 0ff8bb066af9663158fe229dfb550beeb707e3ea and 7eb632327901e0dfff334640ec348f9f2704ca52.
📒 Files selected for processing (12)
src/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/service.test.tssrc/main/index.tssrc/main/plugins/plugin-code-provider-proxy.test.tssrc/main/plugins/plugin-code-provider-proxy.tssrc/main/plugins/plugin-host-process.tssrc/main/plugins/plugin-service.test.tssrc/main/plugins/plugin-service.tssrc/renderer/src/components/right-sidebar/right-sidebar-panel-content.tsxsrc/shared/plugins/code-provider.tssrc/shared/plugins/plugin-manifest.test.tssrc/shared/plugins/plugin-manifest.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/renderer/src/components/right-sidebar/right-sidebar-panel-content.tsx
- src/main/codex-accounts/runtime-home-service.test.ts
- src/shared/plugins/plugin-manifest.test.ts
- src/main/codex-accounts/service.test.ts
- src/shared/plugins/plugin-manifest.ts
- src/main/index.ts
- src/main/plugins/plugin-service.test.ts
- src/main/plugins/plugin-service.ts
- orca-plugin.json manifest schema (zod), VS Code-style contributes naming
- CodeProvider contract (Go-style interface, optional capability methods)
- Typed extension-point registry with per-plugin registration/teardown
- fork-IPC plugin host protocol schemas
- disabledPlugins setting + RightSidebarTab plugin:${string} tab keys
Co-Authored-By: Claude Opus 4.8 <[email protected]>
… plugin sidebar panels Plugins are directories with an orca-plugin.json manifest (VS Code-style contributes naming) discovered under <userData>/plugins. - Out-of-process plugin host per plugin (fork + ELECTRON_RUN_AS_NODE, same isolation as the daemon), zod-validated fork-IPC protocol both directions - CodeProvider: first Go-style typed extension point; capability-probed optional methods dispatched through the shared extension registry via main-process proxies - Right sidebar: plugin-contributed panels as dynamic plugin:<id>/<panel> tabs rendered in sandboxed opaque-origin iframes (allow-scripts only) - Desktop IPC (plugins:*) and runtime RPC (plugins.*) parity for headless orca serve / SSH clients - disabledPlugins setting mirroring the disabledTuiAgents enable model - Fixes pr-checks right-sidebar tab resetting to Explorer on restart (missing from normalizeRightSidebarTab) - Sample plugin at examples/plugins/hello-orca (TODO-scanner CodeProvider + panel) exercised end-to-end by the host runtime probe test; docs at docs/PLUGINS.md Co-Authored-By: Claude Opus 4.8 <[email protected]>
…l.sendText, ModelShift example Phase 2 of the plugin system. Sandboxed panel iframes (opaque origin, sandbox=allow-scripts) talk to the host renderer over a zod-validated postMessage protocol; the host verifies the sending window's identity and relays requests over new plugins:panelAction IPC / plugins.panelAction runtime RPC (headless serve parity). Main enforces the manifest's new contributes.permissions grants before executing. First action terminal.sendText types text into the active worktree terminal through the existing runtime sendTerminal pty path. Ships examples/plugins/model-shift, a gear-shifter panel that switches the Claude Code model via /model + Enter. Co-Authored-By: Claude Fable 5 <[email protected]>
… addressing, new panel actions Review fixes (codex + manual audit): - plugins:list/RPC handlers await PluginService.whenReady() so an early renderer fetch can't observe the empty pre-discovery list and leave the sidebar permanently pluginless - code providers are addressable by providerId; a multi-provider plugin's second+ providers were previously unreachable - preload invokeCodeProvider types args as unknown[] (backends always required an array and silently dropped non-array args) Consent (drop-a-folder must not execute code): - new approvedPlugins setting; discovered-but-unapproved plugins are 'pending' and fully inert (no host, no panel entry, no permissions) - desktop shows a one-time Enable/Keep-Disabled dialog after discovery; either answer persists (no nagging) - headless serve default-denies; new plugins.setEnabled RPC records approval explicitly (SSH parity) New permissioned panel actions: - workspace.readContext: read-only focused-worktree context (id, path, branch, displayName) via new OrcaRuntimeService.resolveActiveWorktreeContext - notifications.show: plugin-id-prefixed native notification + mobile relay via dispatchPluginNotification; ModelShift example shows the active branch Docs state plainly that plugin main code has full system access (host process = crash isolation, not a sandbox) and document the consent flow. Co-Authored-By: Claude Fable 5 <[email protected]>
…, result decoding - will-quit: join pluginService.dispose() into the allSettled barrier so Electron cannot exit before forked plugin hosts are shut down - plugin-host-process: post-ready child error events now reject in-flight invokes immediately instead of leaving them to individual timeouts - plugin-service: de-dupe concurrent activations via an in-flight map so a double enable cannot fork a second, orphaned host; a disable racing an in-flight enable now waits for the host to land before stopping it - right-sidebar: key PluginPanel by tab so switching plugin panels remounts the sandboxed iframe instead of rebinding the bridge under a reused frame - plugin-manifest: reject codeProviders without a main entry at parse time (providers register from main's activate(); such manifests were inert) - code-provider proxy: decode fork-boundary results with zod schemas instead of casting, so malformed plugin responses fail loudly at the boundary - codex-accounts tests: add missing approvedPlugins to settings builders (pre-existing typecheck break on the branch) Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
1856369 to
1a4cc8b
Compare
|
Closing: plugin system is already on main via #8549 (plugin-host-process, panel bridge, first-run consent). |
Summary
Adds an extensible plugin system to Orca, built in three layers across four commits:
32024dcff) — manifest schema (zod), typed extension-point registry, plugin contracts.CodeProvideris the first extension point.7677759ef) — each plugin'smainruns in a forked Node child (ELECTRON_RUN_AS_NODE=1) for crash/lifecycle isolation; plugins can contribute right-sidebar panels rendered as sandboxed iframes (allow-scriptsonly, opaque origin,srcdoc— neverfile://).c0890263c) — panels call back into Orca via a validated postMessage bridge. Action id == permission id, declared in the manifest, enforced in the main process only (never renderer). First action:terminal.sendText. Example plugin: ModelShift (one-click Claude Code model switch).0ff8bb066) — review-driven fixes:pendingand are fully inert (no host process, no panel HTML, no permissions) until the user approves. Desktop shows a one-time dialog (safe default = Keep Disabled, both answers persisted); headless serve default-denies with aplugins.setEnabledRPC for explicit approval. Dropping a folder into<userData>/plugins/can no longer execute code silently.PluginService.whenReady()awaited in every IPC/RPC handler, so an early renderer fetch can't lock in an empty plugin list.providerId;invokeCodeProvidercan address one of several providers in a plugin.workspace.readContext(read-only focused-worktree metadata) andnotifications.show(plugin-id-prefixed titles to prevent notification spoofing, native + mobile relay).Trust model (documented in docs/PLUGINS.md)
Test plan
/model sonnettyped into live terminal.plugins.list/setEnabled/panelAction/invokeCodeProvider), consent default-deny verified by unit tests.🤖 Generated with Claude Code
ELI5
Adds an out-of-process plugin system with panels, permissioned actions, and first-run consent. Plugins run isolated and can contribute sandboxed sidebar UI.