Skip to content

Clean exit for tmux provider#178

Merged
nickjvandyke merged 3 commits intonickjvandyke:mainfrom
uudashr:tmux-clean-exit
Feb 19, 2026
Merged

Clean exit for tmux provider#178
nickjvandyke merged 3 commits intonickjvandyke:mainfrom
uudashr:tmux-clean-exit

Conversation

@uudashr
Copy link
Copy Markdown
Contributor

@uudashr uudashr commented Feb 19, 2026

Description

To have clean exit when using tmux as provider, as mentioned here

Explicitly stop opencode via Ctrl-C in its TUI, and/or run it outside Neovim so it doesn't orphan every time you exit Neovim.

Related Issue(s)

Screenshots/Videos

n/a

Copilot AI review requested due to automatic review settings February 19, 2026 04:48
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 pull request addresses the issue of orphaned opencode processes when using the tmux provider by implementing graceful shutdown via Ctrl-C signal instead of forcefully killing the tmux pane.

Changes:

  • Modified tmux provider to send SIGINT (Ctrl-C) for clean process termination
  • Improved pane_id handling by trimming whitespace at storage time rather than usage time

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +111 to 112
vim.fn.system("tmux send-keys -t " .. pane_id .. " C-c")
self.pane_id = nil
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending C-c allows opencode to exit gracefully, but the tmux pane remains open afterward. When using toggle() to stop opencode, users will have an empty pane that needs manual cleanup. Consider either: (1) documenting this behavior, (2) adding a delayed kill-pane command, or (3) checking if the process exited before clearing pane_id to allow restart attempts to reuse the pane if the process is still running.

Copilot uses AI. Check for mistakes.
@nickjvandyke
Copy link
Copy Markdown
Owner

Ah good thinking, this is a very clean workaround! Thank you!

I tried this with the snacks provider just now, but I guess the embedded terminal closes before opencode can handle the Ctrl-C, or something 😞 Whereas the delay doesn't matter for tmux because it's outside Neovim.

@nickjvandyke nickjvandyke merged commit 93ad519 into nickjvandyke:main Feb 19, 2026
2 checks passed
nickjvandyke pushed a commit that referenced this pull request Feb 19, 2026
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.

bug: provider's opencode process orphans when stopping

3 participants