@spunto/design-system 0.53.2 → 0.55.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.55.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",
@@ -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
 
@@ -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")
@@ -215,8 +215,17 @@ export interface TaskMachineNode {
215
215
  online?: boolean
216
216
  }
217
217
 
218
- /** A port detected listening inside the task's container. */
218
+ /**
219
+ * A port of the task's machine: detected listening inside it, or declared by its project
220
+ * (devcontainer `forwardPorts` / `portsAttributes`) — or both.
221
+ */
219
222
  export interface TaskMachinePort {
220
223
  port: number
221
224
  process?: string | null
225
+ /** The project's name for it (`portsAttributes[port].label`): shown before the number. */
226
+ label?: string | null
227
+ /** Something listens on it right now. Omitted: listening while the machine runs (a detected port). */
228
+ listening?: boolean
229
+ /** Declared by the project: shown even while nothing listens (greyed), even with the machine parked. */
230
+ declared?: boolean
222
231
  }
@@ -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")