mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-03 02:24:33 +00:00
Fabro projected the driver's status into its own state enum, resource, network, and timestamp types for the run sandbox and inventory endpoints, losing the provider's state string, the network policy, the sandbox kind, and the driver's own vocabulary along the way. The API now carries the driver's SandboxStatus itself: SandboxDetails is fabro's run record beside the status, SandboxInfo is the provider beside the status, and the OpenAPI schema describes the driver's types (state, resources in the units the driver reports, the network policy, the sandbox kind, workspace ownership) which fabro-api reuses through with_replacement with round trip tests proving identity and JSON parity. The projection types and their conversion go; the web sandbox page and summary panel read the status directly, and the TypeScript client is regenerated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
116 lines
2.8 KiB
TypeScript
116 lines
2.8 KiB
TypeScript
import type { SandboxState } from "@qltysh/fabro-api-client";
|
|
|
|
export interface SandboxStateDisplay {
|
|
/** Short human-readable label, e.g. "Running". */
|
|
label: string;
|
|
/** One-sentence explanation shown on hover. */
|
|
description: string;
|
|
/** Tailwind background class for the status dot. */
|
|
dot: string;
|
|
/** Tailwind text color class matching the dot. */
|
|
text: string;
|
|
}
|
|
|
|
const PENDING = { dot: "bg-amber", text: "text-amber" } as const;
|
|
const QUIET = { dot: "bg-fg-muted", text: "text-fg-muted" } as const;
|
|
const GONE = { dot: "bg-coral", text: "text-coral" } as const;
|
|
|
|
/**
|
|
* Display metadata for every sandbox driver lifecycle state. Shared by the
|
|
* run overview summary panel and the dedicated sandbox page so the dot color,
|
|
* label, and hover copy stay consistent. A state this build does not know
|
|
* renders as `unknown`.
|
|
*/
|
|
export const SANDBOX_STATE_DISPLAY: Record<SandboxState, SandboxStateDisplay> = {
|
|
unknown: {
|
|
label: "Unknown",
|
|
description: "The sandbox state could not be determined.",
|
|
...QUIET,
|
|
},
|
|
creating: {
|
|
label: "Creating",
|
|
description: "The sandbox is being created.",
|
|
...PENDING,
|
|
},
|
|
starting: {
|
|
label: "Starting",
|
|
description: "The sandbox is starting up.",
|
|
...PENDING,
|
|
},
|
|
running: {
|
|
label: "Running",
|
|
description: "The sandbox is running.",
|
|
dot: "bg-teal-500",
|
|
text: "text-teal-500",
|
|
},
|
|
stopping: {
|
|
label: "Stopping",
|
|
description: "The sandbox is shutting down.",
|
|
...PENDING,
|
|
},
|
|
stopped: {
|
|
label: "Stopped",
|
|
description: "The sandbox is stopped.",
|
|
...QUIET,
|
|
},
|
|
pausing: {
|
|
label: "Pausing",
|
|
description: "The sandbox is being paused.",
|
|
...PENDING,
|
|
},
|
|
paused: {
|
|
label: "Paused",
|
|
description: "The sandbox is paused.",
|
|
...PENDING,
|
|
},
|
|
resuming: {
|
|
label: "Resuming",
|
|
description: "The sandbox is resuming.",
|
|
...PENDING,
|
|
},
|
|
archiving: {
|
|
label: "Archiving",
|
|
description: "The sandbox is being archived.",
|
|
...PENDING,
|
|
},
|
|
archived: {
|
|
label: "Archived",
|
|
description: "The sandbox has been archived.",
|
|
...QUIET,
|
|
},
|
|
restoring: {
|
|
label: "Restoring",
|
|
description: "The sandbox is being restored.",
|
|
...PENDING,
|
|
},
|
|
resizing: {
|
|
label: "Resizing",
|
|
description: "The sandbox resources are being resized.",
|
|
...PENDING,
|
|
},
|
|
forking: {
|
|
label: "Forking",
|
|
description: "The sandbox is being forked.",
|
|
...PENDING,
|
|
},
|
|
snapshotting: {
|
|
label: "Snapshotting",
|
|
description: "A snapshot of the sandbox is being taken.",
|
|
...PENDING,
|
|
},
|
|
deleting: {
|
|
label: "Deleting",
|
|
description: "The sandbox is being deleted.",
|
|
...PENDING,
|
|
},
|
|
deleted: {
|
|
label: "Deleted",
|
|
description: "The sandbox has been deleted.",
|
|
...GONE,
|
|
},
|
|
error: {
|
|
label: "Error",
|
|
description: "The sandbox encountered an error.",
|
|
...GONE,
|
|
},
|
|
};
|