feat(FN-4606): complete Step 3 — route engine call sites

Ref: Runfusion/Fusion#321
Fusion-Task-Id: FN-4606
Fusion-Task-Lineage: 94b23f37-944e-4bcd-bfa1-67d0a8c0a267
This commit is contained in:
Fusion
2026-05-15 08:15:31 -07:00
committed by gsxdsm
parent f00df58eb7
commit 2799c101ac
8 changed files with 71 additions and 41 deletions

View File

@@ -1,9 +1,9 @@
import { existsSync } from "node:fs";
import { exec } from "node:child_process";
import { promisify } from "node:util";
import { join } from "node:path";
import type { RunMutationContext, Settings, Task, TaskStore } from "@fusion/core";
import { generateWorktreeName, slugify } from "./worktree-names.js";
import { resolveTaskWorktreePath } from "./worktree-paths.js";
import { hydrateWorktreeDb } from "./worktree-db-hydrate.js";
import { formatError } from "./logger.js";
import { isBranchConflictError } from "./branch-conflicts.js";
@@ -135,8 +135,8 @@ export async function acquireTaskWorktree(opts: AcquireTaskWorktreeOptions): Pro
? task.id.toLowerCase()
: naming === "task-title"
? slugify(task.title || task.description.slice(0, 60))
: generateWorktreeName(rootDir);
worktreePath = join(rootDir, ".worktrees", worktreeName);
: generateWorktreeName(rootDir, settings);
worktreePath = resolveTaskWorktreePath(rootDir, settings, worktreeName);
}
let isResume = Boolean(task.worktree && existsSync(worktreePath));
@@ -144,7 +144,7 @@ export async function acquireTaskWorktree(opts: AcquireTaskWorktreeOptions): Pro
logger?.log(`${task.id}: assigned worktree is not usable; creating a fresh worktree instead: ${worktreePath}`);
await store.logEntry(task.id, "Assigned worktree is not a registered, usable git worktree; creating a fresh worktree instead", worktreePath, runContext);
await store.updateTask(task.id, { worktree: null, branch: null });
worktreePath = join(rootDir, ".worktrees", generateWorktreeName(rootDir));
worktreePath = resolveTaskWorktreePath(rootDir, settings, generateWorktreeName(rootDir, settings));
isResume = false;
}