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)
This commit is contained in:
3 files changed
+11
-22
No files matched your search
@@ -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(
|
||||
|
||||
@@ -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: [],
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in new issue
Block a user