Feature: Allow external process to set and/or query TUI's active session #885

Closed
opened 2026-02-16 17:28:40 -05:00 by yindo · 6 comments
Owner

Originally created by @nickjvandyke on GitHub (Jul 23, 2025).

Originally assigned to: @thdxr on GitHub.

Thanks for all your great work on both the TUI and server! I recently hooked up https://github.com/NickvanDyke/opencode.nvim to the latter. It works great, but I still use the TUI for simplicity and consistency, and only use Neovim to conveniently input (editor-aware) prompts.

However I have a couple awkward/inconvenient scenarios:

  1. When I switch the TUI's active session, I need to send a message there for my plugin to consider it the "active" session - it can only check session.time.updated from the server's /session.
  2. My plugin can send a message to an arbitrary session, or even create one, but I still have to manually select the session in the TUI.

I would love if the TUI or server exposed a way to to query the active session (addresses 1) and set the active session (addresses 2). Or any other solution you might have better context on.

I understand if this is out of scope of the TUI or server's responsibilities, but I thought I'd ask.

Thanks!

Originally created by @nickjvandyke on GitHub (Jul 23, 2025). Originally assigned to: @thdxr on GitHub. Thanks for all your great work on both the TUI and server! I recently hooked up https://github.com/NickvanDyke/opencode.nvim to the latter. It works great, but I still use the TUI for simplicity and consistency, and only use Neovim to conveniently input (editor-aware) prompts. However I have a couple awkward/inconvenient scenarios: 1. When I switch the TUI's active session, I need to send a message there for my plugin to consider it the "active" session - it can only check `session.time.updated` from the server's `/session`. 2. My plugin can send a message to an arbitrary session, or even create one, but I still have to manually select the session in the TUI. I would love if the TUI or server exposed a way to to query the active session (addresses 1) and set the active session (addresses 2). Or any other solution you might have better context on. I understand if this is out of scope of the TUI or server's responsibilities, but I thought I'd ask. Thanks!
yindo closed this issue 2026-02-16 17:28:40 -05:00
Author
Owner

@thdxr commented on GitHub (Jul 24, 2025):

we started exposing apis to control and query the tui - you can take a look at server.ts and tui.go where it handles the reqs

@thdxr commented on GitHub (Jul 24, 2025): we started exposing apis to control and query the tui - you can take a look at server.ts and tui.go where it handles the reqs
Author
Owner

@nickjvandyke commented on GitHub (Jul 25, 2025):

Thanks, that simplifies much of my code too!

I see it's a WIP - do you have plans to add a new endpoint or an option to /tui/append-prompt etc that sends the prompt? I tried \n and \r in my prompt and that was used literally. That should be all I need for now 😀

@nickjvandyke commented on GitHub (Jul 25, 2025): Thanks, that simplifies much of my code too! I see it's a WIP - do you have plans to add a new endpoint or an option to `/tui/append-prompt` etc that sends the prompt? I tried `\n` and `\r` in my prompt and that was used literally. That should be all I need for now 😀
Author
Owner

@adamdotdevin commented on GitHub (Jul 31, 2025):

Thanks, that simplifies much of my code too!

I see it's a WIP - do you have plans to add a new endpoint or an option to /tui/append-prompt etc that sends the prompt? I tried \n and \r in my prompt and that was used literally. That should be all I need for now 😀

i'll add this as a new api endpoint. also, as an aside, forgot to tell you that i added OPENCODE_THEME as an env you can pass to override the theme.

@adamdotdevin commented on GitHub (Jul 31, 2025): > Thanks, that simplifies much of my code too! > > I see it's a WIP - do you have plans to add a new endpoint or an option to `/tui/append-prompt` etc that sends the prompt? I tried `\n` and `\r` in my prompt and that was used literally. That should be all I need for now 😀 i'll add this as a new api endpoint. also, as an aside, forgot to tell you that i added OPENCODE_THEME as an env you can pass to override the theme.
Author
Owner

@nickjvandyke commented on GitHub (Aug 1, 2025):

It works great, thank you!!

@nickjvandyke commented on GitHub (Aug 1, 2025): It works great, thank you!!
Author
Owner

@adamdotdevin commented on GitHub (Aug 1, 2025):

It works great, thank you!!

you saw the new tui APIs i exposed yesterday i guess? were there any other APIs you needed? also, are you in the discord?

@adamdotdevin commented on GitHub (Aug 1, 2025): > It works great, thank you!! you saw the new tui APIs i exposed yesterday i guess? were there any other APIs you needed? also, are you in the discord?
Author
Owner

@nickjvandyke commented on GitHub (Aug 1, 2025):

Yeah I stalked the release notes 😀

were there any other APIs you needed?

Thanks for asking. The one thing "missing" now is I can't know when opencode has finished responding - POSTing a message to the session would respond after processing, whereas submit-prompt responds immediately. I used that to reload the buffer at the ideal time in case edits were made, and had ideas for a statusline integration (like a spinner) in case users have opencode open in another tab/space. I also saw e.g. another user likes to trigger a ding sound when claudecode.nvim finishes processing which seems neat, and it'd enable such customization.

Although that's pretty minor and I'm sure you have endless tasks. If it fits in somewhere then let me know, but I'm very satisfied atm 🙂 If I get any other "unsupported" ideas I'll open a new issue.

are you in the discord?

I am now! @nickteezy, feel free to reach out with anything.

@nickjvandyke commented on GitHub (Aug 1, 2025): Yeah I stalked the release notes 😀 > were there any other APIs you needed? Thanks for asking. The one thing "missing" now is I can't know when `opencode` has finished responding - POSTing a message to the session would respond after processing, whereas `submit-prompt` responds immediately. I used that to [reload](https://github.com/NickvanDyke/opencode.nvim/blob/main/lua/opencode/reload.lua) the buffer at the ideal time in case edits were made, and had ideas for a statusline integration (like a spinner) in case users have `opencode` open in another tab/space. I also saw e.g. another user likes to trigger a ding sound when claudecode.nvim finishes processing which seems neat, and it'd enable such customization. Although that's pretty minor and I'm sure you have endless tasks. If it fits in somewhere then let me know, but I'm very satisfied atm 🙂 If I get any other "unsupported" ideas I'll open a new issue. > are you in the discord? I am now! `@nickteezy`, feel free to reach out with anything.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#885