From b9268a3495f22ec63a6e7f982c32cc751ae94361 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 29 Mar 2026 07:53:15 +0000 Subject: [PATCH] fix: draft thread effectiveCwd fallback to project cwd and remove redundant ensureGitWorkspace - buildLocalDraftThread now accepts projectCwd and falls back to it when no worktreePath is set, matching server-side projection logic - Remove single-use ensureGitWorkspace helper and its redundant call in statusDetails (execute already guards via assertWorkspaceDirectory) --- apps/server/src/git/Layers/GitCore.ts | 19 ------------------- apps/web/src/components/ChatView.logic.ts | 5 +++-- apps/web/src/components/ChatView.tsx | 9 ++++++++- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/apps/server/src/git/Layers/GitCore.ts b/apps/server/src/git/Layers/GitCore.ts index fc7799f5a5..411e56c89b 100644 --- a/apps/server/src/git/Layers/GitCore.ts +++ b/apps/server/src/git/Layers/GitCore.ts @@ -673,20 +673,6 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: { }), ); - const ensureGitWorkspace = (operation: string, cwd: string, args: readonly string[] = []) => - assertWorkspaceDirectory(cwd, operation).pipe( - Effect.mapError( - (error) => - new GitCommandError({ - operation, - command: quoteGitCommand(args), - cwd, - detail: error.message, - cause: error, - }), - ), - ); - const runGit = ( operation: string, cwd: string, @@ -1073,11 +1059,6 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: { }); const statusDetails: GitCoreShape["statusDetails"] = Effect.fn("statusDetails")(function* (cwd) { - yield* ensureGitWorkspace("GitCore.statusDetails", cwd, [ - "status", - "--porcelain=2", - "--branch", - ]); yield* refreshStatusUpstreamIfStale(cwd).pipe(Effect.ignoreCause({ log: true })); const [statusStdout, unstagedNumstatStdout, stagedNumstatStdout] = yield* Effect.all( diff --git a/apps/web/src/components/ChatView.logic.ts b/apps/web/src/components/ChatView.logic.ts index c0168f28b9..e86846420e 100644 --- a/apps/web/src/components/ChatView.logic.ts +++ b/apps/web/src/components/ChatView.logic.ts @@ -19,6 +19,7 @@ export function buildLocalDraftThread( draftThread: DraftThreadState, fallbackModelSelection: ModelSelection, error: string | null, + projectCwd: string | null, ): Thread { return { id: threadId, @@ -37,8 +38,8 @@ export function buildLocalDraftThread( lastVisitedAt: draftThread.createdAt, branch: draftThread.branch, worktreePath: draftThread.worktreePath, - effectiveCwd: draftThread.worktreePath ?? null, - effectiveCwdSource: draftThread.worktreePath ? "worktree" : null, + effectiveCwd: draftThread.worktreePath ?? projectCwd, + effectiveCwdSource: draftThread.worktreePath ? "worktree" : projectCwd ? "project" : null, effectiveCwdState: "available", turnDiffSummaries: [], activities: [], diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 1f6b206488..632c8d4739 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -486,9 +486,16 @@ export default function ChatView({ threadId }: ChatViewProps) { model: DEFAULT_MODEL_BY_PROVIDER.codex, }, localDraftError, + fallbackDraftProject?.cwd ?? null, ) : undefined, - [draftThread, fallbackDraftProject?.defaultModelSelection, localDraftError, threadId], + [ + draftThread, + fallbackDraftProject?.defaultModelSelection, + fallbackDraftProject?.cwd, + localDraftError, + threadId, + ], ); const activeThread = serverThread ?? localDraftThread; const runtimeMode =