summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-21 16:17:42 +0000
committersoryu <soryu@soryu.co>2026-01-21 16:17:42 +0000
commitda275cf510c9ddf2904e5a6cb5d4d5464f494530 (patch)
tree9c1f2faacb4fdb6ae2be0a47f5c5d5c3dabd0cb2
parent0c52f42a753f6d3e7581764670238ec5fae721da (diff)
downloadsoryu-da275cf510c9ddf2904e5a6cb5d4d5464f494530.tar.gz
soryu-da275cf510c9ddf2904e5a6cb5d4d5464f494530.zip
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 <noreply@anthropic.com>
-rw-r--r--makima/frontend/src/lib/api.ts47
1 files 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<TaskListResponse> {
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<BranchTaskResponse> {
+ 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<TaskEventListResponse> {