Add --session flag to opencode attach command #3503

Closed
opened 2026-02-16 17:40:23 -05:00 by yindo · 1 comment
Owner

Originally created by @charles-cooper on GitHub (Dec 12, 2025).

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.

Originally created by @charles-cooper on GitHub (Dec 12, 2025). ## 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 ```typescript // attach.ts .option("session", { alias: ["s"], type: "string", description: "session id to navigate to", }) // ... await tui({ url: args.url, args: { sessionID: args.session, }, }) ``` ## Usage ```bash opencode attach http://localhost:4096 -s ses_abc123 ``` The `tui()` function already accepts `sessionID` in its args, so this is a one-line change.
yindo closed this issue 2026-02-16 17:40:23 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 12, 2025):

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

  • #5380: TUI referencing local directory when using attach --dir to connect to a remote server (related to the attach command and remote server interaction)

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

  • #5256: Adding Authentication to opencode server api (discusses server API features)
  • #5409: SessionStart hook for session lifecycle events (discusses session management)

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

@github-actions[bot] commented on GitHub (Dec 12, 2025): This issue might be a duplicate of existing issues. Please check: - #5380: TUI referencing local directory when using attach --dir to connect to a remote server (related to the attach command and remote server interaction) Additionally, this feature request relates to the broader server/attach functionality discussed in: - #5256: Adding Authentication to `opencode server` api (discusses server API features) - #5409: SessionStart hook for session lifecycle events (discusses session management) Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3503