Skip to content

feat(bot): add /session_delete command with two-stage confirmation flow#101

Open
georgernstgraf wants to merge 4 commits intogrinev:mainfrom
georgernstgraf:feat/session-delete
Open

feat(bot): add /session_delete command with two-stage confirmation flow#101
georgernstgraf wants to merge 4 commits intogrinev:mainfrom
georgernstgraf:feat/session-delete

Conversation

@georgernstgraf
Copy link
Copy Markdown
Contributor

Closes #81

What

Adds a /session_delete command that lets users delete OpenCode sessions directly from Telegram.

Flow

  1. /session_delete → paginated session list as inline keyboard
  2. Click a session → detail view with session info + [Delete] [Cancel]
  3. Delete → calls opencodeClient.session.delete(), clears interaction

If the deleted session is the currently active one, the session state is reset and the user is prompted to use /sessions or /new.

Implementation

  • Follows existing /tasklist command pattern (two-stage custom interaction)
  • Reuses pagination logic from /sessions command
  • Full i18n coverage: en, de, ru, es, fr, zh

Copilot AI review requested due to automatic review settings April 25, 2026 08:35
Copy link
Copy Markdown

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

Adds a new Telegram bot command /session_delete to delete OpenCode sessions via an inline, two-step confirmation UI, with i18n strings added across supported locales.

Changes:

  • Register new /session_delete command and callback handler in the bot router.
  • Implement src/bot/commands/session-delete.ts with paginated session list → details → confirm delete flow.
  • Add i18n keys for the new command and flow messages (en, de, es, fr, ru, zh).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/bot/index.ts Wires /session_delete command + callback dispatch logging/handling.
src/bot/commands/definitions.ts Adds /session_delete to the bot command list for Telegram.
src/bot/commands/session-delete.ts Implements the session deletion interaction flow (list/details/confirm + pagination).
src/i18n/en.ts Adds English strings for the session delete flow.
src/i18n/de.ts Adds German strings for the session delete flow.
src/i18n/es.ts Adds Spanish strings for the session delete flow.
src/i18n/fr.ts Adds French strings for the session delete flow.
src/i18n/ru.ts Adds Russian strings for the session delete flow.
src/i18n/zh.ts Adds Chinese strings for the session delete flow.

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

Comment thread src/bot/commands/session-delete.ts
Comment thread src/bot/commands/session-delete.ts Outdated
Comment thread src/bot/commands/session-delete.ts
Comment thread src/bot/commands/session-delete.ts Outdated
Comment thread src/bot/commands/session-delete.ts
Comment thread src/bot/commands/session-delete.ts Outdated
Comment thread src/bot/commands/session-delete.ts
@georgernstgraf
Copy link
Copy Markdown
Contributor Author

This is a simple implementation. I considered modifying the /sessions command directly, but that would have been more complicated and perhaps less intuitive for the user than this quick solution.

Georg Graf added 3 commits April 25, 2026 15:44
grinev#81)

- Add busy-guard to callback handler
- Full session cleanup when deleting current session (detach, stop events, clear pinned)
- Import from session/manager for consistency
- Handle session.get error separately from not-found
- Truncate session title for callback toast (200-char limit)
- Answer callback query before deleting message in error paths
@georgernstgraf
Copy link
Copy Markdown
Contributor Author

georgernstgraf commented Apr 27, 2026

I am still not sure if this should be merged. The / menu is already crowded and it is sooo easy to ssh into the machine and do <ctrl-d> to clean up ..

An alternative would be: find out if its possible to add a trash icon to each listed session and thus give the user the possiblity to delete a session. But then the confirmation dialog would be challenging, or we would skip it in this case ..

Good we have a maintainer to decide ;)

worked with it a couple of days ... it's actually nice.

@grinev
Copy link
Copy Markdown
Owner

grinev commented Apr 30, 2026

I will look an this, but I have in plans another implementation, something like this: when you choose session you see buttions: switch, rename, delete, cancel.

@georgernstgraf
Copy link
Copy Markdown
Contributor Author

I will look an this, but I have in plans another implementation, something like this: when you choose session you see buttions: switch, rename, delete, cancel.

That might be the better idea. BUT: the session-change workflow will involve one user-tap extra.

BTW: anomalyco/opencode#25009

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.

[Feature]: Command for deleting sessions

3 participants