Skip to content

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

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

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
Copy link
Copy Markdown

@rsdrahat rsdrahat commented May 4, 2026

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

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.

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.

[FEATURE]: vim motions in input box

1 participant