chat: run the /email chat from the email account's storage dir
The email chat's working directory now resolves to DATA_PATH/<owner>/email_accounts/<accountEmail> (created if missing), so the agent operates in the selected account's dir (emails.db, attachment_cache, …). - websocket.ts: new resolveChatCwd — context 'email' → the account dir (via a new resolveEmailCwd), 'chat' → the pwd/claude_sessions dir, else the given cwd. Both the Claude and OpenCode handlers use it. The account defaults to the owner's first enabled account for now; the account selector will pass it as contextId later. - OpenCode honors the cwd again: send-opencode passes it as the session `directory` (client.createSession(directory?)) for context-scoped chats; the general /chat still omits it and uses the fixed server's default project. Verified against the live server that directory-bound sessions create + list. No frontend change — the /email panel already sends context:'email'. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -105,9 +105,13 @@ class ServerConnection {
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
|
||||
async createSession(title?: string): Promise<string> {
|
||||
// No `directory` — the session lives in the fixed server's own project (its cwd).
|
||||
const session = await this.postJson<{ id?: string }>('/session', title ? { title } : {});
|
||||
async createSession(directory?: string, title?: string): Promise<string> {
|
||||
// `directory` binds the session's working dir (e.g. an email account dir). Omit it for the general
|
||||
// /chat, so the session lives in the fixed server's own project (its cwd).
|
||||
const body: Record<string, unknown> = {};
|
||||
if (directory) body.directory = directory;
|
||||
if (title) body.title = title;
|
||||
const session = await this.postJson<{ id?: string }>('/session', body);
|
||||
if (!session.id) throw new Error('opencode POST /session returned no id');
|
||||
return session.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user