Skip to content

feat(session): add /session command to browse and attach CLI sessions#30

Merged
RoundTable02 merged 2 commits intomainfrom
feat/session-resume
Mar 16, 2026
Merged

feat(session): add /session command to browse and attach CLI sessions#30
RoundTable02 merged 2 commits intomainfrom
feat/session-resume

Conversation

@RoundTable02
Copy link
Owner

Summary

Add a new /session slash command that allows Discord users to browse, attach, and manage existing OpenCode CLI sessions directly from Discord threads — enabling seamless session resume across CLI and Discord.

Related Issue

Closes #25

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Changes Made

  • New src/commands/session.ts/session command with 4 subcommands:
    • list — Lists all sessions for the channel's bound project, showing session titles, mapping status, and last-used time
    • attach — Presents a select menu of active sessions (labeled by title) to attach to the current thread
    • detach — Detaches the session from the current thread and clears the SSE client
    • info — Shows detailed session info embed including title, ID, port, status, and timestamps
  • Modified src/services/sessionManager.ts:
    • Added SessionInfo interface ({ id, title })
    • Updated listSessions() to return SessionInfo[] with titles from the OpenCode API
    • Added getSessionInfo() to fetch a single session's title and validate its existence
  • Modified src/commands/index.ts — Registered the new session command

Testing

  • I have tested this locally
  • I have added/updated tests (if applicable)
  • All existing tests pass (npm test)

Checklist

  • My code follows the existing code style
  • I have not included version bumps (maintainer handles versioning)
  • I have updated documentation if needed
  • This PR focuses on a single feature/fix

Additional Notes

  • Session titles are sourced from the OpenCode API (GET /session returns title field per session). This matches the OpenCode CLI's /session TUI which displays titles for easy identification.
  • The attach subcommand uses Discord's StringSelectMenu with a 120-second timeout. Select menu labels show session titles (max 25 chars), descriptions show session ID prefix and mapping info.
  • After attaching, freshContext is automatically set to false so the resumed session preserves conversation history.
  • After merging, run remote-opencode deploy to register the new slash command with Discord.

… from Discord

Add a new /session slash command with list, attach, detach, and info
subcommands, allowing users to resume OpenCode CLI sessions from Discord
threads. Sessions display titles from the OpenCode API for easy
identification.

- Add SessionInfo interface and getSessionInfo() to sessionManager
- Update listSessions() to return {id, title} instead of just IDs
- Create session.ts with list/attach/detach/info subcommands
- Register session command in commands/index.ts

Closes #25
@RoundTable02 RoundTable02 merged commit 480dbb7 into main Mar 16, 2026
@RoundTable02 RoundTable02 deleted the feat/session-resume branch March 16, 2026 03:16
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.

[Question] Agent behaviour issue

1 participant