The plugin now supports session switching! Previously, it only tracked one main session. Now it:
- Tracks all main sessions (non-subagent) in a Map
- Tracks the currently active session
- Detects when you switch between sessions using the
tui.session.selectevent - Updates the tmux window name whenever you switch to a different session
When you switch sessions in OpenCode (using /sessions, /resume, or Ctrl+X L), the plugin:
- Receives a
tui.session.selectevent with the newsessionID - Looks up the session from its internal cache
- Updates the tmux window name to
oc-<new-session-title>
session.created- Stores new sessions and sets initial window namesession.updated- Updates window name when session title changestui.session.select- Detects session switches and updates window namesession.deleted- Removes deleted sessions from trackingserver.instance.disposed- Cleanup when OpenCode closes
- Start OpenCode: Window name becomes
oc-<session-title>oroc-<session-id> - Create new session: New session is tracked but window name stays the same
- Switch to another session: Window name updates to
oc-<new-session-title> - Update session title: Window name updates to reflect new title
- Close OpenCode: Window name resets to
oc
To test session switching:
- Start OpenCode in a tmux window
- Start a conversation (tmux window should be renamed)
- Create a new session with
/newor Ctrl+N - Switch between sessions with
/sessionsor Ctrl+X L - Watch the tmux window name update as you switch!
- The
tui.session.selectevent exists in the OpenCode API but isn't in the standard Plugin Event type union - We use type assertion
(event as any).type === "tui.session.select"to access it - The plugin maintains a
Map<string, Session>to cache session information - Only main sessions (without
parentID) are tracked; subagent sessions are ignored