153 lines · 6.0 KB
import { SELECTED_SURFACE } from "~/ui/tones";
import { useState } from "react";
import { startPullMergeFix } from "~/fns/mergefix";
import { MERGE_FIX_ACTIVE, useMergeFix, type MergeFix, type PullParams } from "~/hooks/use-merge-fix";
import { useAction } from "~/hooks/use-action";
import { MergeFixProposal } from "~/components/MergeFixProposal";
import { Badge } from "~/ui/Badge";
import { Panel } from "~/ui/Panel";
import { Button } from "~/ui/Button";
import { ErrorBanner } from "~/ui/Callout";
import { cn } from "~/utils/cn";

const STATUS_COPY = {
  queued: "Queued",
  running: "Analyzing conflicts",
  applying: "Committing fix",
  applied: "Fix committed",
  suggested: "Proposal ready",
  failed: "Failed",
} as const;

const REQUEUE_COPY = {
  waiting: "Rejoins the merge queue once CI passes",
  enqueued: "Back in the merge queue",
  gave_up: "Not re-queued",
} as const;

function percent(value: number | undefined): string {
  return `${Math.round((value ?? 0) * 100)}%`;
}

export function MergeFixPanel({
  params,
  initial,
  canStart,
  onPick,
  onApplied,
}: {
  params: PullParams;
  initial: MergeFix;