@spunto/design-system 0.58.0 → 0.60.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spunto/design-system",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "description": "Spunto's shared design system — green tokens (conservatory + sprout), color constants, and UI primitives.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -162,7 +162,7 @@ function ConversationRow({
162
162
  ) : task.pendingAction ? (
163
163
  <Loader2Icon className="h-3 w-3 animate-spin" />
164
164
  ) : (
165
- <TaskStateIcon state={task.state} />
165
+ <TaskStateIcon state={task.state} machine={task.machine} machinePaused={task.machinePaused} />
166
166
  )}
167
167
  </span>
168
168
  <span className={cn("min-w-0 flex-1 truncate text-xs pointer-coarse:text-sm", selected ? "font-semibold" : "font-medium")}>
@@ -17,10 +17,11 @@ export {
17
17
  taskPendingActionConfig,
18
18
  taskSpan,
19
19
  taskStateConfig,
20
+ taskMachineStatus,
20
21
  taskStateStyle,
21
22
  useElapsed,
22
23
  } from "./task-state"
23
- export type { TaskStateBadgeProps, TaskStateStyle } from "./task-state"
24
+ export type { TaskStateBadgeProps, TaskStateIconProps, TaskStateStyle } from "./task-state"
24
25
 
25
26
  // ── Lists ───────────────────────────────────────────────────────────────────────────────────
26
27
  export { TaskList } from "./task-list"
@@ -107,6 +108,7 @@ export type {
107
108
  TaskItem,
108
109
  TaskLink,
109
110
  TaskMachineNode,
111
+ TaskMachineState,
110
112
  TaskMachinePort,
111
113
  TaskPatchHunk,
112
114
  TaskPatchLine,
@@ -15,6 +15,7 @@ import {
15
15
 
16
16
  import { cn, formatDuration } from "../../utils"
17
17
  import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "../sheet"
18
+ import { MachinePorts } from "../workers/machine-ports"
18
19
  import { ResourceBars, type WorkerStats } from "../workers/resource-bars"
19
20
  import { SetupWaterfall } from "../workers/setup-waterfall"
20
21
  import { StepIndicator, phaseLabel, setupTotalMs, type StepState } from "../workers/setup-progress"
@@ -110,13 +111,6 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
110
111
  const status = resolveWorkerStatus(worker)
111
112
  const setup = worker.setupStatus ?? null
112
113
  const running = worker.dockerState === "running"
113
- // 8080 is the editor, already its own link; 22 is SSH, not a browser tab.
114
- // A port with no word on it listens while the machine runs — what a detected port always meant.
115
- const shownPorts = ports
116
- .filter((p) => p.port !== 8080 && p.port !== 22)
117
- .map((p) => ({ ...p, live: running && (p.listening ?? true) }))
118
- // Off the machine: only what the project declares is worth saying ("not listening").
119
- .filter((p) => p.live || p.declared)
120
114
  const startup = setupTotalMs(setup)
121
115
  // A terminal task no longer holds its worker: the next task may already be using it. Saying
122
116
  // "Running" without saying whose is how a cockpit lies quietly.
@@ -207,36 +201,7 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
207
201
  )}
208
202
  </div>
209
203
 
210
- {portHref && shownPorts.length > 0 && (
211
- <div className="flex flex-wrap items-center gap-1.5" data-slot="task-machine-ports">
212
- {shownPorts.map((p) => {
213
- const name = p.label ? `${p.label} :${p.port}` : `:${p.port}`
214
- const href = p.live ? portHref(p.port) : undefined
215
- const title = p.live
216
- ? [p.label, p.process, `:${p.port}`].filter(Boolean).join(" · ")
217
- : `${p.label ? `${p.label} · ` : ""}:${p.port} — nothing listens on it${running ? "" : " (the machine is not running)"}`
218
- const tone = p.live
219
- ? "bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20"
220
- : "bg-muted/60 text-muted-foreground/60"
221
- const body = (
222
- <>
223
- <span className={cn("h-1.5 w-1.5 shrink-0 rounded-full", p.live ? "bg-green-500" : "bg-muted-foreground/40")} />
224
- {name}
225
- </>
226
- )
227
- const cls = cn("inline-flex items-center gap-1.5 rounded-md px-2 py-1 font-mono text-[11px] transition-colors", tone)
228
- return href ? (
229
- <a key={p.port} href={href} target="_blank" rel="noreferrer" title={title} data-listening="true" className={cls}>
230
- {body}
231
- </a>
232
- ) : (
233
- <span key={p.port} title={title} data-listening="false" className={cls}>
234
- {body}
235
- </span>
236
- )
237
- })}
238
- </div>
239
- )}
204
+ {portHref && <MachinePorts ports={ports} running={running} portHref={portHref} />}
240
205
 
241
206
  {startup !== null && (
242
207
  <div>
@@ -116,7 +116,7 @@ function NavStatus({ task, action, since }: { task: TaskItem; action: TaskPendin
116
116
  return (
117
117
  <p className="flex items-center gap-1 text-[11px] leading-tight text-muted-foreground">
118
118
  <span className={style.textClass}>
119
- <TaskStateIcon state={task.state} />
119
+ <TaskStateIcon state={task.state} machine={task.machine} machinePaused={task.machinePaused} />
120
120
  </span>
121
121
  {style.label}
122
122
  <span aria-hidden>·</span>
@@ -236,7 +236,7 @@ export function TaskCockpit({
236
236
  <h1 className="flex min-w-0">
237
237
  <TaskTitle title={task.title} onTitleChange={onTitleChange} updating={titleUpdating} className="text-sm font-semibold" />
238
238
  </h1>
239
- <TaskStateBadge state={task.state} pendingAction={action} pendingSince={since} />
239
+ <TaskStateBadge state={task.state} machine={task.machine} machinePaused={task.machinePaused} pendingAction={action} pendingSince={since} />
240
240
  {task.userArchivedAt && <TaskArchivedBadge />}
241
241
  </div>
242
242
 
@@ -95,7 +95,7 @@ function TaskRow<T extends TaskItem>({
95
95
  <Link href={href} className="truncate text-sm font-medium underline-offset-2 hover:underline">
96
96
  {task.title}
97
97
  </Link>
98
- <TaskStateBadge state={task.state} pendingAction={pendingAction} pendingSince={task.pendingSince} />
98
+ <TaskStateBadge state={task.state} machine={task.machine} machinePaused={task.machinePaused} pendingAction={pendingAction} pendingSince={task.pendingSince} />
99
99
 
100
100
  {/* Actions live on the row, not behind a menu: reviewing is the moment the panel exists
101
101
  for. On a task in review they are always visible; a merely live task only offers Drop,
@@ -6,11 +6,12 @@
6
6
  // flame in another.
7
7
 
8
8
  import { useEffect, useState } from "react"
9
- import { CheckCircle2Icon, CircleAlertIcon, ClockIcon, GitPullRequestIcon, Loader2Icon } from "lucide-react"
9
+ import { CheckCircle2Icon, CircleAlertIcon, CircleDotIcon, ClockIcon, Loader2Icon } from "lucide-react"
10
10
 
11
11
  import { cn } from "../../utils"
12
12
  import { Badge } from "../badge"
13
- import type { TaskPendingAction, TaskState } from "./types"
13
+ import { WorkerStatusDot, type WorkerStatusKey } from "../workers/worker-status"
14
+ import type { TaskMachineState, TaskPendingAction, TaskState } from "./types"
14
15
 
15
16
  export interface TaskStateStyle {
16
17
  label: string
@@ -83,17 +84,63 @@ export function isLiveTaskState(state: string): boolean {
83
84
  return state === "queued" || state === "running" || state === "in-review"
84
85
  }
85
86
 
86
- export function TaskStateIcon({ state, className }: { state: string; className?: string }) {
87
+ /**
88
+ * The machine of a task in the sandboxes' own words — the dot and its colour (`WorkerStatusDot`:
89
+ * green pulsing while it runs, blue paused, grey stopped), and what it means.
90
+ */
91
+ export function taskMachineStatus(machine: TaskMachineState, paused = false): { key: WorkerStatusKey; label: string } {
92
+ switch (machine) {
93
+ case "awake":
94
+ return { key: "running", label: "Its machine is running" }
95
+ case "starting":
96
+ return { key: "pending", label: "Its machine is starting" }
97
+ case "parking":
98
+ return paused ? { key: "pausing", label: "Its machine is pausing" } : { key: "stopping", label: "Its machine is stopping" }
99
+ case "parked":
100
+ return paused
101
+ ? { key: "paused", label: "Its machine is paused — memory kept" }
102
+ : { key: "stopped", label: "Its machine is stopped — disk kept" }
103
+ case "unreachable":
104
+ return { key: "not_found", label: "Its machine is unreachable" }
105
+ default:
106
+ return { key: "error", label: "Its machine is gone" }
107
+ }
108
+ }
109
+
110
+ export interface TaskStateIconProps {
111
+ state: string
112
+ /**
113
+ * The task's machine (`TaskItem.machine`). In review, the icon *is* its dot: what waits for a
114
+ * human is the review, and what the reader wants to know next is whether the box behind it still
115
+ * runs, sleeps with its memory, or is stopped. Omitted: a neutral ring with a dot — the same shape, no machine to colour it.
116
+ */
117
+ machine?: TaskMachineState | null
118
+ machinePaused?: boolean
119
+ className?: string
120
+ }
121
+
122
+ export function TaskStateIcon({ state, machine, machinePaused, className }: TaskStateIconProps) {
87
123
  const c = cn("h-3 w-3", className)
88
124
  if (state === "queued") return <ClockIcon className={c} />
89
125
  if (state === "running") return <Loader2Icon className={cn(c, "animate-spin")} />
90
- if (state === "in-review") return <GitPullRequestIcon className={c} />
126
+ if (state === "in-review" && machine) {
127
+ const { key, label } = taskMachineStatus(machine, machinePaused)
128
+ return (
129
+ <span role="img" aria-label={label} title={label} data-machine={key} className={cn(c, "inline-flex shrink-0 items-center justify-center")}>
130
+ <WorkerStatusDot status={key} />
131
+ </span>
132
+ )
133
+ }
134
+ if (state === "in-review") return <CircleDotIcon className={c} />
91
135
  if (state === "done") return <CheckCircle2Icon className={c} />
92
136
  return <CircleAlertIcon className={c} />
93
137
  }
94
138
 
95
139
  export interface TaskStateBadgeProps {
96
140
  state: string
141
+ /** In review: the task's machine, drawn as its dot — see `TaskStateIcon`. */
142
+ machine?: TaskMachineState | null
143
+ machinePaused?: boolean
97
144
  pendingAction?: TaskPendingAction | null
98
145
  pendingSince?: string | null
99
146
  className?: string
@@ -106,12 +153,12 @@ export interface TaskStateBadgeProps {
106
153
  * badges saying one thing, and the state is the half that is about to stop being true. A dashed
107
154
  * border is the whole of the extra vocabulary, and the clock answers "is this stuck?".
108
155
  */
109
- export function TaskStateBadge({ state, pendingAction = null, pendingSince = null, className }: TaskStateBadgeProps) {
156
+ export function TaskStateBadge({ state, machine, machinePaused, pendingAction = null, pendingSince = null, className }: TaskStateBadgeProps) {
110
157
  if (pendingAction) return <TaskPendingBadge action={pendingAction} since={pendingSince} className={className} />
111
158
  const style = taskStateStyle(state)
112
159
  return (
113
160
  <Badge variant="outline" className={cn("h-5 shrink-0 gap-1 px-1.5 text-[10px]", style.className, className)}>
114
- <TaskStateIcon state={state} />
161
+ <TaskStateIcon state={state} machine={machine} machinePaused={machinePaused} />
115
162
  {style.label}
116
163
  </Badge>
117
164
  )
@@ -19,6 +19,12 @@ export type TaskState = "queued" | "running" | "in-review" | "done" | "failed"
19
19
  */
20
20
  export type TaskPendingAction = "accepting" | "dropping" | "replying"
21
21
 
22
+ /**
23
+ * Where the sandbox a task holds stands (the API's `Task.machine`) — a second axis next to `state`.
24
+ * `parked` is stopped with its disk kept; `machinePaused` says when its memory was kept too.
25
+ */
26
+ export type TaskMachineState = "starting" | "awake" | "parking" | "parked" | "unreachable" | "lost"
27
+
22
28
  /** One of a task's `links`: `label` → `url` (http(s)). */
23
29
  export interface TaskLink {
24
30
  label: string
@@ -54,6 +60,10 @@ export interface TaskItem {
54
60
  pendingAction?: TaskPendingAction | null
55
61
  /** When that was asked for. What the spinner counts from — across reloads and readers. */
56
62
  pendingSince?: string | null
63
+ /** Where the sandbox it holds stands — the API's `Task.machine`. What "in review" draws its dot from. */
64
+ machine?: TaskMachineState | null
65
+ /** With `machine` `parked`/`parking`: paused rather than stopped — its memory kept. */
66
+ machinePaused?: boolean
57
67
  /** When a member put this finished task away — it then lives in the « Archived » view. Null = not archived. */
58
68
  userArchivedAt?: string | null
59
69
  }
@@ -171,7 +171,7 @@ export function WorkerTaskHistory({
171
171
  className="block rounded-lg border border-border/50 bg-muted/20 px-3 py-2.5 transition-colors hover:bg-muted/40"
172
172
  >
173
173
  <div className="flex items-center justify-between gap-2">
174
- <TaskStateBadge state={current.state} pendingAction={current.pendingAction} pendingSince={current.pendingSince} />
174
+ <TaskStateBadge state={current.state} machine={current.machine} machinePaused={current.machinePaused} pendingAction={current.pendingAction} pendingSince={current.pendingSince} />
175
175
  <span className="shrink-0 text-[10px] text-muted-foreground/60">{formatRelativeTime(at(current))}</span>
176
176
  </div>
177
177
  <p className="mt-1.5 line-clamp-2 text-xs font-medium text-foreground">{current.title}</p>
@@ -18,6 +18,8 @@ export { ActionMenu } from "../action-menu"
18
18
  export type { ActionMenuProps, ActionMenuItem, ActionMenuEntry, ActionMenuLinkRender } from "../action-menu"
19
19
 
20
20
  export { WorkerCockpit } from "./worker-cockpit"
21
+ export { MachinePorts, machinePortsShown } from "./machine-ports"
22
+ export type { MachinePortsProps } from "./machine-ports"
21
23
  export type { WorkerCockpitAction, WorkerCockpitProps } from "./worker-cockpit"
22
24
 
23
25
  export { IN_FLIGHT_STATUSES, WorkerStatusDot, WorkerStatusPill, inFlightMessage, resolveWorkerStatus, workerStatusConfig } from "./worker-status"
@@ -0,0 +1,63 @@
1
+ "use client"
2
+
3
+ import { cn } from "../../utils"
4
+ import type { TaskMachinePort } from "../tasks/types"
5
+
6
+ /**
7
+ * A machine's ports, as chips: the project's label before the number, green (and a link, in a new
8
+ * tab) while something listens, greyed while nothing does. One rule for every surface that shows
9
+ * them — a task's sidebar (`TaskMachine`) and a sandbox's cockpit (`WorkerCockpit`).
10
+ *
11
+ * 8080 is the editor, already its own link; 22 is SSH, not a browser tab. A port with no word on
12
+ * it listens while the machine runs — what a detected port always meant. Off the machine, only
13
+ * what the project declares is worth saying ("not listening").
14
+ */
15
+ export function machinePortsShown(ports: TaskMachinePort[], running: boolean) {
16
+ return ports
17
+ .filter((p) => p.port !== 8080 && p.port !== 22)
18
+ .map((p) => ({ ...p, live: running && (p.listening ?? true) }))
19
+ .filter((p) => p.live || p.declared)
20
+ }
21
+
22
+ export interface MachinePortsProps {
23
+ ports: TaskMachinePort[]
24
+ /** The machine runs: without it, nothing is live and only declared ports show, greyed. */
25
+ running: boolean
26
+ portHref: (port: number) => string | undefined
27
+ className?: string
28
+ }
29
+
30
+ export function MachinePorts({ ports, running, portHref, className }: MachinePortsProps) {
31
+ const shown = machinePortsShown(ports, running)
32
+ if (shown.length === 0) return null
33
+ return (
34
+ <div className={cn("flex flex-wrap items-center gap-1.5", className)} data-slot="task-machine-ports">
35
+ {shown.map((p) => {
36
+ const name = p.label ? `${p.label} :${p.port}` : `:${p.port}`
37
+ const href = p.live ? portHref(p.port) : undefined
38
+ const title = p.live
39
+ ? [p.label, p.process, `:${p.port}`].filter(Boolean).join(" · ")
40
+ : `${p.label ? `${p.label} · ` : ""}:${p.port} — nothing listens on it${running ? "" : " (the machine is not running)"}`
41
+ const tone = p.live
42
+ ? "bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20"
43
+ : "bg-muted/60 text-muted-foreground/60"
44
+ const body = (
45
+ <>
46
+ <span className={cn("h-1.5 w-1.5 shrink-0 rounded-full", p.live ? "bg-green-500" : "bg-muted-foreground/40")} />
47
+ {name}
48
+ </>
49
+ )
50
+ const cls = cn("inline-flex items-center gap-1.5 rounded-md px-2 py-1 font-mono text-[11px] transition-colors", tone)
51
+ return href ? (
52
+ <a key={p.port} href={href} target="_blank" rel="noreferrer" title={title} data-listening="true" className={cls}>
53
+ {body}
54
+ </a>
55
+ ) : (
56
+ <span key={p.port} title={title} data-listening="false" className={cls}>
57
+ {body}
58
+ </span>
59
+ )
60
+ })}
61
+ </div>
62
+ )
63
+ }
@@ -51,7 +51,8 @@ import { WorkerSetupTimeline } from "./worker-setup-timeline"
51
51
  import { IN_FLIGHT_STATUSES, WorkerStatusDot, WorkerStatusPill, inFlightMessage, resolveWorkerStatus } from "./worker-status"
52
52
  import { WorkerStatusHistory } from "./worker-status-history"
53
53
  import { WorkerTaskHistory } from "../tasks/worker-link"
54
- import type { TaskItem } from "../tasks/types"
54
+ import type { TaskItem, TaskMachinePort } from "../tasks/types"
55
+ import { MachinePorts, machinePortsShown } from "./machine-ports"
55
56
 
56
57
  type CockpitTab = "logs" | "terminal"
57
58
 
@@ -97,8 +98,11 @@ export interface WorkerCockpitProps {
97
98
  /** Chip → URL (e.g. code-server at that folder). Returning undefined renders a static row. */
98
99
  repoHref?: (repo: GitRepoStatus) => string | undefined
99
100
 
100
- /** Ports detected inside the container. Only pass these while relevant (running, past setup). */
101
- ports?: { port: number; process?: string }[]
101
+ /**
102
+ * Its ports, drawn as a task's sidebar draws them (`MachinePorts`): the project's label, green and
103
+ * opening in a new tab while something listens, greyed while a declared one doesn't.
104
+ */
105
+ ports?: TaskMachinePort[]
102
106
  portHref?: (port: number) => string | undefined
103
107
 
104
108
  onAddTag?: (tag: string, next: string[]) => void
@@ -392,27 +396,10 @@ export function WorkerCockpit({
392
396
  </div>
393
397
  )}
394
398
 
395
- {ports.length > 0 && (
399
+ {portHref && machinePortsShown(ports, status.running).length > 0 && (
396
400
  <div>
397
401
  <SectionLabel>Open ports</SectionLabel>
398
- <div className="space-y-1.5">
399
- {ports.map((p) => {
400
- const href = portHref?.(p.port)
401
- return (
402
- <div key={p.port} className="flex items-center justify-between rounded-lg border border-border/50 bg-muted/20 px-3 py-2">
403
- <div className="flex min-w-0 items-center gap-2">
404
- <span className="font-mono text-xs text-foreground">:{p.port}</span>
405
- {p.process && <span className="truncate text-[11px] text-muted-foreground">{p.process}</span>}
406
- </div>
407
- {href && (
408
- <Link href={href} className={cn(buttonVariants({ variant: "ghost", size: "sm" }), "h-6 shrink-0 gap-1 px-2 text-[11px] text-muted-foreground")}>
409
- <ExternalLinkIcon className="h-3 w-3" />Open
410
- </Link>
411
- )}
412
- </div>
413
- )
414
- })}
415
- </div>
402
+ <MachinePorts ports={ports} running={status.running} portHref={portHref} />
416
403
  </div>
417
404
  )}
418
405
 
@@ -544,9 +531,9 @@ export function WorkerCockpit({
544
531
  </div>
545
532
  <div className="flex shrink-0 items-center gap-2">
546
533
  {settled && editorHref && (
547
- <Link href={editorHref} className={cn(buttonVariants({ variant: "default", size: "sm" }), "h-8 gap-1.5 px-3 text-xs")}>
534
+ <a href={editorHref} target="_blank" rel="noreferrer" className={cn(buttonVariants({ variant: "default", size: "sm" }), "h-8 gap-1.5 px-3 text-xs")}>
548
535
  <Code2Icon className="h-3.5 w-3.5" />Open IDE<ExternalLinkIcon className="h-2.5 w-2.5 opacity-70" />
549
- </Link>
536
+ </a>
550
537
  )}
551
538
  {settled && onPause && (
552
539
  <Button variant="ghost" size="sm" className="h-8 gap-1.5 px-3 text-xs text-muted-foreground" disabled={pausing || stopping} onClick={onPause}>