Skip to content

POST /session ignores directory query parameter for session record #23607

@Arthur-GH

Description

@Arthur-GH

Summary

When creating a session via POST /session?directory=/path/to/project, the server ignores the directory query parameter and sets the session's directory field to process.cwd() instead.

Context

OpenChamber (desktop GUI) runs a single OpenCode server and uses the directory query parameter to scope sessions to different project directories. The SDK correctly sends directory as a query param on session creation:

// From @opencode-ai/sdk
create(D, B) {
  let F = p0([D], [{args: [
    {in: "query", key: "directory"},  // ← sent but ignored
    {in: "query", key: "workspace"},
    {in: "body", key: "parentID"},
    {in: "body", key: "title"},
    ...
  ]}]);
  return this.client.post({url: "/session", ...});
}

But the resulting session in the SQLite DB always has directory = process.cwd(), regardless of the query param value.

Evidence

  • Launched OpenCode server from /Users/me (via OpenChamber desktop)
  • Created session with directory=/Users/me/projects/myapp via the SDK
  • DB shows: directory: /Users/me, project_id: global
  • Changed server cwd to /Users/me/projects via a wrapper script
  • New sessions now show directory: /Users/me/projects — confirming the field comes from process.cwd(), not the query param

Expected behavior

When directory is provided as a query parameter on POST /session, the session record should use that value for its directory field (and resolve the matching project accordingly).

Environment

  • opencode-ai: 1.14.19
  • OS: macOS (arm64)
  • Client: OpenChamber 1.9.6

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions