Skip to content

feat(plugins): let sandboxed panels call storage.get, so a panel can render live state - #15643

Open
YoraiLevi wants to merge 2 commits into
stablyai:mainfrom
YoraiLevi:plugin-panel-storage-read
Open

YoraiLevi wants to merge 2 commits into
stablyai:mainfrom
YoraiLevi:plugin-panel-storage-read

Conversation

@YoraiLevi

Copy link
Copy Markdown

Follows #15638. That issue asked for a host→panel message channel; this is a much smaller change
that solves most of the same problem, so I built it instead.

Problem

A plugin panel cannot read any state its own worker computed.

Method panel:
workspace.readContext true
terminal.sendText true
notifications.show true
storage.get, storage.set, settings.get, settings.set, secrets.*, events.subscribe false

There is also no host→panel push. So a panel can only render static markup — whatever the plugin
author hard-coded at build time.

My plugin reads agent replies aloud. Users cannot see what is currently being read, which session
it came from, or what is queued behind it, because the panel has no way to learn any of it. The
real report that prompted this: "this is really confusing what it is even reading right now… a way
to control something and not feel helpless."
For an accessibility plugin that is not a cosmetic
gap.

Change

One line: storage.get becomes panel: true.

The worker writes its status to plugin-private storage; the panel polls and renders it. No new API,
no new capability, no new transport.

Why this is the narrowest possible fix

  • Read-only. storage.set and storage.delete stay worker-only, so a panel can observe state
    but never author it.
  • Plugin-private scope. A plugin can only read what it wrote itself.
  • Already capability-gated on storage, which the user consents to at install.
  • Strictly less powerful than what panels can already do. terminal.sendText is panel-callable
    and types into the user's terminal. Reading a plugin's own private key/value store is a smaller
    privilege than that, and today the weaker one is the forbidden one.
  • Secrets untouched. secrets.* remain entirely worker-only.

Tests

New src/shared/plugins/plugin-panel-storage-read.test.ts — 6 cases. Beyond the new surface it
pins invariants that should hold regardless of this PR:

  • writes and secrets.* are not panel-callable
  • every panel-callable method is capability-gated
  • no panel-callable mutation escapes an explicit scope

One existing fixture changed, and I want to flag it explicitly.
plugin-host-conformance.test.ts used storage.get as its exemplar of a panel-forbidden method.
That case exists to prove main and relay return identical panel_forbidden codes, not to pin that
particular method, so it now uses storage.set — a write, still forbidden by design. The case still
exercises the same path. If you would rather it used settings.get, say so and I will switch it.

npx vitest run --config config/vitest.config.ts src/main/plugins src/shared/plugins
Test Files  57 passed (57)
     Tests  359 passed (359)

Why other plugin authors want this

Every panel today is a static page. With this, a panel can show progress, a queue, a log tail, a
last-run result, a live status — anything the worker knows. That is the difference between panels
being decorative and being useful.

If you would rather solve it with the push channel from #15638, I am happy to build that instead —
this seemed like the version most likely to be safely mergeable today.

A plugin panel currently cannot read any state its own worker computed. workspace.readContext,
terminal.sendText and notifications.show are panel-callable; every readable state method
(storage.get, settings.get) is panel: false, and there is no host->panel push. A panel can
therefore only ever render static markup.

This is the narrowest fix that unblocks live panel UI: read-only, plugin-private scope, already
gated on the storage capability, and strictly less powerful than terminal.sendText - which panels
may already call, and which mutates a terminal.

Writes stay worker-only, so a panel can observe state but never author it. Secrets stay entirely
worker-only.

Adds plugin-panel-storage-read.test.ts covering the new surface plus invariants that should hold
regardless: writes and secrets are not panel-callable, every panel-callable method is capability
gated, and no panel-callable mutation escapes an explicit scope.
The fixture used storage.get, which this branch makes panel-callable. The case exists to prove
main and relay return identical panel_forbidden codes, not to pin that specific method, so it now
uses storage.set - a write, still worker-only by design.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The plugin host API now allows sandboxed panels to call storage.get through the postMessage bridge. The method remains read-only, plugin-private, and capability-gated. Storage writes and secrets operations remain worker-only. Tests cover panel access, capability requirements, scope metadata, allowed mutation scopes, and forbidden storage.set panel calls.

Merge Risk: ⚪ Minimal · up to 1c9fe

This narrowly scoped change enables panels to read their plugin’s private state while keeping writes and secrets restricted; no actionable merge-blocking risk remains, aside from a minor follow-up to strengthen transport conformance coverage.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, implementation, security limits, tests, and issue reference, but it omits several required template sections and checklist items. Add the required ELI5, What Changed, Why, Visual Proof or N/A, Testing checklist, AI Disclosure, Review, Notes, boundary, and final checklist sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: allowing sandboxed panels to call storage.get.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files.
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.

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

🧹 Nitpick comments (1)
src/shared/plugins/plugin-host-api.ts (1)

159-164: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten the storage.get rationale and remove the inaccurate claim.

The six-line comment repeats the metadata that follows it. The statement that a panel can “only ever render static markup” is too broad because workspace.readContext, terminal.sendText, and notifications.show are already panel-callable. Replace it with one concise sentence that states the non-obvious contract: panels may read plugin-private worker state, while storage writes remain worker-only.

Proposed comment
-    // Why panel-callable: a panel currently has no way to read ANY state its own worker computed,
-    // so a plugin panel can only ever render static markup. This is the narrowest possible fix —
-    // read-only, plugin-private scope, already gated on the `storage` capability, and strictly
-    // less powerful than `terminal.sendText`, which panels may already call and which mutates a
-    // terminal. Writes (`storage.set`/`delete`) deliberately stay worker-only, so a panel can
-    // observe state but never author it.
+    // Panels may read plugin-private worker state; storage writes remain worker-only.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 905ba6c1-8bb6-4f5f-b91d-6a9ce87556bc

📥 Commits

Reviewing files that changed from the base of the PR and between 4e058d4 and 1c9fef6.

📒 Files selected for processing (3)
  • src/main/plugins/plugin-host-conformance.test.ts
  • src/shared/plugins/plugin-host-api.ts
  • src/shared/plugins/plugin-panel-storage-read.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +7 to +10
it('storage.get is callable from a panel, so a panel can render live state', () => {
expect(isPluginPanelAction('storage.get')).toBe(true)
expect(byName('storage.get')?.panel).toBe(true)
})

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- candidate files ---'
git ls-files | rg 'plugin-panel-storage-read\.test|plugin.*panel|panel.*runtime|capability|storage'
printf '%s\n' '--- test file outline ---'
ast-grep outline src/shared/plugins/plugin-panel-storage-read.test.ts
printf '%s\n' '--- test file ---'
cat -n src/shared/plugins/plugin-panel-storage-read.test.ts
printf '%s\n' '--- relevant symbols ---'
rg -n -S 'isPluginPanelAction|gatePluginHostCall|storage\.get|plugin-private|capability' src test tests 2>/dev/null | head -n 300

Repository: stablyai/orca

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- plugin source files ---'
git ls-files 'src/shared/plugins/*' 'src/main/plugins/*' 'src/preload/api/plugin-host-api.ts' | sort
printf '%s\n' '--- API and gate definitions ---'
rg -n -S 'PLUGIN_HOST_API_V0|isPluginPanelAction|gatePluginHostCall|storage\.get|plugin-private|panel' \
  src/shared/plugins src/preload/api/plugin-host-api.ts src/main/plugins \
  -g '*.ts' -g '*.tsx' | head -n 400
printf '%s\n' '--- candidate test outlines ---'
for f in src/shared/plugins/plugin-panel-call-admission.test.ts \
         src/shared/plugins/plugin-panel-bridge.test.ts \
         src/shared/plugins/plugin-panel-shell.test.ts \
         src/main/plugins/plugin-panel-controller.test.ts \
         src/main/plugins/plugin-storage-store.test.ts; do
  if [ -f "$f" ]; then
    echo "### $f"
    ast-grep outline "$f"
  fi
done

Repository: stablyai/orca

Length of output: 42166


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- capability gate ---'
cat -n src/shared/plugins/plugin-capability-gate.ts
printf '%s\n' '--- host method dispatch ---'
cat -n src/main/plugins/plugin-host-methods.ts
printf '%s\n' '--- storage binding ---'
sed -n '90,135p' src/main/plugins/plugin-host-method-bindings.ts
printf '%s\n' '--- conformance tests: setup and storage cases ---'
sed -n '1,230p' src/main/plugins/plugin-host-conformance.test.ts
sed -n '300,370p' src/main/plugins/plugin-host-conformance.test.ts
printf '%s\n' '--- service dispatch ---'
sed -n '235,285p' src/main/plugins/plugin-service.ts
printf '%s\n' '--- storage store tests ---'
cat -n src/main/plugins/plugin-storage-store.test.ts

Repository: stablyai/orca

Length of output: 24994


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
api = Path('src/shared/plugins/plugin-host-api.ts').read_text()
conformance = Path('src/main/plugins/plugin-host-conformance.test.ts').read_text()
gate = Path('src/shared/plugins/plugin-capability-gate.ts').read_text()

checks = {
    'storage_get_is_panel_callable_in_api': "'storage.get'" in api and "name: 'storage.get'" in api and "panel: true" in api[api.index("name: 'storage.get'"):api.index("name: 'storage.get'") + 500],
    'conformance_sends_each_method_through_both_adapters': "Object.values(createAdapters(resolvePolicy)).map" in conformance,
    'conformance_uses_spec_panel_flag': "}, spec.panel)" in conformance,
    'conformance_has_storage_get_success_params': "'storage.get': { key: 'alpha' }" in conformance,
    'conformance_storage_success_uses_storage_capability': "const policy = createPolicy([spec.capability])" in conformance,
    'conformance_has_storage_get_denial_case': "request: { method: 'storage.get'" in conformance and "code: 'capability_denied'" in conformance,
    'gate_checks_declared_spec_capability': "subject.grantedCapabilities.includes(spec.capability)" in gate,
}
for name, result in checks.items():
    print(f"{name}={result}")
PY
printf '%s\n' '--- exact denial cases ---'
sed -n '165,245p' src/main/plugins/plugin-host-conformance.test.ts
printf '%s\n' '--- API storage spec ---'
sed -n '120,180p' src/shared/plugins/plugin-host-api.ts
printf '%s\n' '--- adapter path ---'
cat -n src/main/plugins/plugin-host-call-adapter.ts

Repository: stablyai/orca

Length of output: 7424


Add storage-specific panel conformance cases.

The conformance harness already dispatches storage.get through both transports, but it does not assert the returned plugin-private value or deny a panel call without storage. Seed plugin-private state, assert the panel read result, and assert capability_denied without the grant. Keep the metadata assertions as contract tests.

YoraiLevi pushed a commit to YoraiLevi/2026-08-orca-plugin-tts-archived that referenced this pull request Aug 21, 2026
…2 decisions

HANDOFF said M13 was blocked on stablyai/orca#15643. That was wrong: the block is on
display, not on control, and control works today via terminal.sendText. Corrected in
place rather than quietly, because a future agent reading the old line would schedule
behind an upstream PR with no maintainer engagement.

Adds the three newer upstream items, records the eight decisions the design round
locked, and moves the settled entries out of "Open decisions" into their own section.

The one new open decision is the one no single design could see: three documents now
write into the same audio stream and none of them summed the total.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JRAHyqLuabxR8qsFguBaHk
@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

This branch has not been deployed

No deployments
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.

2 participants