You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
POST /session ignores directory query parameter for session record #23607
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/sdkcreate(D,B){letF=p0([D],[{args: [{in: "query",key: "directory"},// ← sent but ignored{in: "query",key: "workspace"},{in: "body",key: "parentID"},{in: "body",key: "title"},
...
]}]);returnthis.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).
Activity
github-actions commentedon Jul 6, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
GuoChen-thlg commentedon Aug 27, 2026
OpenCode 的"新建会话"按钮不调用 POST /session API
它创建一个 draft(草稿) 存储在前端内存中
然后导航到 /new-session?draftId=xxx 页面
用户在该页面输入消息后,才会调用 POST /session 创建实际会话
这就是为什么 API 忽略 projectID 的原因 — OpenCode 自己的前端也不通过 API 指定项目,而是通过 ctx.projects.open(directory) 设置当前项目上下文,然后在该上下文中创建会话。