Skip to content

feat: open the panel from outside the TUI over plugin RPC - #18

Merged
nabheet merged 1 commit into
mainfrom
feat/request-open
Nov 20, 2026
Merged

nabheet merged 1 commit into
mainfrom
feat/request-open

Conversation

@nabheet

@nabheet nabheet commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Problem

The panel is unreachable from outside. panel.open is client-side, and clients cannot publish events — GET /api/event is subscribe-only, and the enum has no client-callable publisher. Every workaround (config autoplay, watched file, osascript) either opens on every load or needs a keystroke.

Design

A plugin package can ship a server part beside ./tui, and server parts can register RPC (POST /api/rpc/{rpcID}/{method}). So:

Part Runs in Role
. (new) server registers media.open/media.close, emits open/close. No state.
./tui TUI subscribes to those events, calls the same open() as /media
opencode api POST /api/rpc/media/open -d '{"source":"/tmp/clip.mp4"}'
opencode api POST /api/rpc/media/close

Scope decision

Opening is restricted to the session you are viewing. panel.open is session-scoped, so a request cannot appear in another session; nothing is queued for later. That was a deliberate choice over deferring into unseen sessions.

Verification

Standalone instance, local checkout, real keystrokes and a real RPC call: the panel opened and animated (45/48). Self-test hook used during verification, removed before commit (rg MEDIA_RPC dist/ clean).

npm run check green: typecheck, biome, markdownlint, build, 24 tests. Exports are ., ./tui, ./rpc.

Caveats

  • Events are live only: a call while no TUI runs is missed.
  • Requires one restart to load the new server part.
  • Callers that only know the shapes can use client.rpc(Media).open({ source }).

The panel lives in the TUI process, which no client can reach: `panel.open` is
client-side, and the API cannot publish events (GET /api/event is subscribe
only). A server part makes the plugin addressable from outside.

- `src/rpc.ts` defines the portable contract: `open`/`close`, events `open`
  and `close`.
- `src/index.ts` registers it and forwards each call as an event. No state.
- `src/tui.tsx` subscribes over the connection it already holds and calls the
  same `open()` the slash command uses.
- Scoped to the viewed session: nothing is deferred for another session.

Verified end to end on a standalone instance: the call opened the panel and it
animated (45/48). `npm run check` green; exports are `.`, `./tui`, `./rpc`.
@github-actions

Copy link
Copy Markdown

Beta prerelease published: 0.1.0-beta.45. Install with npm i opencode-media-panel@beta.

@nabheet
nabheet merged commit ecb86cd into main Nov 20, 2026
3 checks passed
@nabheet
nabheet deleted the feat/request-open branch November 20, 2026 21:31
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.

1 participant