fix: require valid project directory for session creation

- Backend: POST /api/chat/sessions now validates working_directory
  exists (400 MISSING_DIRECTORY / INVALID_DIRECTORY)
- db.ts: remove process.cwd() fallback in createSession
- ChatListPanel: validate last-working-directory before use,
  open FolderPicker when invalid; add SSR guard for localStorage
- NewChatPage: block sending without a project directory selected

Bump version to 0.10.5.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7418andClaude Opus 4.6 committed 2026-02-13 15:37:51 +08:00
1 parent ae8a905581
commit 916b8889b7
6 files changed
+63 -12

No files matched your search

+20
View File
@@ -1,4 +1,5 @@
import { NextRequest } from 'next/server';
import fs from 'fs/promises';
import { getAllSessions, createSession } from '@/lib/db';
import type { CreateSessionRequest, SessionsResponse, SessionResponse } from '@/types';
@@ -17,6 +18,25 @@ export async function GET() {
export async function POST(request: NextRequest) {
try {
const body: CreateSessionRequest = await request.json();
// Validate working_directory is provided
if (!body.working_directory) {
return Response.json(
{ error: 'Working directory is required', code: 'MISSING_DIRECTORY' },
{ status: 400 },
);
}
// Validate directory actually exists on disk
try {
await fs.access(body.working_directory);
} catch {
return Response.json(
{ error: 'Directory does not exist', code: 'INVALID_DIRECTORY' },
{ status: 400 },
);
}
const session = createSession(
body.title,
body.model,