Repository navigation
feat: open the panel from outside the TUI over plugin RPC - #18
Merged
Merged
Conversation
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`.
|
Beta prerelease published: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The panel is unreachable from outside.
panel.openis client-side, and clients cannot publish events —GET /api/eventis 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:.(new)media.open/media.close, emitsopen/close. No state../tuiopen()as/mediaopencode api POST /api/rpc/media/open -d '{"source":"/tmp/clip.mp4"}' opencode api POST /api/rpc/media/closeScope decision
Opening is restricted to the session you are viewing.
panel.openis 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 checkgreen: typecheck, biome, markdownlint, build, 24 tests. Exports are.,./tui,./rpc.Caveats
client.rpc(Media).open({ source }).