Skip to content

Conversation

@nkabbara
Copy link
Contributor

@nkabbara nkabbara commented Jan 19, 2026

Re: #123. One way to check this out is to open the main select dialogue and pick the select session command.

@nkabbara nkabbara changed the title feat(sessions): select sessions Re: #123 feat(sessions): select session Re: #123 Jan 19, 2026
@nkabbara nkabbara changed the title feat(sessions): select session Re: #123 feat(sessions): select session Jan 19, 2026
@nkabbara nkabbara changed the title feat(sessions): select session feat(sessions): select session Jan 19, 2026
@NickvanDyke NickvanDyke requested a review from Copilot January 20, 2026 15:03
Copy link

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 PR adds functionality to select and switch between existing OpenCode sessions through the UI.

Changes:

  • Adds a new select_session UI component that fetches and displays sessions
  • Integrates session selection into the command menu
  • Adds API client methods for retrieving and selecting sessions

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lua/opencode/ui/select_session.lua New module implementing session selection UI with sorting and formatting
lua/opencode/ui/select.lua Adds special handling for the "session.select" command
lua/opencode/config.lua Registers "session.select" in the commands configuration
lua/opencode/cli/client.lua Adds get_sessions and select_session API methods
lua/opencode.lua Exports the select_session function in the main module

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

@nkabbara
Copy link
Contributor Author

nkabbara commented Jan 24, 2026

Hey @NickvanDyke!

What do you think about this? Any suggestions?

@NickvanDyke
Copy link
Owner

Sorry just been busy! LGTM, thanks for slotting it in so nicely to the surrounding code + patterns!

I'm generally trying to avoid re-implementing TUI features to keep the plugin simple and reliable for both me and users. I'll accept this because the implementation is good and simple, and hopefully opencode doesn't make many breaking changes to this. But if you plan to add more TUI session features, it may be worth discussing first 🙂

Comment on lines 15 to 26
for _, session in ipairs(session_data.sessions) do
---@type opencode.cli.client.Session
local item = {
id = session.id,
title = session.title,
time = {
created_ms = math.floor(session.time.created),
updated_ms = math.floor(session.time.updated),
},
}
table.insert(sessions, item)
end
Copy link
Owner

Choose a reason for hiding this comment

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

Should this mapping happen in client#get_sessions? I could be misunderstanding but its return type seems a bit misleading right now. It claims to return session.time.created_ms/updated_ms, but I see here - outside it - that we're mapping its session.time.created/updated to those fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept client#get_sessions in the same spirit as the other functions in that file, ie thin wrappers over the curl call. Here session.time.created and session.time.updated are data from opencode, so in milliseconds. We assign them to our _ms versions which are more explicit.

Copy link
Owner

Choose a reason for hiding this comment

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

That makes sense, but the callback passes opencode's data, but is typed as though it passes the _ms versions.

I'm okay to just use the opencode data directly too. We can remove the _ms suffix and just add it as a docstring comment on the field instead. Then no mapping necessary. Unless the math.floor is important?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed a change, is that what you're thinking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remember correctly I used math.floor to convert them to int so not to depend on coercion. But can do that at location of division as well if it's necessary.

Copy link
Owner

@NickvanDyke NickvanDyke Jan 24, 2026

Choose a reason for hiding this comment

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

That's in the right direction! I guess I don't understand what this loop is doing? session_data.sessions is already opencode.cli.client.Session[]. So I don't understand the need for the loop that maps each element to a opencode.cli.client.Session and adds it to sessions. It seems to me we could just use session_data.sessions directly?

Copy link
Contributor Author

@nkabbara nkabbara Jan 24, 2026

Choose a reason for hiding this comment

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

Yeah it doesn't make sense now. It stayed as part of my previous thinking of mapping to a local type. Fixed, but doing some manual testing.

@nkabbara
Copy link
Contributor Author

Sorry just been busy! LGTM, thanks for slotting it in so nicely to the surrounding code + patterns!

I'm generally trying to avoid re-implementing TUI features to keep the plugin simple and reliable for both me and users. I'll accept this because the implementation is good and simple, and hopefully opencode doesn't make many breaking changes to this. But if you plan to add more TUI session features, it may be worth discussing first 🙂

Thanks for the kind words, appreciate it.

Makes sense. Do you have a roadmap on where you see this going as far as how it will interact with opencode? The tui keeps adding ui features which will make the plugin harder to use if we don't implement them somehow. For example it's now starting to ask clarifying questions 😅 .

Screenshot 2026-01-24 at 13 59 48

@NickvanDyke
Copy link
Owner

NickvanDyke commented Jan 24, 2026

The plugin's first priority is enabling functionality that's not possible in the TUI. Supplementing your editor workflow with AI, rather than replace it. Like injecting editor context. Neovim implementations of TUI features are nice, but it's impossible for me to keep up with opencode's pace. As your example demonstrates. They're a paid team, and I'm a single unpaid maintainer 😅

Maintenance aside, I also want to keep things simple for users. Sometimes less is more. Maybe this is just me, but I found it overwhelming to try so many new AI tools. They all have their own way to do things. With opencode.nvim, I wanted it to be like "use opencode how you already know, plus these useful new things." Not confuse users with a second way to do something they already know how to do in opencode.

Obviously there are exceptions. Like opencode.nvim can call opencode commands. But the complexity there is relatively low for the convenience and integration it enables. That tradeoff between complexity and power is the main thing I consider for "duplicative" features. While I appreciate any and all effort, I can't accept every contribution or suggestion because it would both dilute the plugin's purpose and overwhelm me, harming the quality of the plugin's core features.

This is my experience in open source thus far, at least 🙂 I would love to create the best editor experience possible (in Neovim and others), but it's only realistic as a paid member of the opencode team or something.

@nkabbara
Copy link
Contributor Author

This is my experience in open source thus far, at least 🙂 I would love to create the best editor experience possible (in Neovim and others), but it's only realistic as a paid member of the opencode team or something.

Yeah, totally makes sense. How's your current workflow when something like the above happens? Do you ctrl-w to the opencode split and make the selection then go back to editing?

@NickvanDyke
Copy link
Owner

How's your current workflow when something like the above happens? Do you ctrl-w to the opencode split and make the selection then go back to editing?

I don't think I'm on the opencode version with that feature yet haha, but yes, generally switching to the opencode window and using their UI is the default "solution." I hoped the permission dialog would be a good general-purpose solution to such blocking events, but it seems they have sidestepped or enhanced that model.

@nkabbara
Copy link
Contributor Author

How's your current workflow when something like the above happens? Do you ctrl-w to the opencode split and make the selection then go back to editing?

I don't think I'm on the opencode version with that feature yet haha, but yes, generally switching to the opencode window and using their UI is the default "solution." I hoped the permission dialog would be a good general-purpose solution to such blocking events, but it seems they have sidestepped or enhanced that model.

I'm also curious about the opencode devs' workflow since they use vim.

@NickvanDyke
Copy link
Owner

NickvanDyke commented Jan 24, 2026

Interesting, I didn't know that! While they've nicely supported the APIs this plugin needs, they haven't interacted with it much otherwise. So I guess they prefer to use opencode in isolation? I suppose that gives a more accurate dogfooding perspective too.

@NickvanDyke
Copy link
Owner

Code looks and functions well! Tyvm for the discussion and iteration 🙂 ❤️

@NickvanDyke NickvanDyke merged commit 0f85a44 into NickvanDyke:main Jan 24, 2026
2 checks passed
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