Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/application/task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@ export class TaskService {
return this.updateStatus(id, 'cancelled');
}

async clone(id: string): Promise<Task> {
const src = await this.get(id);
return this.create({
title: src.title,
description: src.description,
priority: src.priority,
assignee: src.assignee,
labels: [...src.labels],
depends_on: src.depends_on.length ? [...src.depends_on] : undefined,
max_attempts: src.max_attempts,
workspace_mode: src.workspace_mode,
review_criteria: src.review_criteria ? [...src.review_criteria] : undefined,
scope: src.scope ? [...src.scope] : undefined,
goalId: src.goalId,
});
}

async retry(id: string): Promise<Task> {
const task = await this.get(id);

Expand Down
11 changes: 11 additions & 0 deletions src/cli/commands/tui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ export function registerTuiCommand(program: Command, container: Container): void
await container.orchestrator.runTask(taskId);
};

const onCloneTask = async (taskId: string) => {
const cloned = await container.taskService.clone(taskId);
await container.orchestrator.runTask(cloned.id).catch((dispatchErr) => {
const msg = dispatchErr instanceof Error ? dispatchErr.message : String(dispatchErr);
// Attach cloned task so App can show "cloned but dispatch failed" vs "clone itself failed"
throw Object.assign(new Error(msg), { cloned });
});
return cloned;
};

const onCreateTask = async (title: string, opts?: { priority?: number; description?: string; attachments?: string[] }) => {
return container.taskService.create({
title,
Expand Down Expand Up @@ -265,6 +275,7 @@ export function registerTuiCommand(program: Command, container: Container): void
agents,
state,
onRunTask,
onCloneTask,
onCreateTask,
onCancelTask,
onRetryTask,
Expand Down
Loading