@spunto/design-system 0.73.0 → 0.75.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.73.0",
3
+ "version": "0.75.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",
@@ -18,7 +18,6 @@ import {
18
18
  import { cn } from "../../utils"
19
19
  import { Button } from "../button"
20
20
  import { Input } from "../input"
21
- import { Switch } from "../switch"
22
21
  import { Textarea } from "../textarea"
23
22
  import { ExtensionPicker } from "./extension-picker"
24
23
  import { FeaturePicker, type FeaturePickerProps } from "./feature-picker"
@@ -55,7 +54,6 @@ const SECTION_META: Record<
55
54
  lifecycle: { icon: TerminalIcon, accent: "ship", title: "Lifecycle", hint: "Commands run on create & on every start" },
56
55
  ports: { icon: NetworkIcon, accent: "run", title: "Ports", hint: "Automatically forwarded for every worker" },
57
56
  prewarm: { icon: LayersIcon, accent: "build", title: "Prewarm images", hint: "Docker images pre-loaded into the worker's docker-in-docker on first start" },
58
- docker: { icon: BoxIcon, accent: "build", title: "Docker-in-Docker", hint: "Run workers privileged with a Docker daemon inside" },
59
57
  secrets: { icon: KeyRoundIcon, accent: "flame", title: "Secrets", hint: "Env vars injected into every workspace" },
60
58
  }
61
59
 
@@ -71,7 +69,6 @@ const DEFAULT_ADVANCED: InternalSectionId[] = [
71
69
  "lifecycle",
72
70
  "ports",
73
71
  "prewarm",
74
- "docker",
75
72
  "secrets",
76
73
  ]
77
74
 
@@ -109,9 +106,9 @@ export const DEFAULT_GROUPS: ProjectFormGroup[] = [
109
106
  {
110
107
  id: "runtime",
111
108
  title: "Runtime",
112
- hint: "How a running worker behaves: forwarded ports, preloaded images, Docker inside.",
109
+ hint: "How a running worker behaves: forwarded ports, preloaded images.",
113
110
  icon: NetworkIcon,
114
- sections: ["ports", "prewarm", "docker"],
111
+ sections: ["ports", "prewarm"],
115
112
  },
116
113
  {
117
114
  id: "secrets",
@@ -697,23 +694,6 @@ export function ProjectForm<TValue extends ProjectFormValue = ProjectFormValue>(
697
694
  </Field>
698
695
  )
699
696
 
700
- case "docker":
701
- return (
702
- <label className="flex cursor-pointer items-start justify-between gap-4 rounded-md border bg-muted/30 px-3 py-2.5">
703
- <span className="space-y-0.5">
704
- <span className="block text-sm leading-none font-medium">Enable Docker-in-Docker</span>
705
- <span className="block text-xs text-muted-foreground">
706
- Runs each worker privileged with <code>dockerd</code> and dedicated{" "}
707
- <code>/var/lib/docker</code> volumes. Use with a base image that bakes Docker — no{" "}
708
- <code>docker-in-docker</code> feature needed.
709
- </span>
710
- </span>
711
- <Switch
712
- checked={value.dockerInDocker}
713
- onCheckedChange={(checked) => patch({ dockerInDocker: checked })}
714
- />
715
- </label>
716
- )
717
697
 
718
698
  case "secrets":
719
699
  return (
@@ -809,8 +789,6 @@ export function manifestRows<TValue extends ProjectFormValue>(
809
789
  rows.push({ label: "ports", value: value.forwardPorts.join(", ") || "—", done: value.forwardPorts.length > 0 })
810
790
  if (shown.has("prewarm"))
811
791
  rows.push({ label: "prewarm", value: `${value.prewarmImages.length}`, done: value.prewarmImages.length > 0 })
812
- if (shown.has("docker"))
813
- rows.push({ label: "docker", value: value.dockerInDocker ? "in-docker" : "off", done: value.dockerInDocker })
814
792
  if (shown.has("secrets")) {
815
793
  const n = value.secrets.length + savedSecrets.filter((x) => !value.removedSecretIds.includes(x.id)).length
816
794
  rows.push({ label: "secrets", value: `${n}`, done: n > 0 })
@@ -47,8 +47,6 @@ export function sectionSummary<TValue extends ProjectFormValue>(
47
47
  return value.forwardPorts.length ? `ports ${value.forwardPorts.join(", ")}` : null
48
48
  case "prewarm":
49
49
  return value.prewarmImages.length ? `${value.prewarmImages.length} prewarm` : null
50
- case "docker":
51
- return value.dockerInDocker ? "docker-in-docker" : null
52
50
  case "secrets": {
53
51
  const n = value.secrets.length + savedSecrets.filter((x) => !value.removedSecretIds.includes(x.id)).length
54
52
  return n ? plural(n, "secret") : null
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // Same rule as the rest of the package: this is NOT an app's OpenAPI type. The
4
4
  // dashboard's create payload and its update payload already differ from each
5
- // other (creation has no ports/prewarm/dind, update has no inline secrets), and
5
+ // other (creation has no ports/prewarm, update has no inline secrets), and
6
6
  // Spunto Lite's project is smaller still. So the form owns one **complete**
7
7
  // value — every field present, never undefined — and each app maps it to its own
8
8
  // payload on submit. A complete value is what makes the form controllable
@@ -100,10 +100,9 @@ export interface ProjectFormValue {
100
100
  removedSecretIds: string[]
101
101
  forwardPorts: number[]
102
102
  prewarmImages: string[]
103
- dockerInDocker: boolean
104
103
  }
105
104
 
106
- /** The ten sections the package models and draws itself. */
105
+ /** The nine sections the package models and draws itself. */
107
106
  export type InternalSectionId =
108
107
  | "identity"
109
108
  | "image"
@@ -113,14 +112,13 @@ export type InternalSectionId =
113
112
  | "lifecycle"
114
113
  | "ports"
115
114
  | "prewarm"
116
- | "docker"
117
115
  | "secrets"
118
116
 
119
117
  /**
120
- * A section of the form: one of the ten above, or the id of a card the app
118
+ * A section of the form: one of the nine above, or the id of a card the app
121
119
  * brings itself through `customSections`.
122
120
  *
123
- * Open on purpose, and `(string & {})` rather than plain `string` so the ten
121
+ * Open on purpose, and `(string & {})` rather than plain `string` so the nine
124
122
  * known ids keep their autocompletion — a closed union meant an app with a field
125
123
  * of its own had to either hang it under an unrelated section via `extras` or
126
124
  * draw its own card outside the form, losing the numbering, the fold and the
@@ -193,11 +191,10 @@ export const INTERNAL_SECTION_IDS: readonly InternalSectionId[] = [
193
191
  "lifecycle",
194
192
  "ports",
195
193
  "prewarm",
196
- "docker",
197
194
  "secrets",
198
195
  ]
199
196
 
200
- /** True for the ten sections the package draws itself. */
197
+ /** True for the nine sections the package draws itself. */
201
198
  export function isInternalSectionId(id: ProjectFormSectionId): id is InternalSectionId {
202
199
  return (INTERNAL_SECTION_IDS as readonly string[]).includes(id)
203
200
  }
@@ -223,7 +220,6 @@ export const EDIT_SECTIONS: ProjectFormSectionId[] = [
223
220
  "lifecycle",
224
221
  "ports",
225
222
  "prewarm",
226
- "docker",
227
223
  "secrets",
228
224
  ]
229
225
 
@@ -248,7 +244,6 @@ export function emptyProjectFormValue(): ProjectFormValue {
248
244
  removedSecretIds: [],
249
245
  forwardPorts: [],
250
246
  prewarmImages: [],
251
- dockerInDocker: false,
252
247
  }
253
248
  }
254
249
 
@@ -7,7 +7,9 @@
7
7
  // same spot, as the `TaskComposer` that answers the agent once it runs. Writing the first message
8
8
  // and writing the next ones is one gesture, so it gets one shape: the words take the room, and
9
9
  // where the work happens (project, base branch, model, the app's own fields — which machine…) is
10
- // a row of chips under them, each showing what will be used if nobody touches it.
10
+ // a row of chips under them, each showing what will be used if nobody touches it. Those whose
11
+ // default is almost always right (the base branch, `advanced` fields: an effort, the machine) wait
12
+ // behind an Options chip, so the row says only what is worth a glance.
11
13
  //
12
14
  // The title is not asked: the task takes the name the agent gives the conversation, and the
13
15
  // cockpit renames it in place afterwards (`TaskTitle`).
@@ -17,7 +19,7 @@
17
19
  // come back down. It fills its parent like `TaskCockpit`, so it can stand where a cockpit stands.
18
20
 
19
21
  import { useState, type ReactNode } from "react"
20
- import { ArrowLeftIcon, CornerDownLeftIcon, FolderIcon, GitBranchIcon, Loader2Icon, PackageIcon, SparklesIcon } from "lucide-react"
22
+ import { ArrowLeftIcon, CornerDownLeftIcon, FolderIcon, GitBranchIcon, Loader2Icon, PackageIcon, SlidersHorizontalIcon, SparklesIcon } from "lucide-react"
21
23
 
22
24
  import { cn } from "../../utils"
23
25
  import { Button } from "../button"
@@ -264,6 +266,7 @@ export function NewTaskComposer({
264
266
  setModel(remembered?.model ?? "")
265
267
  setPicked({})
266
268
  }
269
+ const [showAdvanced, setShowAdvanced] = useState(false)
267
270
  const draft = useAttachmentDraft()
268
271
  const Link = render?.link ?? defaultLink
269
272
 
@@ -281,6 +284,16 @@ export function NewTaskComposer({
281
284
  ? `Pick “${fields.find((f) => f.required && isEmpty(fieldValue(f)))!.label}” first.`
282
285
  : null
283
286
 
287
+ // An advanced field that blocks Delegate is not hidden: the reason names it, it must be there.
288
+ const advanced = fields.filter((f) => f.advanced)
289
+ const advancedOpen = showAdvanced || advanced.some((f) => f.required && isEmpty(fieldValue(f)))
290
+ // The base branch is one of them: it is the default branch nearly every time.
291
+ const hasAdvanced = advanced.length > 0 || !hideBaseBranch
292
+ const advancedLabels = [...(hideBaseBranch ? [] : ["Base branch"]), ...advanced.map((f) => f.label)]
293
+ const branchPicked = !hideBaseBranch && baseBranch.trim() !== (remembered?.baseBranch ?? "") ? 1 : 0
294
+ const advancedPicked = advanced.filter((f) => f.id in picked).length + branchPicked
295
+ const shown = (f: NewTaskCustomField) => !f.advanced || advancedOpen
296
+
284
297
  function submit() {
285
298
  if (disabled) return
286
299
  const values = Object.fromEntries(fields.map((f) => [f.id, fieldValue(f)] as const).filter(([, v]) => !isEmpty(v)))
@@ -294,6 +307,21 @@ export function NewTaskComposer({
294
307
  })
295
308
  }
296
309
 
310
+ const fieldChip = (f: NewTaskCustomField) => (
311
+ <span
312
+ key={f.id}
313
+ className="inline-flex"
314
+ data-slot="new-task-field"
315
+ data-field={f.id}
316
+ title={[f.label, typeof f.hint === "string" ? f.hint : null].filter(Boolean).join(" — ")}
317
+ >
318
+ {f.render(fieldValue(f), (v) => {
319
+ setPicked((prev) => ({ ...prev, [f.id]: v }))
320
+ onFieldChange?.(f.id, v)
321
+ })}
322
+ </span>
323
+ )
324
+
297
325
  const back = backHref ? (
298
326
  <Link href={backHref} className={cn(buttonVariants({ variant: "ghost", size: "icon" }), "h-8 w-8 shrink-0")}>
299
327
  <ArrowLeftIcon className="h-4 w-4" />
@@ -383,32 +411,7 @@ export function NewTaskComposer({
383
411
  )}
384
412
 
385
413
  {/* Fields the package's chips depend on — the harness, before the model it lists. */}
386
- {fields.filter((f) => f.placement === "lead").map((f) => (
387
- <span
388
- key={f.id}
389
- className="inline-flex"
390
- data-slot="new-task-field"
391
- data-field={f.id}
392
- title={[f.label, typeof f.hint === "string" ? f.hint : null].filter(Boolean).join(" — ")}
393
- >
394
- {f.render(fieldValue(f), (v) => {
395
- setPicked((prev) => ({ ...prev, [f.id]: v }))
396
- onFieldChange?.(f.id, v)
397
- })}
398
- </span>
399
- ))}
400
-
401
- {!hideBaseBranch && (
402
- <FreeTextChip
403
- label="Base branch"
404
- icon={<GitBranchIcon />}
405
- value={baseBranch}
406
- onChange={setBaseBranch}
407
- placeholder={defaultBranch ?? "default branch"}
408
- groups={[{ id: "branches", items: branches.map((b) => ({ value: b })) }]}
409
- searchPlaceholder="Start from…"
410
- />
411
- )}
414
+ {fields.filter((f) => f.placement === "lead" && shown(f)).map(fieldChip)}
412
415
 
413
416
  <FreeTextChip
414
417
  label="Model"
@@ -424,20 +427,33 @@ export function NewTaskComposer({
424
427
  mono
425
428
  />
426
429
 
427
- {fields.filter((f) => f.placement !== "lead").map((f) => (
428
- <span
429
- key={f.id}
430
- className="inline-flex"
431
- data-slot="new-task-field"
432
- data-field={f.id}
433
- title={[f.label, typeof f.hint === "string" ? f.hint : null].filter(Boolean).join(" — ")}
430
+ {!hideBaseBranch && advancedOpen && (
431
+ <FreeTextChip
432
+ label="Base branch"
433
+ icon={<GitBranchIcon />}
434
+ value={baseBranch}
435
+ onChange={setBaseBranch}
436
+ placeholder={defaultBranch ?? "default branch"}
437
+ groups={[{ id: "branches", items: branches.map((b) => ({ value: b })) }]}
438
+ searchPlaceholder="Start from…"
439
+ />
440
+ )}
441
+
442
+ {fields.filter((f) => f.placement !== "lead" && shown(f)).map(fieldChip)}
443
+
444
+ {hasAdvanced && (
445
+ <button
446
+ type="button"
447
+ aria-expanded={advancedOpen}
448
+ aria-label={advancedOpen ? "Hide options" : "More options"}
449
+ title={advancedOpen ? "Hide options" : `${advancedLabels.join(", ")} — the defaults apply unless you pick`}
450
+ onClick={() => setShowAdvanced(!advancedOpen)}
451
+ className={cn(newTaskChipClassName, "inline-flex items-center border outline-none focus-visible:ring-2 focus-visible:ring-ring/40", advancedOpen && "bg-muted text-foreground")}
434
452
  >
435
- {f.render(fieldValue(f), (v) => {
436
- setPicked((prev) => ({ ...prev, [f.id]: v }))
437
- onFieldChange?.(f.id, v)
438
- })}
439
- </span>
440
- ))}
453
+ <SlidersHorizontalIcon />
454
+ {!advancedOpen && <span>Options{advancedPicked > 0 ? ` · ${advancedPicked}` : ""}</span>}
455
+ </button>
456
+ )}
441
457
 
442
458
  <div className="ml-auto flex items-center gap-2 pl-2">
443
459
  <span className="hidden truncate text-[10px] text-muted-foreground @min-[36rem]:inline">
@@ -76,6 +76,12 @@ export interface NewTaskCustomField {
76
76
  * default) after them. The dialog ignores it: its fields come after the package's.
77
77
  */
78
78
  placement?: "lead" | "trail"
79
+ /**
80
+ * The composer keeps it out of sight behind its Options chip until someone opens it — a setting
81
+ * whose default is almost always right (an effort, the machine). Shown anyway while it is required
82
+ * and has no value. The dialog ignores it.
83
+ */
84
+ advanced?: boolean
79
85
  render: (value: unknown, onChange: (value: unknown) => void) => ReactNode
80
86
  }
81
87
 
@@ -646,9 +646,11 @@ describe("NewTaskComposer — delegating where the conversation will be", () =>
646
646
  it("Enter delegates, Shift+Enter does not, and blank options are left out", () => {
647
647
  const onSubmit = vi.fn()
648
648
  render(<NewTaskComposer defaultBranch="main" defaultModel="claude-opus-5" onSubmit={onSubmit} />)
649
- // The chips say what will be used when nobody picks.
650
- expect(screen.getByText("main")).toBeTruthy()
649
+ // The chips say what will be used when nobody picks — the branch behind Options.
651
650
  expect(screen.getByText("claude-opus-5")).toBeTruthy()
651
+ expect(screen.queryByText("main")).toBeNull()
652
+ fireEvent.click(screen.getByRole("button", { name: "More options" }))
653
+ expect(screen.getByText("main")).toBeTruthy()
652
654
  fireEvent.change(prompt(), { target: { value: " Fix the login on Safari " } })
653
655
  fireEvent.keyDown(prompt(), { key: "Enter", shiftKey: true })
654
656
  expect(onSubmit).not.toHaveBeenCalled()
@@ -671,6 +673,23 @@ describe("NewTaskComposer — delegating where the conversation will be", () =>
671
673
  expect(onSubmit.mock.calls[0]![0].fields).toEqual({ machine: "worker", harness: "claude" })
672
674
  })
673
675
 
676
+ it("keeps advanced fields behind Options — still sent, and shown while one blocks Delegate", () => {
677
+ const onSubmit = vi.fn()
678
+ const { rerender } = render(<NewTaskComposer fields={[machine({ advanced: true, required: true })]} onSubmit={onSubmit} />)
679
+ expect(screen.queryByLabelText("Runs on")).toBeNull()
680
+ fireEvent.change(prompt(), { target: { value: "Fix it" } })
681
+ fireEvent.keyDown(prompt(), { key: "Enter" })
682
+ // Hidden is not dropped: its default goes with the task.
683
+ expect(onSubmit.mock.calls[0]![0].fields).toEqual({ machine: "worker" })
684
+ fireEvent.click(screen.getByRole("button", { name: "More options" }))
685
+ expect(screen.getByLabelText("Runs on")).toBeTruthy()
686
+ fireEvent.click(screen.getByRole("button", { name: "Hide options" }))
687
+ expect(screen.queryByLabelText("Runs on")).toBeNull()
688
+ // Required with no value: the reason names it, so it shows.
689
+ rerender(<NewTaskComposer fields={[machine({ advanced: true, required: true, defaultValue: "" })]} onSubmit={onSubmit} />)
690
+ expect(screen.getByLabelText("Runs on")).toBeTruthy()
691
+ })
692
+
674
693
  it("org-wide, Delegate waits for a project and says so", () => {
675
694
  const onSubmit = vi.fn()
676
695
  render(<NewTaskComposer projects={[{ id: "p1", name: "spunto" }]} onSubmit={onSubmit} />)
@@ -721,6 +740,7 @@ describe("NewTaskComposer — delegating where the conversation will be", () =>
721
740
  const onSubmit = vi.fn()
722
741
  const props = { defaultBranch: "main", fields: [machine()], onSubmit }
723
742
  const { rerender } = render(<NewTaskComposer {...props} remembered={{ key: "p1", baseBranch: "dev", model: "claude-sonnet-5-5" }} />)
743
+ fireEvent.click(screen.getByRole("button", { name: "More options" }))
724
744
  expect(screen.getByText("dev")).toBeTruthy()
725
745
  expect(screen.getByText("claude-sonnet-5-5")).toBeTruthy()
726
746
  fireEvent.change(screen.getByLabelText("Runs on"), { target: { value: "sandbox" } })