Feature: Expose TUI Session Management Commands via ACP (for Zed integration) #6509

Open
opened 2026-02-16 18:04:25 -05:00 by yindo · 4 comments
Owner

Originally created by @KristjanMinn on GitHub (Jan 16, 2026).

Originally assigned to: @thdxr on GitHub.

Summary

Expose OpenCode's TUI session management features (session list, switch session, new session, rename, fork, etc.) through the ACP (Agent Client Protocol) so they can be used in external clients like Zed's agent panel.

Problem

When using OpenCode via Zed's agent panel (or any ACP client), users lose access to the powerful session management features available in the TUI:

TUI Command Palette (Ctrl+P) features NOT available in ACP:

Feature TUI ACP/Zed
Switch session Ctrl+X L Not available
New session Ctrl+X N Not available
Rename session Ctrl+R Not available
Fork from message menu Not available
Compact session Ctrl+X C /compact only
Undo/redo message Ctrl+X U/R Not available
Export session Ctrl+X X Not available
Copy session transcript menu Not available
Jump to message Ctrl+X G Not available

This creates a significant UX gap between TUI and Zed users. Zed users cannot:

  1. Resume previous sessions
  2. Switch between active sessions
  3. Fork conversations at specific points
  4. Navigate session history

Current Architecture

Zed Editor
    │
    │ launches: opencode acp
    │ communicates via: JSON-RPC over stdio (ACP)
    ▼
OpenCode ACP Server (headless)
    │
    │ HTTP SDK API
    ▼
OpenCode Server (sessions exist here)

The TUI is a completely separate code path. ACP runs headless with no access to TUI components.

Proposed Solution

Extend the ACP protocol to expose session management operations:

1. New ACP Methods

// List available sessions
acp.session.list({ 
  limit?: number,
  projectPath?: string 
})  Session[]

// Switch to existing session
acp.session.switch({ 
  sessionId: string 
})  void

// Create new session
acp.session.create({ 
  title?: string 
})  Session

// Fork session from specific message
acp.session.fork({ 
  sessionId: string,
  messageId: string 
})  Session

// Rename session
acp.session.rename({ 
  sessionId: string,
  title: string 
})  void

// Delete session
acp.session.delete({ 
  sessionId: string 
})  void

// Get session info
acp.session.info({ 
  sessionId: string 
})  SessionInfo

// Undo last message
acp.session.undo({ 
  sessionId: string 
})  void

// Redo message
acp.session.redo({ 
  sessionId: string 
})  void

2. Zed Integration

These methods would allow Zed to:

  • Show a session picker in the agent panel UI
  • Add keybindings for session operations
  • Display session history in the sidebar
  • Enable "Continue previous session" workflows

3. Backward Compatibility

This is purely additive — existing ACP clients continue to work unchanged.

Use Cases

  1. Resume work across sessions: User opens Zed, wants to continue yesterday's refactoring session instead of starting fresh

  2. Context switching: User working on feature A needs to quickly answer a question about feature B, then return to A

  3. Branching conversations: User wants to try two different approaches from the same starting point

  4. Session organization: User wants to rename "ACP Session 447d300d-e99b-41ae..." to "Auth refactor discussion"

References

  • ACP implementation: packages/opencode/src/acp/agent.ts
  • TUI session picker: packages/opencode/src/cli/cmd/tui/
  • Session storage: ~/.local/share/opencode/storage/session/
  • Related discussion: Zed ACP integration (#892, #3353)

Environment

  • OpenCode version: 1.1.23
  • Zed extension: opencode (from extension marketplace)
  • OS: Linux
Originally created by @KristjanMinn on GitHub (Jan 16, 2026). Originally assigned to: @thdxr on GitHub. ## Summary Expose OpenCode's TUI session management features (session list, switch session, new session, rename, fork, etc.) through the ACP (Agent Client Protocol) so they can be used in external clients like Zed's agent panel. ## Problem When using OpenCode via Zed's agent panel (or any ACP client), users lose access to the powerful session management features available in the TUI: **TUI Command Palette (Ctrl+P) features NOT available in ACP:** | Feature | TUI | ACP/Zed | |---------|-----|---------| | Switch session | `Ctrl+X L` | ❌ Not available | | New session | `Ctrl+X N` | ❌ Not available | | Rename session | `Ctrl+R` | ❌ Not available | | Fork from message | menu | ❌ Not available | | Compact session | `Ctrl+X C` | `/compact` only | | Undo/redo message | `Ctrl+X U/R` | ❌ Not available | | Export session | `Ctrl+X X` | ❌ Not available | | Copy session transcript | menu | ❌ Not available | | Jump to message | `Ctrl+X G` | ❌ Not available | This creates a significant UX gap between TUI and Zed users. Zed users cannot: 1. Resume previous sessions 2. Switch between active sessions 3. Fork conversations at specific points 4. Navigate session history ## Current Architecture ``` Zed Editor │ │ launches: opencode acp │ communicates via: JSON-RPC over stdio (ACP) ▼ OpenCode ACP Server (headless) │ │ HTTP SDK API ▼ OpenCode Server (sessions exist here) ``` The TUI is a completely separate code path. ACP runs headless with no access to TUI components. ## Proposed Solution Extend the ACP protocol to expose session management operations: ### 1. New ACP Methods ```typescript // List available sessions acp.session.list({ limit?: number, projectPath?: string }) → Session[] // Switch to existing session acp.session.switch({ sessionId: string }) → void // Create new session acp.session.create({ title?: string }) → Session // Fork session from specific message acp.session.fork({ sessionId: string, messageId: string }) → Session // Rename session acp.session.rename({ sessionId: string, title: string }) → void // Delete session acp.session.delete({ sessionId: string }) → void // Get session info acp.session.info({ sessionId: string }) → SessionInfo // Undo last message acp.session.undo({ sessionId: string }) → void // Redo message acp.session.redo({ sessionId: string }) → void ``` ### 2. Zed Integration These methods would allow Zed to: - Show a session picker in the agent panel UI - Add keybindings for session operations - Display session history in the sidebar - Enable "Continue previous session" workflows ### 3. Backward Compatibility This is purely additive — existing ACP clients continue to work unchanged. ## Use Cases 1. **Resume work across sessions**: User opens Zed, wants to continue yesterday's refactoring session instead of starting fresh 2. **Context switching**: User working on feature A needs to quickly answer a question about feature B, then return to A 3. **Branching conversations**: User wants to try two different approaches from the same starting point 4. **Session organization**: User wants to rename "ACP Session 447d300d-e99b-41ae..." to "Auth refactor discussion" ## References - ACP implementation: `packages/opencode/src/acp/agent.ts` - TUI session picker: `packages/opencode/src/cli/cmd/tui/` - Session storage: `~/.local/share/opencode/storage/session/` - Related discussion: Zed ACP integration (#892, #3353) ## Environment - OpenCode version: 1.1.23 - Zed extension: opencode (from extension marketplace) - OS: Linux
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2026):

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

  • #7978: feat(acp): add session/list and session/fork support - Already addresses part of this feature request with session/list and session/fork ACP methods

Additionally, for keybind-related aspects of this request, please also check our pinned keybinds documentation: #4997

@github-actions[bot] commented on GitHub (Jan 16, 2026): This issue might be a duplicate of existing issues. Please check: - #7978: feat(acp): add session/list and session/fork support - Already addresses part of this feature request with session/list and session/fork ACP methods Additionally, for keybind-related aspects of this request, please also check our pinned keybinds documentation: #4997
Author
Owner

@xsa-dev commented on GitHub (Jan 30, 2026):

PR with Implementation Available 🎉

Hi @thdxr! This feature request has a working implementation ready for review:

PR: xsa-dev/opencode#1
Branch: feat/acp-session-management-v2

What the PR adds:

13 Session Management ACP Commands:

  • listSessions - List all available sessions
  • switchSession - Switch to a different session
  • createSession - Create a new session
  • forkSession - Fork the current session
  • renameSession - Rename a session
  • deleteSession - Delete a session
  • getSessionInfo - Get information about a session
  • undoMessage - Undo the last message
  • redoMessage - Redo the last message
  • compactSession - Compact the session
  • exportSession - Export a session (text/json/markdown)
  • jumpToMessage - Jump to a specific message
  • duplicateSession - Duplicate a session

Files Changed:

  1. packages/opencode/src/acp/agent.ts - ACP command registration and handlers
  2. packages/opencode/src/acp/session-handlers.ts - Session management implementations
  3. packages/opencode/src/acp/session-types.ts - TypeScript interfaces

Usage Example:

# List sessions
opencode acp -- /listSessions --limit 10

# Switch session  
opencode acp -- /switchSession --session-id <uuid>

# Create new session
opencode acp -- /createSession --title "Feature X"

# Export session
opencode acp -- /exportSession --session-id <uuid> --format markdown

Notes from Author:

This is a simplified implementation that uses file-based storage for sessions. Future work could integrate with OpenCode's internal session storage via SDK for more robust session management.

Related Feature Requests:

The PR is mergeable and ready for review. Let me know if you need any changes!

@xsa-dev commented on GitHub (Jan 30, 2026): ## PR with Implementation Available 🎉 Hi @thdxr! This feature request has a working implementation ready for review: **PR:** xsa-dev/opencode#1 **Branch:** `feat/acp-session-management-v2` ### What the PR adds: ✅ **13 Session Management ACP Commands:** - `listSessions` - List all available sessions - `switchSession` - Switch to a different session - `createSession` - Create a new session - `forkSession` - Fork the current session - `renameSession` - Rename a session - `deleteSession` - Delete a session - `getSessionInfo` - Get information about a session - `undoMessage` - Undo the last message - `redoMessage` - Redo the last message - `compactSession` - Compact the session - `exportSession` - Export a session (text/json/markdown) - `jumpToMessage` - Jump to a specific message - `duplicateSession` - Duplicate a session ### Files Changed: 1. `packages/opencode/src/acp/agent.ts` - ACP command registration and handlers 2. `packages/opencode/src/acp/session-handlers.ts` - Session management implementations 3. `packages/opencode/src/acp/session-types.ts` - TypeScript interfaces ### Usage Example: ```bash # List sessions opencode acp -- /listSessions --limit 10 # Switch session opencode acp -- /switchSession --session-id <uuid> # Create new session opencode acp -- /createSession --title "Feature X" # Export session opencode acp -- /exportSession --session-id <uuid> --format markdown ``` ### Notes from Author: This is a simplified implementation that uses file-based storage for sessions. Future work could integrate with OpenCode's internal session storage via SDK for more robust session management. ### Related Feature Requests: - anomalyco/opencode#11283 - Add support for local executable override (OPENCODE_EXECUTABLE) - for local dev testing - anomalyco/opencode#11284 - Display /sessions as separate icon/tab in Zed agent panel - this PR enables that UI feature! The PR is mergeable and ready for review. Let me know if you need any changes!
Author
Owner

@xsa-dev commented on GitHub (Jan 30, 2026):

Note: This implementation was AI-generated using OpenCode itself! 🤖


PR with Implementation Available 🎉

Hi @thdxr! This feature request has a working implementation ready for review:

PR: xsa-dev/opencode#1
Branch: feat/acp-session-management-v2

What the PR adds:

13 Session Management ACP Commands:

  • listSessions - List all available sessions
  • switchSession - Switch to a different session
  • createSession - Create a new session
  • forkSession - Fork the current session
  • renameSession - Rename a session
  • deleteSession - Delete a session
  • getSessionInfo - Get information about a session
  • undoMessage - Undo the last message
  • redoMessage - Redo the last message
  • compactSession - Compact the session
  • exportSession - Export a session (text/json/markdown)
  • jumpToMessage - Jump to a specific message
  • duplicateSession - Duplicate a session

Files Changed:

  1. packages/opencode/src/acp/agent.ts - ACP command registration and handlers
  2. packages/opencode/src/acp/session-handlers.ts - Session management implementations
  3. packages/opencode/src/acp/session-types.ts - TypeScript interfaces

Usage Example:

# List sessions
opencode acp -- /listSessions --limit 10

# Switch session  
opencode acp -- /switchSession --session-id <uuid>

# Create new session
opencode acp -- /createSession --title "Feature X"

# Export session
opencode acp -- /exportSession --session-id <uuid> --format markdown

Notes from Author:

This is a simplified implementation that uses file-based storage for sessions. Future work could integrate with OpenCode's internal session storage via SDK for more robust session management.

Related Feature Requests:

The PR is mergeable and ready for review. Let me know if you need any changes!

@xsa-dev commented on GitHub (Jan 30, 2026): **Note:** This implementation was AI-generated using OpenCode itself! 🤖✨ --- ## PR with Implementation Available 🎉 Hi @thdxr! This feature request has a working implementation ready for review: **PR:** xsa-dev/opencode#1 **Branch:** `feat/acp-session-management-v2` ### What the PR adds: ✅ **13 Session Management ACP Commands:** - `listSessions` - List all available sessions - `switchSession` - Switch to a different session - `createSession` - Create a new session - `forkSession` - Fork the current session - `renameSession` - Rename a session - `deleteSession` - Delete a session - `getSessionInfo` - Get information about a session - `undoMessage` - Undo the last message - `redoMessage` - Redo the last message - `compactSession` - Compact the session - `exportSession` - Export a session (text/json/markdown) - `jumpToMessage` - Jump to a specific message - `duplicateSession` - Duplicate a session ### Files Changed: 1. `packages/opencode/src/acp/agent.ts` - ACP command registration and handlers 2. `packages/opencode/src/acp/session-handlers.ts` - Session management implementations 3. `packages/opencode/src/acp/session-types.ts` - TypeScript interfaces ### Usage Example: ```bash # List sessions opencode acp -- /listSessions --limit 10 # Switch session opencode acp -- /switchSession --session-id <uuid> # Create new session opencode acp -- /createSession --title "Feature X" # Export session opencode acp -- /exportSession --session-id <uuid> --format markdown ``` ### Notes from Author: This is a simplified implementation that uses file-based storage for sessions. Future work could integrate with OpenCode's internal session storage via SDK for more robust session management. ### Related Feature Requests: - anomalyco/opencode#11283 - Add support for local executable override (OPENCODE_EXECUTABLE) - for local dev testing - anomalyco/opencode#11284 - Display /sessions as separate icon/tab in Zed agent panel - this PR enables that UI feature! The PR is mergeable and ready for review. Let me know if you need any changes!
Author
Owner

@jackeydou commented on GitHub (Feb 13, 2026):

I saw there was another merged PR that implements session/list and session/fork, I am still wondering if it's possible that opencode acp can support session export and import like opencode CLI?

@jackeydou commented on GitHub (Feb 13, 2026): I saw there was another merged PR that implements session/list and session/fork, I am still wondering if it's possible that opencode acp can support session export and import like opencode CLI?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6509