import { useEffect, useRef, useState } from "react";
import type { ContainerStaleness, MigrationOptions } from "../../lib/types";
import Modal from "../ui/Modal";
import Button from "../ui/Button";
import Toggle from "../ui/Toggle";
import { SwitchRow } from "../ui/Field";
import MigrationReportCard from "./MigrationReportCard";
import MigrationInterruptedCard from "./MigrationInterruptedCard";
import type { ContainerMigration } from "../../hooks/useContainerMigration";
import {
DATA_NOT_CARRIED,
KEPT_AUTOMATICALLY,
KEPT_WHY,
LOST_WITHOUT_REPLAY,
MID_RUN_SAFETY,
REPLAY_COST,
ROLLBACK_DISK_COST,
ROLLBACK_SCOPE,
formatDataSize,
formatSnapshotDate,
} from "./migrationCopy";
interface Props {
projectName: string;
staleness: ContainerStaleness | null;
migration: ContainerMigration;
onClose: () => void;
}
function Section({
title,
children,
control,
}: {
title: string;
children: React.ReactNode;
control?: React.ReactNode;
}) {
return (
{title}
)}
{phaseMessage ?? "Starting…"}
{MID_RUN_SAFETY}
Still working out what this container has that the current base does not. The lists below are not complete until it finishes, so the update cannot start yet.
{KEPT_WHY}
{LOST_WITHOUT_REPLAY}
{DATA_NOT_CARRIED}
{probeSettled ? ( atRisk.length > 0 ? (
Nothing was found under /var{" "}
on this container, so there is nothing here to lose.
Not checked yet.
)}{/* "None found" and "not looked yet" are different sentences. Printing the first while the probe is still running is how a user ends up believing a delta was empty when it was unread. */} {probeSettled ? "No extra apt packages were found on this container." : "Still checking which apt packages this container added."}
) : (Global npm packages ({npmDelta.length}):
{REPLAY_COST}
{/* 3. Verbatim copies — usually nothing once the probe has settled, so usually not shown at all. Shown while it has not, because a hidden section reads as "there is nothing here". */} {(verbatim.length > 0 || !probeSettled) && ( } >
Content under /usr/local,{" "}
/opt,{" "}
/srv and non-bind-mounted{" "}
/workspace that belongs to no
package, so it cannot be reinstalled from a repository.
Still checking what is there.
)} )} {/* 4. The rollback image, with its real disk cost stated. */} } >{ROLLBACK_DISK_COST}
{ROLLBACK_SCOPE}
{gains.length > 0 && (Plus {staleness?.outdated_package_count} package {staleness?.outdated_package_count === 1 ? "" : "s"} the current base carries at a different version, security updates among them.
)}