From da275cf510c9ddf2904e5a6cb5d4d5464f494530 Mon Sep 17 00:00:00 2001 From: soryu Date: Wed, 21 Jan 2026 16:17:42 +0000 Subject: feat(frontend): Add task branching API types and function - Make contractId optional in CreateTaskRequest interface - Add BranchTaskRequest interface with message, name, includeConversation fields - Add BranchTaskResponse interface with task, messageCount, daemonId fields - Add branchTask API function to call POST /api/v1/mesh/tasks/{id}/branch Co-Authored-By: Claude Opus 4.5 --- makima/frontend/src/lib/api.ts | 47 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 78e52cd..f34ba57 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -607,8 +607,8 @@ export interface TaskListResponse { } export interface CreateTaskRequest { - /** Contract this task belongs to (required) */ - contractId: string; + /** Contract this task belongs to (optional - can be standalone) */ + contractId?: string; name: string; description?: string; plan: string; @@ -974,6 +974,49 @@ export async function listSubtasks(taskId: string): Promise { return res.json(); } +// ============================================================================= +// Task Branching +// ============================================================================= + +/** Request to branch a task */ +export interface BranchTaskRequest { + /** Message to send to the new branched task */ + message: string; + /** Optional name for the new task (defaults to "Branch of {original task name}") */ + name?: string; + /** Whether to include conversation history from the source task */ + includeConversation?: boolean; +} + +/** Response from branching a task */ +export interface BranchTaskResponse { + /** The newly created task */ + task: Task; + /** Number of conversation messages copied to the new task */ + messageCount: number; + /** ID of the daemon assigned to the new task (null if not yet assigned) */ + daemonId: string | null; +} + +/** + * Branch a task to create a new task with the same state. + * Copies the worktree and optionally the conversation history. + */ +export async function branchTask( + taskId: string, + request: BranchTaskRequest +): Promise { + const res = await authFetch(`${API_BASE}/api/v1/mesh/tasks/${taskId}/branch`, { + method: "POST", + body: JSON.stringify(request), + }); + if (!res.ok) { + const errorText = await res.text(); + throw new Error(`Failed to branch task: ${errorText || res.statusText}`); + } + return res.json(); +} + export async function listTaskEvents( taskId: string ): Promise { -- cgit v1.2.3