chat: run /chat sessions from the dedicated claude_sessions cwd

The standalone /chat route now tags its context as 'chat'; the backend runs those
sessions with cwd = DATA_PATH/<email>/claude_sessions (created on demand), so their
transcripts form an isolated Claude project group instead of polluting the home-dir
history. Other chat contexts (email/project panels) keep their own cwd.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 09:43:01 +00:00
co-authored by Claude Opus 4.8
parent 319cf39e84
commit eb4ce4301b
3 changed files with 20 additions and 7 deletions
+8 -1
View File
@@ -1,4 +1,4 @@
import { readdirSync, readFileSync, existsSync, statSync } from 'node:fs';
import { readdirSync, readFileSync, existsSync, statSync, mkdirSync } from 'node:fs';
import { join } from 'node:path';
import { DATA_PATH } from '../../data-path';
@@ -12,6 +12,13 @@ import { DATA_PATH } from '../../data-path';
/** Dedicated working directory for /chat sessions, so they form their own Claude "project" group. */
export const getClaudeSessionsCwd = (email: string): string => join(DATA_PATH, email, 'claude_sessions');
/** Same, but create the directory if it doesn't exist (call before spawning a /chat session). */
export const ensureClaudeSessionsCwd = (email: string): string => {
const dir = getClaudeSessionsCwd(email);
mkdirSync(dir, { recursive: true });
return dir;
};
const claudeProjectsDir = (email: string): string => join(DATA_PATH, email, 'home', '.claude', 'projects');
/** Claude's folder name for a working directory. */