From 6aca8c38709e47d69efa1463eb676418744ab2ea Mon Sep 17 00:00:00 2001 From: 7418 <7418@openclaw.ai> Date: Fri, 13 Feb 2026 17:28:53 +0800 Subject: [PATCH] fix: remove process.cwd() fallback for working directory in chat route The chat route and claude-client both fell back to process.cwd() when working_directory was empty, causing Claude to operate in the server's directory instead of the user's project. Since session creation now requires a valid working_directory, these fallbacks are unnecessary and misleading. Fall back to os.homedir() as a safer last resort. Also update CLAUDE.md: require explicit user confirmation before publishing releases (no auto push+tag). Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 4 ++++ src/app/api/chat/route.ts | 2 +- src/lib/claude-client.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b831a05..5ada8b4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -21,6 +21,10 @@ CodePilot — Claude Code 的桌面 GUI 客户端,基于 Electron + Next.js。 **重要:不要手动创建 GitHub Release**,否则会与 CI 自动创建的 Release 冲突。如果需要本地打包测试,使用 `npm run electron:pack:mac` 但不要手动上传到 Release。 +## 发版纪律 + +**禁止自动发版**:不要在完成代码修改后自动执行 `git push` + `git tag` + `git push origin tag` 发版流程。必须等待用户明确指示"发版"、"发布"或类似确认后才能执行。代码提交(commit)可以正常进行,但推送和打 tag 必须由用户确认。 + ## Development Rules **提交前必须详尽测试:** diff --git a/src/app/api/chat/route.ts b/src/app/api/chat/route.ts index 3da3714..19e4a2f 100644 --- a/src/app/api/chat/route.ts +++ b/src/app/api/chat/route.ts @@ -32,7 +32,7 @@ export async function POST(request: NextRequest) { let savedContent = content; let fileMeta: Array<{ id: string; name: string; type: string; size: number; filePath: string }> | undefined; if (files && files.length > 0) { - const workDir = session.working_directory || process.cwd(); + const workDir = session.working_directory; const uploadDir = path.join(workDir, '.codepilot-uploads'); if (!fs.existsSync(uploadDir)) { fs.mkdirSync(uploadDir, { recursive: true }); diff --git a/src/lib/claude-client.ts b/src/lib/claude-client.ts index 52ba7d5..0d026c3 100644 --- a/src/lib/claude-client.ts +++ b/src/lib/claude-client.ts @@ -316,7 +316,7 @@ export function streamClaude(options: ClaudeStreamOptions): ReadableStream