Feature Request
Allow opencode -s / --session to accept a session title (name) in addition to a session ID.
Problem
Currently, --session only accepts a session ID like ses_3cf7dd8d4ffeUPfENpVxfFojZ2. This makes it impractical to script session resume workflows — for example, automatically resuming a specific session when opening a git worktree.
The session ID is opaque and changes every time, so there's no way to create a stable mapping like "always open this session for this worktree".
Proposed Solution
If the value passed to --session starts with ses_, treat it as an ID (current behavior). Otherwise, treat it as a title search using the existing GET /session/?search=<term> API endpoint.
# Current (still works)
opencode -s ses_3cf7dd8d4ffeUPfENpVxfFojZ2
# Proposed
opencode -s "my feature session"
If multiple sessions match, pick the most recently updated one. Exact title match should take priority over substring match.
Implementation Notes
This is a small change (~20 lines) in two files:
packages/opencode/src/cli/cmd/run.ts — headless mode session resolution
packages/opencode/src/cli/cmd/tui/app.tsx — TUI mode session resolution
The server-side search-by-title API already exists (GET /session/?search=<query> does case-insensitive substring matching), so no backend changes are needed.
Use Case
When using git worktrees with a terminal multiplexer (e.g., zellij), you want to automatically open/resume the correct opencode session for each worktree:
# In a zellij layout or lazygit custom command
opencode --port -s "feature/dark-mode"
This would resume the session titled "feature/dark-mode" if it exists, or could be combined with --title to create one with that name if it doesn't.
Feature Request
Allow
opencode -s/--sessionto accept a session title (name) in addition to a session ID.Problem
Currently,
--sessiononly accepts a session ID likeses_3cf7dd8d4ffeUPfENpVxfFojZ2. This makes it impractical to script session resume workflows — for example, automatically resuming a specific session when opening a git worktree.The session ID is opaque and changes every time, so there's no way to create a stable mapping like "always open this session for this worktree".
Proposed Solution
If the value passed to
--sessionstarts withses_, treat it as an ID (current behavior). Otherwise, treat it as a title search using the existingGET /session/?search=<term>API endpoint.If multiple sessions match, pick the most recently updated one. Exact title match should take priority over substring match.
Implementation Notes
This is a small change (~20 lines) in two files:
packages/opencode/src/cli/cmd/run.ts— headless mode session resolutionpackages/opencode/src/cli/cmd/tui/app.tsx— TUI mode session resolutionThe server-side search-by-title API already exists (
GET /session/?search=<query>does case-insensitive substring matching), so no backend changes are needed.Use Case
When using git worktrees with a terminal multiplexer (e.g., zellij), you want to automatically open/resume the correct opencode session for each worktree:
This would resume the session titled "feature/dark-mode" if it exists, or could be combined with
--titleto create one with that name if it doesn't.