feat(cli): add CSI-u key forwarding for modified special keys (e.g. <S-CR>) - #337
Open
S1M0N38 wants to merge 2 commits into
Open
feat(cli): add CSI-u key forwarding for modified special keys (e.g. <S-CR>)#337S1M0N38 wants to merge 2 commits into
S1M0N38 wants to merge 2 commits into
Conversation
…s CSI-u. Enable with cli.win.csiu
There was a problem hiding this comment.
Pull request overview
Adds an opt-in cli.win.csiu configuration to forward modified special keys (e.g. <S-CR>) to agent CLIs using CSI-u escape sequences, and ensures tmux sessions spawned by Sidekick can pass CSI-u through when enabled.
Changes:
- Introduces
cli.win.csiuconfig flag and injects default CSI-u keymaps intocli.win.keyswhen enabled. - Adds tmux session option injection (
extended-keys,extended-keys-format csi-u) gated bycli.win.csiu. - Adds a dedicated CSI-u module plus test coverage for keymap bytes, tmux option segments, and config keymap injection behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/csiu_spec.lua | New tests covering CSI-u byte sequences, tmux option injection, and config-driven keymap injection. |
| lua/sidekick/config.lua | Adds cli.win.csiu option + injects CSI-u default keymaps during Config.setup(). |
| lua/sidekick/cli/session/tmux.lua | Adds M.options() to append tmux extended-keys options when CSI-u is enabled. |
| lua/sidekick/cli/csiu.lua | New module defining default CSI-u forwarding keymaps and their terminal-job send behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+95
to
+105
| local orig_schedule | ||
|
|
||
| before_each(function() | ||
| orig_schedule = vim.schedule | ||
| vim.schedule = function() end | ||
| end) | ||
|
|
||
| after_each(function() | ||
| Config.setup({}) -- restore defaults (schedule still suppressed) | ||
| vim.schedule = orig_schedule | ||
| end) |
1 task
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.
Description
Introduce a bool flag in
cli.win.csiuto force csi-u escape sequences. After testing across various envs I found out that explicitly forcing csi-u whencli.mux.backend="tmux". I had this setup working in Wezterm with some custom config (see discussion 295). When using Ghostty close to no config is required (on mac os you have to forcealtto behave as meta key e.g.macos-option-as-alt = left).I've tested this new option with the following coding agents running lazyvim with sidekick extra enabled in ghostty terminal emulator (not inside a tmux session - the only tmux session are the ones spawned by sidekick.nvim)
agy(by Google - gemini-cli was discontinued for non-enterprise users) ✅claude code(by Anthropic) ✅pi(by earendil-works) ✅codex(by OpenAI) ✅copilot(by GitHub) ✅opencode(by Anomalyco) ✅agent(by Cursor) ❌The agent CLI by cursor in not really optimized for tmux, from their docs:
Configuration
The config that I've use was the following
Related Issue(s)
No issue. Just a workaround in discussions #295
Additional Notes
The code in this PR was generated with AI, tested manually and iteratively refined. I think this issue regarding escape seq between various layers of the stack can be somewhat hard to for a user to debug (keyboard -> terminal emulator -> nvim terminal -> tmux -> coding agent). Maybe having the option to enabled the usage of CSI-u could beneficial.
I think that the failure point is when the nvim terminal emulator try to interpret the escape sequence and it's not related to sidekick.nvim specifically. Maybe this issue will be solved if/when
libghostty-vtwill replace the currentvterm(hopefully to be more spec-comply).If this PR is out of the scope of this project, feel free to close this PR without additional comments.