Add merged flag

This commit is contained in:
Louis Knight-Webb
2025-06-19 21:41:18 -04:00
parent b3ce6c1711
commit e3033b6a71
3 changed files with 23 additions and 13 deletions

View File

@@ -129,6 +129,7 @@ pub struct BranchStatus {
pub commits_behind: usize,
pub commits_ahead: usize,
pub up_to_date: bool,
pub merged: bool,
}
impl TaskAttempt {
@@ -776,6 +777,7 @@ impl TaskAttempt {
commits_behind: 0,
commits_ahead: 0,
up_to_date: true,
merged: attempt.merge_commit.is_some(),
});
}
@@ -798,6 +800,7 @@ impl TaskAttempt {
commits_behind,
commits_ahead,
up_to_date: commits_behind == 0 && commits_ahead == 0,
merged: attempt.merge_commit.is_some(),
})
}

View File

@@ -376,7 +376,12 @@ export function TaskAttemptComparePage() {
</div>
)}
{/* Success Messages */}
{/* Status Messages */}
{branchStatus?.merged && (
<div className="text-green-600 text-sm font-medium">
Changes have been merged
</div>
)}
{rebaseSuccess && (
<div className="text-green-600 text-sm">
Branch rebased successfully!
@@ -390,7 +395,7 @@ export function TaskAttemptComparePage() {
{/* Action Buttons */}
<div className="flex items-center gap-2">
{branchStatus && branchStatus.is_behind === true && (
{branchStatus && branchStatus.is_behind === true && !branchStatus.merged && (
<Button
onClick={handleRebaseClick}
disabled={rebasing || branchStatusLoading}
@@ -401,13 +406,15 @@ export function TaskAttemptComparePage() {
{rebasing ? "Rebasing..." : "Rebase onto Main"}
</Button>
)}
<Button
onClick={handleMergeClick}
disabled={merging || !diff || diff.files.length === 0 || Boolean(branchStatus?.is_behind)}
className="bg-green-600 hover:bg-green-700 disabled:bg-gray-400"
>
{merging ? "Merging..." : "Merge Changes"}
</Button>
{!branchStatus?.merged && (
<Button
onClick={handleMergeClick}
disabled={merging || !diff || diff.files.length === 0 || Boolean(branchStatus?.is_behind)}
className="bg-green-600 hover:bg-green-700 disabled:bg-gray-400"
>
{merging ? "Merging..." : "Merge Changes"}
</Button>
)}
</div>
</div>
</div>

View File

@@ -31,11 +31,11 @@ export type UpdateTask = { title: string | null, description: string | null, sta
export type TaskAttemptStatus = "init" | "setuprunning" | "setupcomplete" | "setupfailed" | "executorrunning" | "executorcomplete" | "executorfailed" | "paused";
export type TaskAttempt = { id: string, task_id: string, worktree_path: string, base_commit: string | null, merge_commit: string | null, executor: string | null, stdout: string | null, stderr: string | null, created_at: string, updated_at: string, };
export type TaskAttempt = { id: string, task_id: string, worktree_path: string, merge_commit: string | null, executor: string | null, stdout: string | null, stderr: string | null, created_at: string, updated_at: string, };
export type CreateTaskAttempt = { task_id: string, worktree_path: string, base_commit: string | null, merge_commit: string | null, executor: string | null, };
export type CreateTaskAttempt = { task_id: string, worktree_path: string, merge_commit: string | null, executor: string | null, };
export type UpdateTaskAttempt = { worktree_path: string | null, base_commit: string | null, merge_commit: string | null, };
export type UpdateTaskAttempt = { worktree_path: string | null, merge_commit: string | null, };
export type TaskAttemptActivity = { id: string, task_attempt_id: string, status: TaskAttemptStatus, note: string | null, created_at: string, };
@@ -51,4 +51,4 @@ export type FileDiff = { path: string, chunks: Array<DiffChunk>, };
export type WorktreeDiff = { files: Array<FileDiff>, };
export type BranchStatus = { is_behind: boolean, commits_behind: number, commits_ahead: number, up_to_date: boolean, };
export type BranchStatus = { is_behind: boolean, commits_behind: number, commits_ahead: number, up_to_date: boolean, merged: boolean, };