From d1f5dadb549d499c5aeee9cacf6c9aa0a233c198 Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 26 Jan 2026 22:12:57 +0000 Subject: Add local-only mode for contracts with patch export support (#34) * Add local_only flag to contracts database and models Co-Authored-By: Claude Opus 4.5 * Task completion checkpoint * Skip automatic completion actions in local_only mode Add `local_only` flag to contracts that prevents automatic completion actions (branch, merge, pr) from executing when tasks complete. This allows users to manually handle code changes via patch files or other means when operating in local-only mode. Changes: - Add `local_only` field to Contract model and request types - Add database migration for the new column - Add `local_only` parameter to SpawnTask command in both state.rs and daemon protocol.rs - Modify task manager to skip completion action execution when `local_only` is true, with appropriate logging - Pass `local_only` flag through all task spawning paths: - mesh_supervisor.rs (task spawn, retry, resume) - mesh.rs (task start, reassign, continue) - mesh_chat.rs (run task) - contract_chat.rs (run task) - Update repository create/update functions to handle `local_only` Co-Authored-By: Claude Opus 4.5 * Task completion checkpoint * Implement core patch export system Add functionality to create uncompressed, human-readable git patches for export. This enables users to generate patches that can be manually applied or shared, without the compression used for internal checkpoints. Changes: - Add ExportPatchResult struct with patch content, file count, and line stats - Add create_export_patch() function that generates diffs against a base SHA - Add get_head_sha() utility function - Add parse_diff_stat() helper to extract line counts from git output - Add CreateExportPatch command to daemon protocol - Add ExportPatchCreated response message to protocol - Add handler in task manager to process export patch requests - Add server-side handling to broadcast patch results to UI The export patch system automatically finds the merge-base when no base SHA is provided, trying upstream tracking branch first, then common default branches (origin/main, origin/master, main, master). Co-Authored-By: Claude Opus 4.5 * Task completion checkpoint * Add GitActionsPanel frontend component * Add WorktreeFilesPanel and PatchesListPanel components * Add local-only mode toggle to contract creation --------- Co-authored-by: Claude Opus 4.5 --- .../src/components/mesh/WorktreeFilesPanel.tsx | 197 +++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 makima/frontend/src/components/mesh/WorktreeFilesPanel.tsx (limited to 'makima/frontend/src/components/mesh/WorktreeFilesPanel.tsx') diff --git a/makima/frontend/src/components/mesh/WorktreeFilesPanel.tsx b/makima/frontend/src/components/mesh/WorktreeFilesPanel.tsx new file mode 100644 index 0000000..b529588 --- /dev/null +++ b/makima/frontend/src/components/mesh/WorktreeFilesPanel.tsx @@ -0,0 +1,197 @@ +import { useState, useEffect, useCallback } from "react"; +import type { WorktreeInfo } from "../../lib/api"; +import { getWorktreeInfo } from "../../lib/api"; + +interface WorktreeFilesPanelProps { + taskId: string; +} + +/** Get status badge styling based on file status */ +function getStatusStyle(status: string): { color: string; bgColor: string; label: string } { + switch (status) { + case "M": + case "modified": + return { color: "text-yellow-400", bgColor: "bg-yellow-400/10", label: "M" }; + case "A": + case "added": + return { color: "text-green-400", bgColor: "bg-green-400/10", label: "A" }; + case "D": + case "deleted": + return { color: "text-red-400", bgColor: "bg-red-400/10", label: "D" }; + case "R": + case "renamed": + return { color: "text-cyan-400", bgColor: "bg-cyan-400/10", label: "R" }; + case "C": + case "copied": + return { color: "text-purple-400", bgColor: "bg-purple-400/10", label: "C" }; + case "U": + case "unmerged": + return { color: "text-orange-400", bgColor: "bg-orange-400/10", label: "U" }; + case "?": + case "untracked": + return { color: "text-[#555]", bgColor: "bg-[#555]/10", label: "?" }; + default: + return { color: "text-[#9bc3ff]", bgColor: "bg-[rgba(117,170,252,0.1)]", label: status.charAt(0).toUpperCase() }; + } +} + +export function WorktreeFilesPanel({ taskId }: WorktreeFilesPanelProps) { + const [worktreeInfo, setWorktreeInfo] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [expanded, setExpanded] = useState(false); + + const fetchWorktreeInfo = useCallback(async () => { + try { + setLoading(true); + setError(null); + const info = await getWorktreeInfo(taskId); + setWorktreeInfo(info); + } catch (e) { + console.error("Failed to fetch worktree info:", e); + setError(e instanceof Error ? e.message : "Failed to fetch worktree info"); + } finally { + setLoading(false); + } + }, [taskId]); + + useEffect(() => { + fetchWorktreeInfo(); + }, [fetchWorktreeInfo]); + + if (loading) { + return ( +
+
+ Worktree Changes +
+
+ Loading worktree info... +
+
+ ); + } + + if (error) { + return ( +
+
+
+ Worktree Changes +
+ +
+
+ {error} +
+
+ ); + } + + if (!worktreeInfo || worktreeInfo.files.length === 0) { + return ( +
+
+
+ Worktree Changes +
+ +
+
+ No changes in worktree +
+
+ ); + } + + const { stats, files } = worktreeInfo; + const displayFiles = expanded ? files : files.slice(0, 10); + + return ( +
+ {/* Header */} +
+
+ Worktree Changes +
+
+ {/* Stats */} +
+ + {stats.filesChanged} file{stats.filesChanged !== 1 ? "s" : ""} + + +{stats.insertions} + -{stats.deletions} +
+ +
+
+ + {/* File list */} +
+ {displayFiles.map((file) => { + const statusStyle = getStatusStyle(file.status); + return ( +
+ {/* Status badge */} + + {statusStyle.label} + + + {/* File path */} + + {file.path} + + + {/* Line stats */} +
+ {file.linesAdded > 0 && ( + +{file.linesAdded} + )} + {file.linesRemoved > 0 && ( + -{file.linesRemoved} + )} +
+
+ ); + })} +
+ + {/* Show more/less button */} + {files.length > 10 && ( +
+ +
+ )} +
+ ); +} -- cgit v1.2.3