feat(tmux): add fallback server discovery for split panes #150
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.
Adds fallback discovery logic for opencode sessions active in a tmux sibling pane but not matching CWD.
For tmux users, it is reasonable to assume that if they have a split open with opencode and fire off a prompt from nvim, they likely intend it to go to that instance in the split whether it matches the CWD discovery logic or not. Overall, makes it much more intuitive where your prompt will end up, and avoids unnecessarily launching new sessions.
Implemented as a fallback, so if there is a different session that does get discovered we still connect to that as normal. When there are multiple splits running opencode and none share CWD, it just picks the first one it finds. And then if there are no opencode instances in splits, use the normal logic of launching and connecting via the plugin.
Currently only affects tmux users, but implemented such that any provider can implement a
find_serverfunction to attempt another discovery before failing.Relation to #119
This is complementary to #119 but solves a different problem:
self.pane_id.self.pane_idis nil andget_port()returns nil.This PR searches all sibling panes in the current tmux window via TTY, regardless of whether the provider started them.
Changes
lua/opencode/cli/server.lua: Use provider'sfind_server()as fallback when CWD matching failslua/opencode/provider/tmux.lua: Addfind_server()method that discovers opencode in sibling tmux paneslua/opencode/provider/init.lua: Document the newfind_serverfield in the Provider interface