feat: pre_keys/post_keys support for keystroke injection#20
Merged
MSmaili merged 5 commits intoMSmaili:mainfrom Apr 1, 2026
Merged
feat: pre_keys/post_keys support for keystroke injection#20MSmaili merged 5 commits intoMSmaili:mainfrom
MSmaili merged 5 commits intoMSmaili:mainfrom
Conversation
Allow sending keystrokes before and after pasting text to tmux targets. Useful for TUI apps that need e.g. C-c to cancel input or i/Escape for vim-mode editors. - Add pre_keys/post_keys to SendItem and ActionConfig (string|string[]) - Wire through do_send() → backend.send() with correct batch ordering - Item-level keys override opts-level as fallback - Add tests and documentation
Collapse 6 positional parameters into a single send_opts table for
readability. Build backend_opts via tbl_extend to add focus.
- do_send(expanded, opts, send_opts) instead of 6 args
- Callers build { submit, title, pre_keys, post_keys } at call site
- No behavioral change
Contributor
Author
|
There is probably the same problem that was resolved in #15. It appears when I try to replace I'll check this later and adjust my implementation to the solution provided in that issue. |
post_keys suffered the same race condition as submit (issue MSmaili#15) — keystrokes arrived in the same tmux batch as paste, before the TUI processed the text. - Move post_keys from main batch to deferred execution (300ms delay) - Unify submit and post_keys into _send_deferred() for single-point change - Deferred order per target: post_keys -> Enter (if submit) - Update tests to verify post_keys arrives in deferred batch, not main
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.
Closes #17
What
Adds
pre_keysandpost_keysfields toSendItemand action-level config. This allows sending keystrokes before/after pasting text to tmux targets - useful for TUI apps that need state preparation (e.g.ifor vim insert mode,C-cto cancel current input).Usage example
Status
This is a first working prototype - pushed so it's available for testing and review. I'll be validating this further on my side.
Open to feedback and suggestions on the approach.