Skip to content

Add --session flag to opencode attach command #5445

Closed

Description

@charles-cooper

Summary

Add a --session / -s flag to opencode attach to navigate directly to a specific session when attaching to a running server.

Problem

The docs describe opencode serve as enabling "multiple clients" to interact with opencode programmatically. However, there's no clean way to attach a TUI to an existing server and open a specific session.

Currently:

  • opencode -s <session_id> starts a new server, defeating the purpose of opencode serve
  • opencode attach <url> connects to an existing server but has no way to specify which session to open

This means opencode serve can't really be used as intended - any TUI interaction requires starting a separate server.

Proposed Solution

// attach.ts
.option("session", {
  alias: ["s"],
  type: "string",
  description: "session id to navigate to",
})
// ...
await tui({
  url: args.url,
  args: {
    sessionID: args.session,
  },
})

Usage

opencode attach http://localhost:4096 -s ses_abc123

The tui() function already accepts sessionID in its args, so this is a one-line change.

Activity

  1. github-actions commented on Dec 12, 2025

    @github-actions
    Contributor

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

    Additionally, this feature request relates to the broader server/attach functionality discussed in:

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

  2. added a commit that references this issue on Dec 12, 2025
    609704c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions