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.
Summary
Add a
--session/-sflag toopencode attachto navigate directly to a specific session when attaching to a running server.Problem
The docs describe
opencode serveas 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 ofopencode serveopencode attach <url>connects to an existing server but has no way to specify which session to openThis means
opencode servecan't really be used as intended - any TUI interaction requires starting a separate server.Proposed Solution
Usage
The
tui()function already acceptssessionIDin its args, so this is a one-line change.