Skip to content

feat(tui): add input.intercept API for plugin keydown interception#25666

Closed
rsdrahat wants to merge 1 commit into
anomalyco:devfrom
rsdrahat:feat/plugin-input-intercept
Closed

feat(tui): add input.intercept API for plugin keydown interception#25666
rsdrahat wants to merge 1 commit into
anomalyco:devfrom
rsdrahat:feat/plugin-input-intercept

Conversation

@rsdrahat

@rsdrahat rsdrahat commented May 4, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #1764

Type of change

  • New feature

What does this PR do?

Adds an input.intercept hook to the TUI plugin API, enabling plugins to intercept keystrokes in the prompt input before default handling runs.

This is the foundational API needed to implement vim mode, macro recording, and custom keybinding plugins — without requiring changes to core. The approach uses a simple module-level handler registry. Handlers run in registration order; the first handler returning truthy consumes the key event.

How did you verify your code works?

  • Typecheck passes for all 19 packages in the monorepo
  • All 20 existing plugin unit tests pass (bun test test/cli/tui/plugin*.test.ts)
  • Manual inspection of the dispatch flow: interceptors fire before any other onKeyDown logic

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Enables plugins to intercept keystrokes in the prompt input before
default handling runs. This is the foundational API hook needed for
vim mode, macro recording, and custom keybinding plugins.

- Add intercept.ts shared module with register/dispatch
- Dispatch interceptors in prompt component onKeyDown (before all
  other handling); a handler returning truthy consumes the event
- Expose input.intercept() on TuiPluginApi
- Add TuiInputInterceptHandler type (ParsedKey + TextareaRenderable)
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR:

This PR may be related because it addresses vim mode functionality in the prompt input, which is mentioned in PR #25666 as one of the use cases for the new input.intercept API. However, this appears to be a different implementation approach rather than a duplicate — PR #25666 introduces the foundational API that could enable such features, while PR #12679 seems to implement vim motions directly.

No other duplicate PRs found addressing the exact same input.intercept API feature.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: vim motions in input box

1 participant