Skip to content

allow terminal setup to preserve backend focus#234

Closed
nkabbara wants to merge 3 commits intonickjvandyke:mainfrom
nkabbara:feature/switch-window-option
Closed

allow terminal setup to preserve backend focus#234
nkabbara wants to merge 3 commits intonickjvandyke:mainfrom
nkabbara:feature/switch-window-option

Conversation

@nkabbara
Copy link
Copy Markdown
Contributor

@nkabbara nkabbara commented Apr 15, 2026

Hey @nickjvandyke!

I started customizing the plugin to open in a float as I am improving my workflow with ai. I noticed that I could not set the cursor to stay in my newly opened float because of the setup method. Do you mind if we made it configurable to do so?

Summary

  • add an optional restore_focus flag to opencode.terminal.setup() while keeping the current behavior as the default
  • let custom terminal integrations preserve their own focus behavior by calling setup(win, { restore_focus = false })
  • update the README snacks.terminal example to show how to opt out of the forced focus restore

Why

Custom terminal backends may want to control whether focus stays in the terminal or returns to the previous window. The current setup() helper always restores focus as part of its redraw workaround, which makes it hard for custom integrations to keep the terminal focused.

@nickjvandyke
Copy link
Copy Markdown
Owner

Thanks for calling this out! I pushed a change just now that moves the redraw workaround to only our terminal implementation, because it seems unnecessary for snacks.terminal. Hopefully that holds true for other terminal integrations too? Let me know if that works for you.

@nkabbara
Copy link
Copy Markdown
Contributor Author

Thanks for calling this out! I pushed a change just now that moves the redraw workaround to only our terminal implementation, because it seems unnecessary for snacks.terminal. Hopefully that holds true for other terminal integrations too? Let me know if that works for you.

Just saw this. Trying.

@nkabbara
Copy link
Copy Markdown
Contributor Author

Thanks for calling this out! I pushed a change just now that moves the redraw workaround to only our terminal implementation, because it seems unnecessary for snacks.terminal. Hopefully that holds true for other terminal integrations too? Let me know if that works for you.

Works great! Thanks!

@nkabbara nkabbara closed this Apr 15, 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.

3 participants