Skip to content

opencode attach --session fails with 'Session not found' since v1.1.1 #7149

@rmk40

Description

@rmk40

Description

opencode attach with --session flag fails with "Session not found" error when the client's current working directory differs from the directory where the session was created.

This is a regression introduced in v1.1.1 by commit 401b498 (PR #6715).

OpenCode version

v1.1.1 and later (worked in v1.0.223)

Steps to reproduce

  1. Start opencode server in directory A (e.g., /Users/me/project-a)
  2. Create a session, note the session ID (e.g., ses_abc123)
  3. From a different directory B, run:
    opencode attach "http://localhost:4096" --session "ses_abc123"
  4. Error: "Session not found: ses_abc123"

The same session works fine when accessed via browser at http://localhost:4096/<base64-encoded-directory>/session/ses_abc123.

Root cause

PR #6715 added directory: process.cwd() to the attach command, which sends the client's current working directory as the x-opencode-directory header. Sessions are stored per-project (keyed by directory), so when the client's cwd differs from the session's directory, the server looks in the wrong project and fails to find the session.

Before v1.1.1, no directory was sent, so the server fell back to its own process.cwd() (where the session was created).

Metadata

Metadata

Assignees

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