Skip to content

Allow plugin panels to invoke their own worker commands - #12229

Closed
Syfyivan wants to merge 1 commit into
stablyai:mainfrom
Syfyivan:agent/plugin-panel-worker-commands
Closed

Syfyivan wants to merge 1 commit into
stablyai:mainfrom
Syfyivan:agent/plugin-panel-worker-commands

Conversation

@Syfyivan

@Syfyivan Syfyivan commented Aug 3, 2026 •

Copy link
Copy Markdown

Summary

  • add a session-bound plugin.command.invoke panel action so a plugin panel can call commands registered by its own worker
  • preserve the existing plugin consent, manifest contribution, registered-handler, message-size, and rate-limit checks
  • reject caller-supplied plugin identity and cap serialized worker results at 1 MiB
  • extend the hello-orca example and Electron E2E coverage to exercise the complete panel-to-worker path

Why

Plugin panels can currently call a small set of host actions, but they cannot consume data or logic owned by their plugin worker. That prevents sandboxed panels from presenting dynamic plugin data such as local indexes, databases, or computed history unless Orca adds a dedicated host API for every use case.

This change keeps the iframe sandbox intact. Main derives the plugin identity from the opaque panel session and routes only to a command contributed and registered by that same enabled plugin.

Security boundaries

  • panel requests contain only commandId and optional args; extra fields such as pluginKey fail validation
  • command dispatch uses the plugin key bound to the verified panel session
  • the existing worker command validation and consent model remains authoritative
  • worker errors are converted to bounded panel errors, and successful results are limited to 1 MiB before crossing renderer clone boundaries

Testing

  • 24 focused Vitest tests
  • pnpm run typecheck:node
  • pnpm run typecheck:web
  • oxfmt --check on all changed files
  • oxlint --deny-warnings on changed TypeScript files
  • pnpm run build:electron-vite
  • pnpm run test:e2e -- tests/e2e/plugin-demo.spec.ts --workers=1

@Syfyivan
Syfyivan marked this pull request as ready for review August 6, 2026 12:08
@Syfyivan

Syfyivan commented Aug 6, 2026

Copy link
Copy Markdown
Author

Hi @brennanb2025 — this PR is ready for review. It adds a session-bound plugin.command.invoke panel action so plugin panels can call commands registered by their own worker (previously panels could only use the small set of host actions, which prevented sandboxed panels from consuming data/logic owned by their plugin worker).

Quick summary of what's included:

  • Main derives the plugin identity from the opaque panel session; caller-supplied identity is rejected
  • Routing is restricted to a command contributed in the plugin manifest and actually registered by that same, user-approved plugin
  • Existing consent, message-size, and rate-limit checks are preserved; worker results are capped at 1 MiB; iframe sandbox is unchanged
  • No new dependencies or local services

Validation performed:

  • 23 focused Vitest tests
  • pnpm run typecheck:node / pnpm run typecheck:web
  • oxfmt --check + oxlint --deny-warnings
  • Electron production build + E2E (plugin-demo.spec.ts) covering: install plugin → review/consent → main calls worker → panel calls worker → panel receives pong count=3

This is a generic plugin capability (not a one-off hook), so future plugins displaying local indexes, databases, or computed data can use it too. I've also published a reference plugin (Syfyivan/orca-codex-history-viewer) that depends on this bridge. Happy to adjust anything — thanks!

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds the plugin.command.invoke panel action. The bridge validates command IDs and parameters, then relays requests to the main process. The panel controller invokes commands for the bound plugin and runtime session, limits serialized results to 1 MiB, and returns bounded failures. PluginService supplies the command callback. The Hello Orca panel and end-to-end test cover worker command execution.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: enabling plugin panels to invoke their own worker commands.
Description check ✅ Passed The description clearly explains the change, rationale, security boundaries, and testing performed, with only minor template sections omitted.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e389b6b9-9ddb-4a0d-a19e-7f899fd49521

📥 Commits

Reviewing files that changed from the base of the PR and between aa03e24 and cd35070ba3903b45da2f17521e4a094a6b7ddac0.

📒 Files selected for processing (7)
  • examples/plugins/hello-orca/panel.html
  • src/main/plugins/plugin-panel-controller.test.ts
  • src/main/plugins/plugin-panel-controller.ts
  • src/main/plugins/plugin-service.ts
  • src/renderer/src/components/right-sidebar/plugin-panel-bridge-host.test.ts
  • src/shared/plugins/plugin-panel-bridge.ts
  • tests/e2e/plugin-demo.spec.ts

Plugin panels could call host actions but could not query commands registered by their own worker, which made dynamic local-data panels impossible. Bind command dispatch to the opaque panel session owner and keep validation, rate limits, and result-size limits in the main process.

Constraint: Panel callers never supply a plugin key; dispatch always uses the session-bound owner.
Rejected: Direct filesystem access from the panel | the sandboxed iframe intentionally has no Node authority.
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Keep same-plugin command invocation bound to the opaque panel session and preserve the result-size cap.
Tested: 23 targeted Vitest tests; plugin demo Electron E2E; Node and web typechecks; oxfmt; oxlint --deny-warnings; electron-vite production build.
@Syfyivan
Syfyivan force-pushed the agent/plugin-panel-worker-commands branch from cd35070 to 78dfd32 Compare August 10, 2026 10:02
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nwparker nwparker removed the P2 label Aug 19, 2026
@Fnine59

Fnine59 commented Aug 23, 2026

Copy link
Copy Markdown

I verified this change against the current main at c3a1694b1 by cherry-picking 78dfd325f onto a fresh branch.

Results:

  • Applies cleanly with no conflicts
  • Focused unit tests: 24/24 passed
  • pnpm typecheck: passed
  • Oxlint on the changed TypeScript files: passed
  • tests/e2e/plugin-demo.spec.ts: passed

The session-bound, same-plugin command dispatch still fits the current panel and worker-command architecture without widening panel access to arbitrary host APIs.

Is there any remaining design or maintenance concern blocking review or merge? I am happy to help refresh the branch or address follow-up feedback.

@harepus

harepus commented Sep 29, 2026

Copy link
Copy Markdown

We'd use this for a plugin with a launcher and live agent dashboard in the sidebar panel. The only workaround today is routing actions through a terminal and rewriting the panel HTML to push state.

FYI it no longer applies cleanly on main: small conflicts in plugin-service.ts and plugin-panel-controller.ts (the log option signature changed), and plugin-service.ts now hits the 300-line max-lines limit. With those fixed, the plugin tests and both typechecks pass.

jmfieldman added a commit to jmfieldman/docket that referenced this pull request Oct 4, 2026
- ui/index.html: findings grouped by lane (needs attention, quick,
  decide, scope, dig, needs research) with complexity and confidence
  meters, lane-specific primary actions, bulk accept for quick, expandable
  detail (background, why it matters, options with blast radius and pros
  and cons, discussion, review comments, commit history), reply approval,
  reopen, light and dark themes. Redraws only when data changes.
- docket ui [--open]: local HTTP server on 127.0.0.1. Writes need an
  x-docket header and a same-origin request. src/api.ts is the action
  layer shared with the Orca worker; dispatch launches agent terminals
  through the Orca CLI, reuses a live applier, resumes discussions by
  session id, and keeps a quick-fix decision even when the applier cannot
  start.
- orca-plugin/: "Docket: Open" command (starts a detached server with
  Orca's own runtime and opens the worktree in Orca's browser), a right
  sidebar panel that uses the same page, and a worker API for when Orca
  lets panels call their worker (stablyai/orca#12229 is unmerged; today
  the panel is a launcher).
- scripts/demo.mjs: throwaway fixture with every lane and state.

Verified: 9 server tests (40 total, against source and bundle); the
worker runs inside Orca's Electron with a scrubbed PATH; the UI was
exercised in a browser (decide, acknowledge, quick fix without Orca,
reply approval, narrow width, light mode).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@LociStar

Copy link
Copy Markdown

What is the status on this? Will this eventually be merged? Can I help in any way?

@nwparker

nwparker commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@Syfyivan Thank you for this, and sorry it sat so long. Panel-to-worker calls landed in #37013 (merged), which takes a slightly different shape: a panel calls plugin.request(name, input) and the worker answers with orca.panels.handle(name, handler). It goes through the host, so it reuses the existing session, consent and capability checks, starts the worker on demand, and works on remote-only worktrees. Docs: docs/reference/plugin-host-api.md; a full example is examples/plugins/hello-worker-panel. Closing this as superseded. Your PR helped shape what we needed, so thanks again.

@nwparker nwparker closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants