-
-
Notifications
You must be signed in to change notification settings - Fork 73
fix(tmux): add config options to prevent OSC response leak into Neovim buffer #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2cd066e to
1682b9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to fix an issue where launching opencode with tmux's allow-passthrough on configuration causes OSC 1337 responses (=31337;OK) to leak into the Neovim buffer. The fix proposes adding configuration options to allow users to choose between two workarounds: disabling passthrough on the opencode pane or focusing the pane on creation.
Changes:
- Adds logic to disable
allow-passthroughon the opencode tmux pane after creation - Updates the
split-windowcommand to handle missingself.opts.optionssafely withor ""
Comments suppressed due to low confidence (4)
lua/opencode/provider/tmux.lua:81
- The PR description mentions config options
focusanddisable_passthroughthat should control the behavior, but the current implementation unconditionally disables passthrough without checking any configuration. According to the description, users should be able to configure this behavior withprovider.tmux.disable_passthrough(default: true) andprovider.tmux.focus(default: false). The implementation should respect these config options rather than always disabling passthrough.
---Start `opencode` in pane.
function Tmux:start()
lua/opencode/provider/tmux.lua:81
- This check for non-empty pane_id is insufficient. The vim.fn.system call can return error messages or other text besides just the pane ID. Consider checking the exit code of the tmux command and verifying the pane_id format matches tmux's pane ID pattern (e.g., %number). Currently, any non-empty output will pass this check, potentially causing the subsequent tmux set-option command to fail silently or target the wrong pane.
---Start `opencode` in pane.
function Tmux:start()
lua/opencode/provider/tmux.lua:78
- The PR description indicates that users should be able to choose whether to focus the new pane via a
focusconfig option (default: false). However, the code always uses the-dflag which prevents focus. To support thefocusoption, the code should conditionally include the-dflag only when focus is false (or when the option is not set, given the default is false). Whenfocusis true, the-dflag should be omitted so the new pane receives focus immediately, allowing opencode to consume the OSC response.
end
lua/opencode/provider/tmux.lua:78
- The result from vim.fn.system should be trimmed and stored before being used. Currently, self.pane_id may contain trailing newlines or whitespace from the tmux command output, which is only trimmed in the subsequent command. This could cause issues if self.pane_id is used elsewhere. Consider assigning the trimmed result immediately:
self.pane_id = vim.trim(vim.fn.system(...))
end
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
is the opencode TUI still able to receive the response and figure out the terminal capabilities if we disable tmux passthrough? |
|
Sort of, The main limitations of having it off in the opencode pane are:
And this is all bound to only the opencode pane. Most users wouldn't notice anything different, and those that do (e.g. make use of terminal clipboards) can turn it off and use the other workaround. |
|
This is why I think it should be a config option, not forced. |
agreed! I've closed my initial PR since yours supersedes it |
Add config options for creating a split in tmux:
Details
When tmux has
allow-passthrough onconfigured, launching opencode writes=31337;OKto the buffer (an iTerm2 OSC 1337 response).Caused by opencode TUI querying terminal capabilities on startup with nvim pane still in focus.
#143 also aims to address this issue via auto-focus, so opencode eats the OSC response as its meant to.
Some users may prefer keeping the launch in the background, others may require allow-passthrough in the opencode pane. So, I propose making your choice of workaround a config option.
I make
disable_passthrough = trueby default though since this is the less invasive workaround and most users won't notice the difference anyway.