@spunto/design-system 0.53.2 → 0.56.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.53.2",
3
+ "version": "0.56.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",
@@ -104,6 +104,7 @@ export type {
104
104
  TaskFilePatch,
105
105
  TaskFileRef,
106
106
  TaskItem,
107
+ TaskLink,
107
108
  TaskMachineNode,
108
109
  TaskMachinePort,
109
110
  TaskPatchHunk,
@@ -7,7 +7,6 @@ import {
7
7
  ExternalLinkIcon,
8
8
  GitBranchIcon,
9
9
  MoonIcon,
10
- NetworkIcon,
11
10
  ServerIcon,
12
11
  SparklesIcon,
13
12
  TerminalIcon,
@@ -79,7 +78,11 @@ export interface TaskMachineProps {
79
78
  node?: TaskMachineNode | null
80
79
  /** Live container stats — pass them only while the task is live and the container up. */
81
80
  stats?: WorkerStats | null
82
- /** Ports detected listening in the container (editor and SSH are filtered out). */
81
+ /**
82
+ * Its ports (editor and SSH are filtered out): detected listening, and those the project declares
83
+ * — green while something listens, greyed (no link) while nothing does. Declared ones show even
84
+ * with the machine parked: the reader sees what the app will serve, and that it doesn't now.
85
+ */
83
86
  ports?: TaskMachinePort[]
84
87
  /** The worker's own page (logs, terminal, files). */
85
88
  workerHref?: string
@@ -108,7 +111,12 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
108
111
  const setup = worker.setupStatus ?? null
109
112
  const running = worker.dockerState === "running"
110
113
  // 8080 is the editor, already its own link; 22 is SSH, not a browser tab.
111
- const detectedPorts = ports.filter((p) => p.port !== 8080 && p.port !== 22)
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)
112
120
  const startup = setupTotalMs(setup)
113
121
  // A terminal task no longer holds its worker: the next task may already be using it. Saying
114
122
  // "Running" without saying whose is how a cockpit lies quietly.
@@ -199,20 +207,34 @@ export function TaskMachine({ task, worker, node = null, stats = null, ports = [
199
207
  )}
200
208
  </div>
201
209
 
202
- {running && portHref && detectedPorts.length > 0 && (
203
- <div className="flex flex-wrap items-center gap-1.5">
204
- {detectedPorts.map((p) => (
205
- <a
206
- key={p.port}
207
- href={portHref(p.port)}
208
- target="_blank"
209
- rel="noreferrer"
210
- title={p.process ? `${p.process} · :${p.port}` : `Port ${p.port}`}
211
- className="inline-flex items-center gap-1 rounded-md bg-muted px-2 py-1 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary"
212
- >
213
- <NetworkIcon className="h-3 w-3 shrink-0" />:{p.port}
214
- </a>
215
- ))}
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
+ })}
216
238
  </div>
217
239
  )}
218
240
 
@@ -132,6 +132,8 @@ export function TaskDetails({
132
132
  }: TaskDetailsProps) {
133
133
  const sheet = useContext(TaskDetailsSheetContext)
134
134
  const meta = task.meta && Object.keys(task.meta).length > 0 ? task.meta : null
135
+ const links = task.links && task.links.length > 0 ? task.links : null
136
+ const metadata = task.metadata && Object.keys(task.metadata).length > 0 ? Object.entries(task.metadata) : null
135
137
  const ran = task.completedAt ? taskSpan(task.startedAt ?? task.createdAt, task.completedAt) : null
136
138
 
137
139
  return (
@@ -155,6 +157,28 @@ export function TaskDetails({
155
157
  )}
156
158
 
157
159
  <div className={cn("grid grid-cols-2 gap-3", variant === "sidebar" && "mt-3")}>
160
+ {/* First: where the work came from is what a reader arriving from a list asks before anything else. */}
161
+ {links && (
162
+ <div className="col-span-2">
163
+ <Fact label={links.length === 1 ? "Link" : "Links"}>
164
+ <span className="flex flex-wrap gap-x-3 gap-y-1">
165
+ {links.map((link, i) => (
166
+ <a
167
+ key={`${i}-${link.url}`}
168
+ href={link.url}
169
+ target="_blank"
170
+ rel="noreferrer"
171
+ title={link.url}
172
+ className="flex min-w-0 items-center gap-1 text-primary hover:underline"
173
+ >
174
+ <span className="truncate">{link.label}</span>
175
+ <ExternalLinkIcon className="h-3 w-3 shrink-0" />
176
+ </a>
177
+ ))}
178
+ </span>
179
+ </Fact>
180
+ </div>
181
+ )}
158
182
  {/* Not truncated: a branch name ends in the part that identifies the task. */}
159
183
  {task.branch && (
160
184
  <div className="col-span-2">
@@ -229,6 +253,20 @@ export function TaskDetails({
229
253
  )}
230
254
  </Block>
231
255
 
256
+ {/* For machines, not people — folded, but there to check what an integration attached. */}
257
+ {metadata && (
258
+ <Block variant={variant} title="Metadata" hint={`${metadata.length} key${metadata.length === 1 ? "" : "s"}`} defaultOpen={false}>
259
+ <dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 font-mono text-[11px]">
260
+ {metadata.map(([key, value]) => (
261
+ <div key={key} className="contents">
262
+ <dt className="text-muted-foreground">{key}</dt>
263
+ <dd className="min-w-0 break-all">{value}</dd>
264
+ </div>
265
+ ))}
266
+ </dl>
267
+ </Block>
268
+ )}
269
+
232
270
  {/* Only ever filled by a status command that no longer exists — kept for the tasks that ran under it. */}
233
271
  {meta && (
234
272
  <Block variant={variant} title="Reported" hint="from a removed setting" defaultOpen={false}>
@@ -13,7 +13,7 @@ import { renderInlineMarkdown } from "./agent-markdown"
13
13
  import { emptyCommandTerminalState, planCommandTerminalWrites } from "./command-terminal"
14
14
  import { TaskComposer } from "./composer"
15
15
  import { foldTimeline } from "./event-stream"
16
- import { TaskBoot, bootSteps } from "./machine"
16
+ import { TaskBoot, TaskMachine, bootSteps } from "./machine"
17
17
  import { NewTaskComposer } from "./new-task-composer"
18
18
  import { clearTaskDraft, readTaskDraft } from "./prompt-draft"
19
19
  import { NewTaskDialog, type NewTaskCustomField } from "./new-task-dialog"
@@ -238,6 +238,36 @@ describe("worker ↔ task", () => {
238
238
  })
239
239
  })
240
240
 
241
+ describe("TaskMachine — its ports", () => {
242
+ const task = { id: "t1", state: "in-review" as const }
243
+ const worker = (dockerState: string) => ({ id: "sbx1", name: "task-1", state: dockerState === "running" ? "ready" : "stopped", dockerState }) as never
244
+ const ports = [
245
+ { port: 5173, label: "App", process: "node", listening: true, declared: true },
246
+ { port: 6006, label: "Storybook", listening: false, declared: true },
247
+ { port: 9229, process: "node", listening: true },
248
+ { port: 8080, process: "code-server", listening: true },
249
+ ]
250
+ const chips = (container: HTMLElement) =>
251
+ [...container.querySelectorAll('[data-slot="task-machine-ports"] > *')].map((e) => `${e.textContent}|${e.getAttribute("data-listening")}|${e.tagName}`)
252
+
253
+ it("names a declared port by its label, green and a link while it listens, greyed and no link while it does not", () => {
254
+ const { container } = render(<TaskMachine task={task as never} worker={worker("running")} ports={ports} portHref={(p) => `https://port-${p}`} />)
255
+ expect(chips(container)).toEqual(["App :5173|true|A", "Storybook :6006|false|SPAN", ":9229|true|A"])
256
+ expect(container.querySelector('a[href="https://port-5173"]')).not.toBeNull()
257
+ expect(container.querySelector('[title*="nothing listens"]')?.textContent).toBe("Storybook :6006")
258
+ })
259
+
260
+ it("parked: the declared ports stay, greyed — what the app will serve, and that it doesn't now", () => {
261
+ const { container } = render(<TaskMachine task={task as never} worker={worker("stopped")} ports={ports} portHref={(p) => `https://port-${p}`} />)
262
+ expect(chips(container)).toEqual(["App :5173|false|SPAN", "Storybook :6006|false|SPAN"])
263
+ })
264
+
265
+ it("a detected port with no word on it listens while the machine runs, as before", () => {
266
+ const { container } = render(<TaskMachine task={task as never} worker={worker("running")} ports={[{ port: 3000, process: "next" }]} portHref={() => "#"} />)
267
+ expect(chips(container)).toEqual([":3000|true|A"])
268
+ })
269
+ })
270
+
241
271
  describe("formatters", () => {
242
272
  it("reads token counts as orders of magnitude", () => {
243
273
  expect(formatTokens(812)).toBe("812")
@@ -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
+ /** One of a task's `links`: `label` → `url` (http(s)). */
23
+ export interface TaskLink {
24
+ label: string
25
+ url: string
26
+ }
27
+
22
28
  /** A task as the list rows, the cockpit and its sidebar draw it. */
23
29
  export interface TaskItem {
24
30
  id: string
@@ -33,6 +39,10 @@ export interface TaskItem {
33
39
  outcomeLabel?: string | null
34
40
  /** Legacy: what a removed status command once reported. Drawn as JSON when present. */
35
41
  meta?: Record<string, unknown> | null
42
+ /** Pages about the task elsewhere — the card or issue it came from — set by whoever delegated it. */
43
+ links?: TaskLink[] | null
44
+ /** String pairs its caller attached, for machines. Drawn as a key/value list, never interpreted. */
45
+ metadata?: Record<string, string> | null
36
46
  error?: string | null
37
47
  createdAt: string
38
48
  /** When the task last moved — a turn, a state change. What lists sort and date rows on. */
@@ -215,8 +225,17 @@ export interface TaskMachineNode {
215
225
  online?: boolean
216
226
  }
217
227
 
218
- /** A port detected listening inside the task's container. */
228
+ /**
229
+ * A port of the task's machine: detected listening inside it, or declared by its project
230
+ * (devcontainer `forwardPorts` / `portsAttributes`) — or both.
231
+ */
219
232
  export interface TaskMachinePort {
220
233
  port: number
221
234
  process?: string | null
235
+ /** The project's name for it (`portsAttributes[port].label`): shown before the number. */
236
+ label?: string | null
237
+ /** Something listens on it right now. Omitted: listening while the machine runs (a detected port). */
238
+ listening?: boolean
239
+ /** Declared by the project: shown even while nothing listens (greyed), even with the machine parked. */
240
+ declared?: boolean
222
241
  }
@@ -103,4 +103,10 @@ describe("resolveWorkerStatus — pause, stop, snapshot (RFC 0039 § 20)", () =>
103
103
  expect(resolveWorkerStatus({ id: "s", state: "pausing" }).label).toBe("Pausing…")
104
104
  expect(resolveWorkerStatus({ id: "s", state: "snapshotting" }).label).toBe("Snapshotting…")
105
105
  })
106
+
107
+ it("une reprise n'est pas un setup : sa pastille, son bandeau, et le setup d'avant n'est pas « en cours »", () => {
108
+ const s = resolveWorkerStatus({ id: "s", state: "resuming", setupStatus: { phase: "ready", codeServer: "ready", repos: [], features: [], postCreate: "done", postStart: "done" } } as never)
109
+ expect(s).toMatchObject({ key: "resuming", label: "Resuming…", running: false, settingUp: false })
110
+ expect(IN_FLIGHT_STATUSES.has(s.key)).toBe(true)
111
+ })
106
112
  })
@@ -42,6 +42,7 @@ export type WorkerStatusKey =
42
42
  | "pausing"
43
43
  | "paused"
44
44
  | "snapshotting"
45
+ | "resuming"
45
46
 
46
47
  export interface WorkerStatusConfig {
47
48
  label: string
@@ -116,13 +117,17 @@ export const workerStatusConfig: Record<WorkerStatusKey, WorkerStatusConfig> = {
116
117
  // Its memory being written: nothing can be asked of it until then.
117
118
  pausing: { ...BUSY, label: "Pausing…" },
118
119
  snapshotting: { ...BUSY, label: "Snapshotting…" },
120
+ // Its memory loaded back after a pause: on its way, but nothing is being set up — its processes
121
+ // come back as they were. Not a setup state: as `starting`, the cockpit drew the previous boot's
122
+ // finished setup in yellow, "Ready 100%", for the second the resume takes (2026-10-27).
123
+ resuming: { ...BUSY, label: "Resuming…" },
119
124
  }
120
125
 
121
126
  /**
122
127
  * Statuses during which nothing can be asked of a worker or a sandbox: its memory is being written
123
128
  * (`pausing`, `snapshotting`), or it is on its way down. A host greys its actions out on these.
124
129
  */
125
- export const IN_FLIGHT_STATUSES: ReadonlySet<WorkerStatusKey> = new Set(["pausing", "snapshotting", "stopping", "deleting"])
130
+ export const IN_FLIGHT_STATUSES: ReadonlySet<WorkerStatusKey> = new Set(["pausing", "snapshotting", "stopping", "deleting", "resuming"])
126
131
 
127
132
  /** What a status in flight means for the reader, in one line — the cockpit's banner. */
128
133
  export const inFlightMessage: Partial<Record<WorkerStatusKey, string>> = {
@@ -130,6 +135,7 @@ export const inFlightMessage: Partial<Record<WorkerStatusKey, string>> = {
130
135
  snapshotting: "Snapshotting — frozen while its memory is written. It runs again once the snapshot is taken.",
131
136
  stopping: "Stopping — shutting down. Its memory is not kept: the next start boots it.",
132
137
  deleting: "Deleting…",
138
+ resuming: "Resuming — its memory is loaded back: processes, terminals and sessions are where they were.",
133
139
  }
134
140
 
135
141
  export interface WorkerStatus extends WorkerStatusConfig {
@@ -209,6 +215,8 @@ export function resolveWorkerStatus(worker: WorkerCardWorker): WorkerStatus {
209
215
  if (state === "paused") return of("paused")
210
216
  // Frozen for a moment, not running for anyone who would act on it now (`running: false`).
211
217
  if (state === "snapshotting") return of("snapshotting")
218
+ // Back from a pause: not a setup, whatever `setupStatus` says (it is the boot's, already done).
219
+ if (state === "resuming") return of("resuming")
212
220
  // Le node est injoignable : on ne sait pas. Surtout pas `settingUp` — annoncer une progression
213
221
  // pour une machine qu'on ne voit plus est exactement ce que ce statut existe pour éviter.
214
222
  if (state === "unknown") return of("unknown")