Skip to content

Commit b9268a3

Browse files
committed
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)
1 parent ae625d2 commit b9268a3

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

apps/server/src/git/Layers/GitCore.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -673,20 +673,6 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
673673
}),
674674
);
675675

676-
const ensureGitWorkspace = (operation: string, cwd: string, args: readonly string[] = []) =>
677-
assertWorkspaceDirectory(cwd, operation).pipe(
678-
Effect.mapError(
679-
(error) =>
680-
new GitCommandError({
681-
operation,
682-
command: quoteGitCommand(args),
683-
cwd,
684-
detail: error.message,
685-
cause: error,
686-
}),
687-
),
688-
);
689-
690676
const runGit = (
691677
operation: string,
692678
cwd: string,
@@ -1073,11 +1059,6 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
10731059
});
10741060

10751061
const statusDetails: GitCoreShape["statusDetails"] = Effect.fn("statusDetails")(function* (cwd) {
1076-
yield* ensureGitWorkspace("GitCore.statusDetails", cwd, [
1077-
"status",
1078-
"--porcelain=2",
1079-
"--branch",
1080-
]);
10811062
yield* refreshStatusUpstreamIfStale(cwd).pipe(Effect.ignoreCause({ log: true }));
10821063

10831064
const [statusStdout, unstagedNumstatStdout, stagedNumstatStdout] = yield* Effect.all(

apps/web/src/components/ChatView.logic.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function buildLocalDraftThread(
1919
draftThread: DraftThreadState,
2020
fallbackModelSelection: ModelSelection,
2121
error: string | null,
22+
projectCwd: string | null,
2223
): Thread {
2324
return {
2425
id: threadId,
@@ -37,8 +38,8 @@ export function buildLocalDraftThread(
3738
lastVisitedAt: draftThread.createdAt,
3839
branch: draftThread.branch,
3940
worktreePath: draftThread.worktreePath,
40-
effectiveCwd: draftThread.worktreePath ?? null,
41-
effectiveCwdSource: draftThread.worktreePath ? "worktree" : null,
41+
effectiveCwd: draftThread.worktreePath ?? projectCwd,
42+
effectiveCwdSource: draftThread.worktreePath ? "worktree" : projectCwd ? "project" : null,
4243
effectiveCwdState: "available",
4344
turnDiffSummaries: [],
4445
activities: [],

apps/web/src/components/ChatView.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,16 @@ export default function ChatView({ threadId }: ChatViewProps) {
486486
model: DEFAULT_MODEL_BY_PROVIDER.codex,
487487
},
488488
localDraftError,
489+
fallbackDraftProject?.cwd ?? null,
489490
)
490491
: undefined,
491-
[draftThread, fallbackDraftProject?.defaultModelSelection, localDraftError, threadId],
492+
[
493+
draftThread,
494+
fallbackDraftProject?.defaultModelSelection,
495+
fallbackDraftProject?.cwd,
496+
localDraftError,
497+
threadId,
498+
],
492499
);
493500
const activeThread = serverThread ?? localDraftThread;
494501
const runtimeMode =

0 commit comments

Comments
 (0)