Skip to content

[FEATURE]: TUI plugin API (v2): a way to take text input, including paste #51392

Open

Description

@Codestz

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

v1's TUI plugin API had keymap.intercept("key", handler), so a plugin could run its own text field: every key before the keymap, with the option to consume it. v2's Keymap has layer, dispatch, shortcuts, commands, pending, active and mode, but no intercept.

Pasting is the harder part: it arrives as a single paste event on the renderer's key input, so a field fed by keys never sees it, and the paste lands in the prompt underneath.

opencode-cockpit works around both by calling prependListener on ctx.renderer.keyInput directly, for keypress and paste. That works, but it depends on OpenTUI internals rather than the plugin API.

Proposal: bring back keymap.intercept(handler, { priority }) on v2, and deliver pastes through it (or through a separate onPaste), with consume() keeping them from the prompt.

Activity

  1. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  2. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed request, @Codestz!

    To restate it: you'd like the v2 TUI plugin API to offer a low-level key interceptor again, like v1's keymap.intercept. Pastes would be delivered through it too, or through a separate paste hook, with a way to consume them so they don't land in the prompt. Then plugins could run their own text fields without reaching into ctx.renderer.keyInput.

    You're right that the v2 plugin Keymap only has layer, dispatch, commands, pending, active and mode. The TUI already uses an intercept internally for some of its own components; it just isn't exposed to plugins. Until then, dialog.prompt() is the only supported way for a plugin to read text, and it's modal, so it won't cover an inline field like cockpit's.

    Maintainers will consider this. Somewhat related paste issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions