@spunto/design-system 0.59.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.59.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,
@@ -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>