@spunto/design-system 0.82.0 → 0.83.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/alert-dialog.tsx +13 -2
- package/src/components/tasks/app-tiles.tsx +7 -1
- package/src/components/tasks/machine.tsx +3 -3
- package/src/components/tasks/tasks.test.tsx +18 -0
- package/src/components/workers/index.ts +1 -1
- package/src/components/workers/setup-progress.tsx +12 -0
- package/src/components/workers/types.ts +5 -0
- package/src/components/workers/worker-setup-timeline.tsx +7 -3
package/package.json
CHANGED
|
@@ -24,13 +24,24 @@ function AlertDialogClose(props: AlertDialogPrimitive.Close.Props) {
|
|
|
24
24
|
return <AlertDialogPrimitive.Close data-slot="alert-dialog-close" {...props} />
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function AlertDialogContent({
|
|
27
|
+
function AlertDialogContent({
|
|
28
|
+
className,
|
|
29
|
+
backdropClassName,
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}: AlertDialogPrimitive.Popup.Props & {
|
|
33
|
+
/** Merged onto the backdrop — e.g. a `z-*` to match a raised `className` on the popup. */
|
|
34
|
+
backdropClassName?: string
|
|
35
|
+
}) {
|
|
28
36
|
const container = useOverlayContainer()
|
|
29
37
|
return (
|
|
30
38
|
<AlertDialogPrimitive.Portal container={container ?? undefined}>
|
|
31
39
|
<AlertDialogPrimitive.Backdrop
|
|
32
40
|
data-slot="alert-dialog-backdrop"
|
|
33
|
-
className=
|
|
41
|
+
className={cn(
|
|
42
|
+
"fixed inset-0 z-50 bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-black/60",
|
|
43
|
+
backdropClassName
|
|
44
|
+
)}
|
|
34
45
|
/>
|
|
35
46
|
<AlertDialogPrimitive.Popup
|
|
36
47
|
data-slot="alert-dialog-content"
|
|
@@ -219,7 +219,13 @@ function ItemAction({ item, action, onAction }: { item: TaskAppTileItem; action:
|
|
|
219
219
|
}}
|
|
220
220
|
>
|
|
221
221
|
<AlertDialogTrigger render={<Button size="xs" variant={danger ? "destructive" : "outline"} />}>{action.label}</AlertDialogTrigger>
|
|
222
|
-
<AlertDialogContent
|
|
222
|
+
<AlertDialogContent
|
|
223
|
+
// Above `z-[120]`: on a phone this opens from the details sheet of `TaskCockpitMobile`,
|
|
224
|
+
// itself a layer at that height — at the default `z-50` the confirmation opened *behind*
|
|
225
|
+
// it, and Merge looked like it did nothing.
|
|
226
|
+
className="z-[130]"
|
|
227
|
+
backdropClassName="z-[130]"
|
|
228
|
+
>
|
|
223
229
|
<AlertDialogHeader>
|
|
224
230
|
<AlertDialogTitle>{action.confirm.title}</AlertDialogTitle>
|
|
225
231
|
{action.confirm.body && <AlertDialogDescription>{action.confirm.body}</AlertDialogDescription>}
|
|
@@ -18,7 +18,7 @@ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "
|
|
|
18
18
|
import { MachinePorts } from "../workers/machine-ports"
|
|
19
19
|
import { ResourceBars, type WorkerStats } from "../workers/resource-bars"
|
|
20
20
|
import { SetupWaterfall } from "../workers/setup-waterfall"
|
|
21
|
-
import { StepIndicator, phaseLabel, setupTotalMs, type StepState } from "../workers/setup-progress"
|
|
21
|
+
import { StepIndicator, catchingUp, phaseLabel, setupTotalMs, type StepState } from "../workers/setup-progress"
|
|
22
22
|
import type { WorkerCardWorker, WorkerSetupStatus } from "../workers/types"
|
|
23
23
|
import type { LinkRender } from "../workers/worker-card"
|
|
24
24
|
import { WorkerSetupTimeline } from "../workers/worker-setup-timeline"
|
|
@@ -319,7 +319,7 @@ export function bootSteps({
|
|
|
319
319
|
? "pending"
|
|
320
320
|
: worker.state === "error"
|
|
321
321
|
? "error"
|
|
322
|
-
: worker.state === "ready"
|
|
322
|
+
: worker.state === "ready" || catchingUp(setup)
|
|
323
323
|
? "done"
|
|
324
324
|
: "running"
|
|
325
325
|
const container: TaskBootStep = {
|
|
@@ -340,7 +340,7 @@ export function bootSteps({
|
|
|
340
340
|
? "pending"
|
|
341
341
|
: setup?.phase === "error"
|
|
342
342
|
? "error"
|
|
343
|
-
: worker.state === "ready" || setup?.phase === "ready"
|
|
343
|
+
: (worker.state === "ready" || setup?.phase === "ready") && !catchingUp(setup)
|
|
344
344
|
? "done"
|
|
345
345
|
: "running"
|
|
346
346
|
const setupStep: TaskBootStep = {
|
|
@@ -27,6 +27,7 @@ import { runStats, toolSubject, toolVerb, type ToolRun } from "./tool-stack"
|
|
|
27
27
|
import type { TaskCommand, TaskEvent, TaskItem } from "./types"
|
|
28
28
|
import { WorkerTaskHistory, indexTasksByWorker } from "./worker-link"
|
|
29
29
|
import { WorkerCard } from "../workers/worker-card"
|
|
30
|
+
import { WorkerSetupTimeline } from "../workers/worker-setup-timeline"
|
|
30
31
|
|
|
31
32
|
const ev = (seq: number, type: string, payload: Record<string, unknown>, ts = `2026-09-24T10:00:${String(seq).padStart(2, "0")}Z`): TaskEvent => ({
|
|
32
33
|
seq,
|
|
@@ -103,6 +104,23 @@ describe("boot steps", () => {
|
|
|
103
104
|
expect(steps.find((s) => s.key === "session")).toMatchObject({ state: "running", detail: "starts as soon as the machine is ready" })
|
|
104
105
|
})
|
|
105
106
|
|
|
107
|
+
it("a machine from a snapshot: its setup runs until the catch-up (postSnapshot) is over", () => {
|
|
108
|
+
const worker = { id: "w1", name: "sbx-1", state: "setup", dockerState: "running", createdAt: "2026-09-20T00:00:00Z" }
|
|
109
|
+
const setup = { phase: "ready", postCreate: "done", postStart: "done", postSnapshot: "running" }
|
|
110
|
+
const steps = bootSteps({ task: task({ state: "queued", branch: null }), worker, setup, commands: [] })
|
|
111
|
+
expect(steps.find((s) => s.key === "container")?.state).toBe("done")
|
|
112
|
+
expect(steps.find((s) => s.key === "setup")).toMatchObject({ state: "running", detail: "Running post-snapshot command…" })
|
|
113
|
+
const after = bootSteps({ task: task({ state: "queued", branch: null }), worker: { ...worker, state: "ready" }, setup: { ...setup, postSnapshot: "done" }, commands: [] })
|
|
114
|
+
expect(after.find((s) => s.key === "setup")?.state).toBe("done")
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it("draws the catch-up as a step after postStart", () => {
|
|
118
|
+
render(<WorkerSetupTimeline status={{ phase: "ready", postCreate: "done", postStart: "done", postSnapshot: "running" }} settingUp />)
|
|
119
|
+
expect(screen.getByText("postSnapshot")).toBeTruthy()
|
|
120
|
+
expect(screen.getByText("Running post-snapshot command…")).toBeTruthy()
|
|
121
|
+
expect(screen.queryByText("Setup complete")).toBeNull()
|
|
122
|
+
})
|
|
123
|
+
|
|
106
124
|
it("says the machine was never allocated on a task that died before one", () => {
|
|
107
125
|
const steps = bootSteps({ task: task({ state: "failed" }), worker: null, commands: [] })
|
|
108
126
|
// A post-mortem drops the container/setup rows: the machine is no longer the task's.
|
|
@@ -25,7 +25,7 @@ export type { WorkerCockpitAction, WorkerCockpitProps } from "./worker-cockpit"
|
|
|
25
25
|
export { IN_FLIGHT_STATUSES, WorkerStatusDot, WorkerStatusPill, inFlightMessage, resolveWorkerStatus, workerStatusConfig } from "./worker-status"
|
|
26
26
|
export type { WorkerStatus, WorkerStatusConfig, WorkerStatusKey } from "./worker-status"
|
|
27
27
|
|
|
28
|
-
export { SetupProgress, StepIndicator, phaseLabel, setupProgress, setupTotalMs } from "./setup-progress"
|
|
28
|
+
export { SetupProgress, StepIndicator, catchingUp, phaseLabel, setupProgress, setupTotalMs } from "./setup-progress"
|
|
29
29
|
export type { SetupProgressProps, StepState } from "./setup-progress"
|
|
30
30
|
|
|
31
31
|
export { WorkerSetupTimeline } from "./worker-setup-timeline"
|
|
@@ -22,6 +22,8 @@ import type { WorkerSetupStatus } from "./types"
|
|
|
22
22
|
*/
|
|
23
23
|
export function setupProgress(status: WorkerSetupStatus | null | undefined): number {
|
|
24
24
|
if (!status) return 5
|
|
25
|
+
// From a snapshot: its setup is the snapshot's, done — what is left is catching up.
|
|
26
|
+
if (catchingUp(status)) return status.postSnapshot === "running" ? 94 : 92
|
|
25
27
|
switch (status.phase) {
|
|
26
28
|
case "initializing": return 10
|
|
27
29
|
case "credentials": return 25
|
|
@@ -43,9 +45,19 @@ export function setupProgress(status: WorkerSetupStatus | null | undefined): num
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
/**
|
|
49
|
+
* A machine started from a snapshot whose catch-up (`postSnapshot`) is still to finish. Not over
|
|
50
|
+
* a failed setup: that one says more.
|
|
51
|
+
*/
|
|
52
|
+
export function catchingUp(status: WorkerSetupStatus | null | undefined): boolean {
|
|
53
|
+
if (!status || status.phase === "error") return false
|
|
54
|
+
return status.postSnapshot === "pending" || status.postSnapshot === "running"
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
/** Human phase label — the line printed above the bar. */
|
|
47
58
|
export function phaseLabel(status: WorkerSetupStatus | null | undefined): string {
|
|
48
59
|
if (!status) return "Starting up…"
|
|
60
|
+
if (catchingUp(status)) return status.postSnapshot === "running" ? "Running post-snapshot command…" : "Catching up from the snapshot…"
|
|
49
61
|
switch (status.phase) {
|
|
50
62
|
case "initializing": return "Starting up…"
|
|
51
63
|
case "credentials": return "Configuring credentials…"
|
|
@@ -15,6 +15,11 @@ export interface WorkerSetupStatus {
|
|
|
15
15
|
repos?: { name?: string; state?: string | null }[] | null
|
|
16
16
|
postCreate?: string | null
|
|
17
17
|
postStart?: string | null
|
|
18
|
+
/**
|
|
19
|
+
* A machine started from a snapshot: the project's command that catches it up with its
|
|
20
|
+
* repositories (`pending` | `running` | `done` | `error`). Absent when there is none to run.
|
|
21
|
+
*/
|
|
22
|
+
postSnapshot?: string | null
|
|
18
23
|
error?: string | null
|
|
19
24
|
/** Per-milestone start timestamps (epoch ms) — `initializing` → `ready` brackets the startup. */
|
|
20
25
|
timings?: Record<string, number> | null
|
|
@@ -4,7 +4,7 @@ import type { ReactNode } from "react"
|
|
|
4
4
|
import { CheckIcon, GitBranchIcon, LoaderIcon, TerminalIcon } from "lucide-react"
|
|
5
5
|
|
|
6
6
|
import { cn } from "../../utils"
|
|
7
|
-
import { StepIndicator, phaseLabel, setupProgress, type StepState } from "./setup-progress"
|
|
7
|
+
import { StepIndicator, catchingUp, phaseLabel, setupProgress, type StepState } from "./setup-progress"
|
|
8
8
|
import type { WorkerSetupStatus } from "./types"
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -46,6 +46,8 @@ function steps(status: WorkerSetupStatus | null): Step[] {
|
|
|
46
46
|
for (const [key, value] of [
|
|
47
47
|
["postCreate", status.postCreate],
|
|
48
48
|
["postStart", status.postStart],
|
|
49
|
+
// A machine from a snapshot: the project's catch-up, after its (the snapshot's) postStart.
|
|
50
|
+
["postSnapshot", status.postSnapshot],
|
|
49
51
|
] as const) {
|
|
50
52
|
if (value == null) continue
|
|
51
53
|
const state = stepState(value)
|
|
@@ -75,7 +77,7 @@ export function WorkerSetupTimeline({
|
|
|
75
77
|
|
|
76
78
|
const pct = setupProgress(status)
|
|
77
79
|
const failed = status?.phase === "error"
|
|
78
|
-
const done = status?.phase === "ready"
|
|
80
|
+
const done = status?.phase === "ready" && !catchingUp(status)
|
|
79
81
|
const rows = steps(status)
|
|
80
82
|
|
|
81
83
|
return (
|
|
@@ -146,6 +148,8 @@ export function WorkerSetupTimeline({
|
|
|
146
148
|
<span
|
|
147
149
|
className={cn(
|
|
148
150
|
"min-w-0 truncate font-mono leading-none",
|
|
151
|
+
// A lifecycle command's name is short and the line's point: its suffix gives way first.
|
|
152
|
+
!step.key.startsWith("repo:") && "shrink-0",
|
|
149
153
|
step.state === "done"
|
|
150
154
|
? "text-muted-foreground/70"
|
|
151
155
|
: step.state === "running"
|
|
@@ -157,7 +161,7 @@ export function WorkerSetupTimeline({
|
|
|
157
161
|
>
|
|
158
162
|
{step.label}
|
|
159
163
|
</span>
|
|
160
|
-
{step.suffix && <span className="font-mono text-muted-foreground/50">{step.suffix}</span>}
|
|
164
|
+
{step.suffix && <span className="min-w-0 truncate font-mono text-muted-foreground/50">{step.suffix}</span>}
|
|
161
165
|
</div>
|
|
162
166
|
))
|
|
163
167
|
) : settingUp ? (
|