MCPcopy
hub / github.com/coder/mux / setupReportedTaskChain

Function setupReportedTaskChain

src/node/services/taskService.test.ts:16980–17048  ·  view source on GitHub ↗
(options?: {
      preserveSubagentsUntilArchive?: boolean;
      taskChain?: ReportedTaskNode[];
    })

Source from the content-addressed store, hash-verified

16978 }
16979
16980 async function setupReportedTaskChain(options?: {
16981 preserveSubagentsUntilArchive?: boolean;
16982 taskChain?: ReportedTaskNode[];
16983 }) {
16984 const config = await createTestConfig(rootDir);
16985
16986 const projectPath = path.join(rootDir, "repo");
16987 const rootWorkspaceId = "root-111";
16988 const taskChain = options?.taskChain ?? [
16989 {
16990 id: "parent-222",
16991 directoryName: "parent-task",
16992 name: "agent_exec_parent",
16993 agentType: "exec",
16994 taskStatus: "reported" as const,
16995 },
16996 {
16997 id: "child-333",
16998 directoryName: "child-task",
16999 name: "agent_explore_child",
17000 agentType: "explore",
17001 taskStatus: "reported" as const,
17002 },
17003 ];
17004
17005 const workspaces: WorkspaceConfigEntry[] = [
17006 projectWorkspace(projectPath, "root", rootWorkspaceId),
17007 ];
17008 let parentWorkspaceId = rootWorkspaceId;
17009 for (const task of taskChain) {
17010 workspaces.push({
17011 path: path.join(projectPath, task.directoryName),
17012 id: task.id,
17013 name: task.name,
17014 parentWorkspaceId,
17015 agentType: task.agentType,
17016 taskStatus: task.taskStatus ?? "reported",
17017 reportedAt: task.reportedAt,
17018 ...(task.workflowTask !== undefined ? { workflowTask: task.workflowTask } : {}),
17019 });
17020 parentWorkspaceId = task.id;
17021 }
17022
17023 await saveWorkspaces(config, projectPath, workspaces, {
17024 taskSettings: {
17025 ...testTaskSettings(3, 5),
17026 preserveSubagentsUntilArchive: options?.preserveSubagentsUntilArchive ?? true,
17027 },
17028 });
17029
17030 const isStreaming = mock(() => false);
17031 const remove = mock(async (workspaceId: string, _force?: boolean): Promise<Result<void>> => {
17032 await removeWorkspaceFromTestConfig(config, workspaceId);
17033 return Ok(undefined);
17034 });
17035 const { aiService } = createAIServiceMocks(config, { isStreaming });
17036 const { workspaceService } = createWorkspaceServiceMocks({ remove });
17037 const { taskService } = createTaskServiceHarness(config, { aiService, workspaceService });

Callers 1

Calls 10

OkFunction · 0.90
projectWorkspaceFunction · 0.85
saveWorkspacesFunction · 0.85
testTaskSettingsFunction · 0.85
createAIServiceMocksFunction · 0.85
createTaskServiceHarnessFunction · 0.85
createTestConfigFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected