Skip to content

[FEATURE]: Add a /delete command to delete the current session #8677

Closed

Description

@frouo

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

The same way we have the /rename session command, I miss a /delete session command that would delete the current session.

Sometimes I start sessions that are not very important, once I got my answer or job done, I just want to delete this session so my session history is clean, only populated with relevant sessions.

This command would be a shortcut for this workflow : /session -> ctrl+d (delete) -> ctrl+d (confirm)

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 15, 2026
  2. github-actions commented on Jan 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. hanazaki05 commented on Jan 28, 2026

    @hanazaki05

    This feature is extremely useful for me, please consider implement

  4. frouo commented on Jan 28, 2026

    @frouo
    Author

    I plan to do it on friday. At least I will try 🙂
    Unless @thdxr you are already working on it?

  5. frouo commented on Jan 28, 2026

    @frouo
    Author

    I managed to find some time tonight and got it working! 🙂

    I've recorded a demo video showing the implementation. Since this is a UI/core feature change, I'm waiting for design review approval before submitting a PR (per CONTRIBUTING.md guidelines).

    Let me know if this approach works for you and I'll open the pull request. Happy to adjust based on feedback.

    delete.session.command.mp4
  6. TheOrdinaryWow commented on Feb 1, 2026

    @TheOrdinaryWow

    I managed to find some time tonight and got it working! 🙂

    I've recorded a demo video showing the implementation. Since this is a UI/core feature change, I'm waiting for design review approval before submitting a PR (per CONTRIBUTING.md guidelines).

    Let me know if this approach works for you and I'll open the pull request. Happy to adjust based on feedback.

    delete.session.command.mp4

    It works!

  7. alberti42 commented on Feb 4, 2026

    @alberti42
    Contributor

    I wrote a zsh plugin implementing the Knight Rider bar of opencode in zsh ZLE prompt (https://github.com/alberti42/Zsh-Opencode-Tab). Now I can use opencode to iteratively construct commands and help me perform difficult tasks on the command line.

    But these single-shot calls to the remote agent leave behind useless sessions. Is there a way to delete them programmatically? The deletion through the backend server works, but requires the backend server to run. Unfortunately, there is a bug (I file a PR #11812) which prevents for the moment to work with the backend from terminal.

    Do you have any tip how to delete old sessions? In my plugin, I have hold of the ses_3d94... id. Thanks!

  8. frouo commented on Feb 4, 2026

    @frouo
    Author

    I wrote a zsh plugin implementing the Knight Rider bar of opencode in zsh ZLE prompt (https://github.com/alberti42/Zsh-Opencode-Tab). Now I can use opencode to iteratively construct commands and help me perform difficult tasks on the command line.

    But these single-shot calls to the remote agent leave behind useless sessions. Is there a way to delete them programmatically? The deletion through the backend server works, but requires the backend server to run. Unfortunately, there is a bug (I file a PR #11812) which prevents for the moment to work with the backend from terminal.

    Do you have any tip how to delete old sessions? In my plugin, I have hold of the ses_3d94... id. Thanks!

    Hello @alberti42, this issue concerns the TUI. In case it helps, here are the 3 lines of code in the PR that delete the current session, using its id.

  9. alberti42 commented on Feb 4, 2026

    @alberti42
    Contributor

    Thanks for the reply @frouo! yes, I took a look, but I am not sure if it is what I needed. I wanted to avoid spinning up another backend server for deleting old sessions.

    In my plugin, people can choose to attach to a backend server (but this does not work until the PR is merged), or to start from terminal with opencode run .. I don't use the TUI. I also wanted to avoid using the SDK approach because my application is not exactly bound to a project / dedicated backend server.

    So I wrote a set of zsh functions that seem robust to me and work for cleaning up old session files when the user cold-started opencode run ... https://github.com/alberti42/Zsh-Opencode-Tab/blob/779b6347cf33e4e092e439d678c5ad6efff50221/src/controller.zsh#L507C1-L562

    If you understand better the mechanics, and know a better approach than mine, I will be grateful for your tip!

  10. arsham commented on Feb 4, 2026

    @arsham

    How do you feel about implementing an ephemeral flag instead of creating sessions and deleting them afterwards?

  11. alberti42 commented on Feb 4, 2026

    @alberti42
    Contributor

    How do you feel about implementing an ephemeral flag instead of creating sessions and deleting them afterwards?

    Yes, this is exactly what I would need. But I am not aware this exists. Someone discussed the idea before #4489 but was it implemented?

  12. frouo commented on Feb 4, 2026

    @frouo
    Author

    How do you feel about implementing an ephemeral flag instead of creating sessions and deleting them afterwards?

    For the TUI. I think that /new /delete covers that use case and is very fast to trigger. Plus we never know, what if the session turns to be interesting and you finally want to keep it; you might regret to have it ephemeral.

    For the CLI, definitely yes. I would need that flag too. My use case is opencode run --command git-commit. A custom command that commits with specific instructions that I launch outside the TUI after I reviewed the diff. Once done I really don't care to keep that session. It pollutes my list of sessions, yes indeed.

  13. alberti42 commented on Feb 5, 2026

    @alberti42
    Contributor

    A custom command that commits with specific instructions that I launch outside the TUI after I reviewed the diff. Once done I really don't care to keep that session. It pollutes my list of sessions, yes indeed.

    Yes, absolutely. This is what I was thinking. I know that opencode primary goal is different, but with minimum effort, it could also become a point of reference / the utility to go for single-shot usages.

    In my plugin, I wanted to avoid directly managing the interaction with the APIs of the different providers because they are not all standard, they might change in the future, and all this would require a lot of maintenance effort.

    opencode run --command git-commit

    Is this a custom extension of yours or I missed that flag --command?

    I am wondering whether I was using the wrong tool for my my plugin. Should I have used Fabric https://github.com/danielmiessler/Fabric ? I did not experiment with it, but it seems to implement the idea of chaining single-shot tasks. Did you try it for your git-commit automation?

  14. frouo commented on Feb 5, 2026

    @frouo
    Author

    Is this a custom extension of yours or I missed that flag --command?

    It's a native flag to run a command (doc).

    I can't help for Fabric and competitors. For the moment I craft my own agents / subagents and skills for my project.

  15. alberti42 commented on Feb 5, 2026

    @alberti42
    Contributor

    I can't help for Fabric and competitors.

    Thanks a lot! It was dumb of me to mention the alternatives. Sorry. I love opencode ❤️

    It's a native flag to run a command (doc).

    Yes, I saw it. But I understood from here that there is no exposed slash command for delete. And also we clearly cannot create a prompt command that does the deletion of the session.

    Not so bad. I am now doing this manually when the user starts the session with a cold start (no server attached). The problem is a different bug in opencode I submitted a PR #11812 to fix it, which prevents people from using attach in CLI and a custom agent. So, this bug forces the users to go for the cold start, and then I need to clean the zombie sessions.

    I think, in the future, I would like to manage more persistent sessions on the terminal. But I need to think about the best workflow. One session per shell? Or to give the user some magic key from the terminal to restart the session? And what to do with those sessions? Always delete them at the end? Or let the user decide? ... I will have to think more about...

  16. github-actions commented on Apr 7, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  17. dmitryplatonov commented on May 3, 2026

    @dmitryplatonov

    This is a basic feature that would be great to have. My sessions are ephemeral, I prefer to have fresh session for new task. If someone can implement /delete (with keybinding like ctrl-x d) and /clear commands it would greatly benefit my workflow.
    I do not think there is a need for confirmation (at least for slash commands), but we might show list of recently closed sessions in session list.
    On another note, opencode session delete runs successfully, but deleted session is still visible in TUI.

  18. frouo commented on May 3, 2026

    @frouo
    Author

    Hello @dmitryplatonov, thank you for your feedback. I implemented it 3 months ago (cf. #11684) but I haven't received any reviews about it so far :(

    I really need this feature too and I don't know how to catch maintainers' attention. It's true there are a lot of PRs awaiting, so I am patiently waiting my turn. IDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions