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
Summary
When creating a session via
POST /session?directory=/path/to/project, the server ignores thedirectoryquery parameter and sets the session'sdirectoryfield toprocess.cwd()instead.Context
OpenChamber (desktop GUI) runs a single OpenCode server and uses the
directoryquery parameter to scope sessions to different project directories. The SDK correctly sendsdirectoryas a query param on session creation:But the resulting session in the SQLite DB always has
directory = process.cwd(), regardless of the query param value.Evidence
/Users/me(via OpenChamber desktop)directory=/Users/me/projects/myappvia the SDKdirectory: /Users/me,project_id: global/Users/me/projectsvia a wrapper scriptdirectory: /Users/me/projects— confirming the field comes fromprocess.cwd(), not the query paramExpected behavior
When
directoryis provided as a query parameter onPOST /session, the session record should use that value for itsdirectoryfield (and resolve the matching project accordingly).Environment