@spunto/design-system 0.61.0 → 0.63.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.61.0",
3
+ "version": "0.63.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",
@@ -0,0 +1,16 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { untilLabel } from "./app-tiles"
3
+
4
+ describe("untilLabel", () => {
5
+ const now = Date.parse("2026-10-31T00:00:00Z")
6
+ it("says how long until a window resets", () => {
7
+ expect(untilLabel("2026-10-31T00:20:00Z", now)).toBe("in 20m")
8
+ expect(untilLabel("2026-10-31T02:10:00Z", now)).toBe("in 2h 10m")
9
+ expect(untilLabel("2026-10-31T03:00:00Z", now)).toBe("in 3h")
10
+ expect(untilLabel("2026-11-03T12:00:00Z", now)).toBe("in 3d 12h")
11
+ })
12
+ it("says now once it has passed, and nothing for a date it cannot read", () => {
13
+ expect(untilLabel("2026-10-30T23:00:00Z", now)).toBe("now")
14
+ expect(untilLabel("soon", now)).toBeNull()
15
+ })
16
+ })
@@ -0,0 +1,231 @@
1
+ "use client"
2
+
3
+ // What an app installed in the organization shows in a task's details (capability `embed`,
4
+ // RFC 0053) — GitHub: the pull requests the conversation shared; Claude Code: the session's quota,
5
+ // MCP servers, skills. Drawn here, with our components, from data the app returned: an app never
6
+ // sends markup, nor a color — it names a tone, and the tone is painted with the status tokens every
7
+ // other block uses.
8
+
9
+ import { useState, type ReactNode } from "react"
10
+ import { CheckIcon, CopyIcon, ExternalLinkIcon } from "lucide-react"
11
+
12
+ import { cn } from "../../utils"
13
+ import type { TaskAppTile, TaskAppTileFact, TaskAppTileItem, TaskAppTileList, TaskAppTileMeter, TaskAppTileTone } from "./types"
14
+
15
+ const TONE_TEXT: Record<TaskAppTileTone, string> = {
16
+ neutral: "text-muted-foreground",
17
+ info: "text-info",
18
+ success: "text-success",
19
+ warning: "text-warning",
20
+ danger: "text-destructive",
21
+ muted: "text-muted-foreground/70",
22
+ }
23
+
24
+ const TONE_CHIP: Record<TaskAppTileTone, string> = {
25
+ neutral: "bg-muted text-muted-foreground border-border",
26
+ info: "bg-info/12 text-info border-info/30",
27
+ success: "bg-success/12 text-success border-success/30",
28
+ warning: "bg-warning/15 text-warning-foreground border-warning/40 dark:text-warning",
29
+ danger: "bg-destructive/10 text-destructive border-destructive/30",
30
+ muted: "bg-muted/60 text-muted-foreground border-border/60",
31
+ }
32
+
33
+ /** A meter's fill: the same ramp as the context meter of Session, so « filling up » reads the same. */
34
+ const TONE_BAR: Record<TaskAppTileTone, string> = {
35
+ neutral: "color-mix(in oklch, var(--ship) 80%, var(--build))",
36
+ info: "var(--info)",
37
+ success: "var(--success)",
38
+ warning: "var(--color-amber-500, #f59e0b)",
39
+ danger: "var(--destructive)",
40
+ muted: "var(--muted-foreground)",
41
+ }
42
+
43
+ /** « in 2h 10m », « in 3d » — a reset ahead, read against the reader's clock. */
44
+ export function untilLabel(iso: string, now = Date.now()): string | null {
45
+ const ms = Date.parse(iso) - now
46
+ if (!Number.isFinite(ms)) return null
47
+ if (ms <= 0) return "now"
48
+ const minutes = Math.ceil(ms / 60_000)
49
+ if (minutes < 60) return `in ${minutes}m`
50
+ const hours = Math.floor(minutes / 60)
51
+ if (hours < 24) return `in ${hours}h${minutes % 60 ? ` ${minutes % 60}m` : ""}`
52
+ const days = Math.floor(hours / 24)
53
+ return `in ${days}d${hours % 24 ? ` ${hours % 24}h` : ""}`
54
+ }
55
+
56
+ function Meter({ meter }: { meter: TaskAppTileMeter }) {
57
+ const tone = meter.tone ?? "neutral"
58
+ const pct = Math.round(meter.value * 100)
59
+ const until = meter.resetsAt ? untilLabel(meter.resetsAt) : null
60
+ return (
61
+ <div>
62
+ <div className="flex items-baseline justify-between gap-3">
63
+ <span className="text-[11px] text-muted-foreground">{meter.label}</span>
64
+ <span className={cn("font-mono text-[11px] tabular-nums", tone === "danger" && "font-semibold text-destructive", tone === "warning" && "font-semibold text-amber-600 dark:text-amber-400")}>
65
+ {pct}%
66
+ </span>
67
+ </div>
68
+ <div className="mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-muted">
69
+ <div className="h-full rounded-full transition-[width] duration-500" style={{ width: `${pct}%`, background: TONE_BAR[tone] }} />
70
+ </div>
71
+ {(meter.detail || until) && (
72
+ <p className="mt-1 text-[10px] text-muted-foreground">
73
+ {[meter.detail, until && `resets ${until}`].filter(Boolean).join(" · ")}
74
+ </p>
75
+ )}
76
+ </div>
77
+ )
78
+ }
79
+
80
+ function CopyValue({ value }: { value: string }) {
81
+ const [copied, setCopied] = useState(false)
82
+ return (
83
+ <button
84
+ type="button"
85
+ title={copied ? "Copied" : "Copy"}
86
+ aria-label="Copy"
87
+ onClick={() => {
88
+ navigator.clipboard?.writeText(value).then(() => {
89
+ setCopied(true)
90
+ setTimeout(() => setCopied(false), 1500)
91
+ })
92
+ }}
93
+ className="shrink-0 text-muted-foreground transition-colors hover:text-foreground"
94
+ >
95
+ {copied ? <CheckIcon className="h-3 w-3 text-success" /> : <CopyIcon className="h-3 w-3" />}
96
+ </button>
97
+ )
98
+ }
99
+
100
+ function Fact({ fact }: { fact: TaskAppTileFact }) {
101
+ return (
102
+ <div className="flex items-baseline justify-between gap-3">
103
+ <span className="shrink-0 text-[11px] text-muted-foreground">{fact.label}</span>
104
+ <span className={cn("flex min-w-0 items-center gap-1 font-mono text-[11px] tabular-nums", fact.tone && fact.tone !== "neutral" && TONE_TEXT[fact.tone])}>
105
+ <span className="truncate" title={fact.value}>
106
+ {fact.value}
107
+ </span>
108
+ {fact.copy && <CopyValue value={fact.value} />}
109
+ </span>
110
+ </div>
111
+ )
112
+ }
113
+
114
+ /** Rows shown before « Show all » — the column is glanced at, not read. */
115
+ const FOLDED_VALUES = 12
116
+
117
+ function List({ list }: { list: TaskAppTileList }) {
118
+ const [all, setAll] = useState(false)
119
+ const shown = all ? list.values : list.values.slice(0, FOLDED_VALUES)
120
+ return (
121
+ <div>
122
+ <p className="text-[11px] text-muted-foreground">
123
+ {list.label} <span className="font-mono tabular-nums">· {list.values.length}</span>
124
+ </p>
125
+ <div className="mt-1.5 flex flex-wrap gap-1">
126
+ {shown.map((value) => (
127
+ <span key={value} className="rounded-sm border border-border/60 bg-muted/40 px-1.5 py-px font-mono text-[10px] text-muted-foreground">
128
+ {value}
129
+ </span>
130
+ ))}
131
+ {list.values.length > FOLDED_VALUES && (
132
+ <button type="button" onClick={() => setAll((v) => !v)} className="px-1 text-[10px] text-muted-foreground hover:text-foreground">
133
+ {all ? "Show fewer" : `+${list.values.length - FOLDED_VALUES}`}
134
+ </button>
135
+ )}
136
+ </div>
137
+ </div>
138
+ )
139
+ }
140
+
141
+ function ItemBody({ item }: { item: TaskAppTileItem }) {
142
+ return (
143
+ <>
144
+ <div className="flex min-w-0 items-center gap-1.5">
145
+ {item.status && (
146
+ <span className={cn("inline-flex h-5 shrink-0 items-center rounded-sm border px-1.5 text-[10px] font-medium", TONE_CHIP[item.status.tone])}>
147
+ {item.status.label}
148
+ </span>
149
+ )}
150
+ {item.label && <span className="shrink-0 font-mono text-[11px] text-muted-foreground">{item.label}</span>}
151
+ {item.subtitle && <span className="min-w-0 truncate font-mono text-[10px] text-muted-foreground">{item.subtitle}</span>}
152
+ {item.url && (
153
+ <ExternalLinkIcon className="ml-auto h-3 w-3 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />
154
+ )}
155
+ </div>
156
+ <p className="mt-1.5 line-clamp-2 text-xs leading-snug">{item.title}</p>
157
+ {item.badges && item.badges.length > 0 && (
158
+ <div className="mt-1.5 flex flex-wrap items-center gap-x-2.5 gap-y-1">
159
+ {item.badges.map((badge) => (
160
+ <span key={badge.label} className={cn("inline-flex items-center gap-1 text-[10px]", TONE_TEXT[badge.tone])}>
161
+ <span className="h-1.5 w-1.5 rounded-full bg-current" />
162
+ {badge.label}
163
+ </span>
164
+ ))}
165
+ </div>
166
+ )}
167
+ </>
168
+ )
169
+ }
170
+
171
+ /**
172
+ * The rows of one app's block. A row with a `url` is a card that opens it — the same card as the
173
+ * branch's own pull request; a row without one (an MCP server) is a compact line: name, then state.
174
+ */
175
+ export function TaskAppTileItems({ items, className }: { items: TaskAppTileItem[]; className?: string }) {
176
+ if (items.length === 0) return null
177
+ return (
178
+ <ul className={cn("space-y-1.5", className)}>
179
+ {items.map((item) =>
180
+ item.url ? (
181
+ <li key={item.url}>
182
+ <a
183
+ href={item.url}
184
+ target="_blank"
185
+ rel="noreferrer"
186
+ title={item.url}
187
+ className="group block rounded-md border border-border/60 bg-background/60 px-2.5 py-2 transition-colors hover:border-border hover:bg-muted/40"
188
+ >
189
+ <ItemBody item={item} />
190
+ </a>
191
+ </li>
192
+ ) : (
193
+ <li key={`title:${item.title}`} className="flex min-w-0 items-center justify-between gap-2">
194
+ <span className="min-w-0 truncate font-mono text-[11px]">
195
+ {item.title}
196
+ {item.subtitle && <span className="ml-1.5 text-[10px] text-muted-foreground">{item.subtitle}</span>}
197
+ </span>
198
+ {item.status && (
199
+ <span className={cn("inline-flex h-5 shrink-0 items-center rounded-sm border px-1.5 text-[10px] font-medium", TONE_CHIP[item.status.tone])}>
200
+ {item.status.label}
201
+ </span>
202
+ )}
203
+ </li>
204
+ ),
205
+ )}
206
+ </ul>
207
+ )
208
+ }
209
+
210
+ function Section({ children, divided }: { children: ReactNode; divided: boolean }) {
211
+ return <div className={cn("space-y-2", divided && "border-t border-border/60 pt-3")}>{children}</div>
212
+ }
213
+
214
+ /** One app's block, every section it sent, in the contract's order: meters, facts, items, lists. */
215
+ export function TaskAppTileContent({ tile, className }: { tile: TaskAppTile; className?: string }) {
216
+ const sections: ReactNode[] = []
217
+ if (tile.meters?.length) sections.push(tile.meters.map((m) => <Meter key={m.label} meter={m} />))
218
+ if (tile.facts?.length) sections.push(<div className="space-y-1.5">{tile.facts.map((f) => <Fact key={f.label} fact={f} />)}</div>)
219
+ if (tile.items?.length) sections.push(<TaskAppTileItems items={tile.items} />)
220
+ if (tile.lists?.length) sections.push(tile.lists.map((l) => <List key={l.label} list={l} />))
221
+ if (sections.length === 0) return null
222
+ return (
223
+ <div className={cn("space-y-3", className)}>
224
+ {sections.map((section, i) => (
225
+ <Section key={i} divided={i > 0}>
226
+ {section}
227
+ </Section>
228
+ ))}
229
+ </div>
230
+ )
231
+ }
@@ -87,6 +87,7 @@ export { TaskTerminalPanel } from "./terminal-panel"
87
87
  export type { TaskTerminalPanelProps } from "./terminal-panel"
88
88
  export { TaskPullRequest } from "./pull-request"
89
89
  export { TaskSharedFiles, TaskSharedLinks } from "./shared"
90
+ export { TaskAppTileContent, TaskAppTileItems } from "./app-tiles"
90
91
  export { TaskSessionUsage, formatCost, formatTokens } from "./session-usage"
91
92
  export { TaskCommandLog } from "./command-log"
92
93
  export { TaskBoot, TaskMachine, bootSteps, workerLabel } from "./machine"
@@ -97,6 +98,12 @@ export type { TaskBootLogs, TaskBootProps, TaskBootStep, TaskMachineProps, TaskM
97
98
  export type {
98
99
  AttachmentUrl,
99
100
  DraftFile,
101
+ TaskAppTile,
102
+ TaskAppTileFact,
103
+ TaskAppTileItem,
104
+ TaskAppTileList,
105
+ TaskAppTileMeter,
106
+ TaskAppTileTone,
100
107
  PendingMessage,
101
108
  TaskDraft,
102
109
  TaskCommand,
@@ -21,8 +21,9 @@ import { TaskCommandLog } from "./command-log"
21
21
  import { TaskPullRequest } from "./pull-request"
22
22
  import { TaskSessionUsage } from "./session-usage"
23
23
  import { TaskSharedFiles, TaskSharedLinks } from "./shared"
24
+ import { TaskAppTileContent } from "./app-tiles"
24
25
  import { isLiveTaskState, taskSpan } from "./task-state"
25
- import type { AttachmentUrl, TaskCommand, TaskItem, TaskPendingAction, TaskPullRequests, TaskSessionUsageData, TaskSharedData } from "./types"
26
+ import type { AttachmentUrl, TaskAppTile, TaskCommand, TaskItem, TaskPendingAction, TaskPullRequests, TaskSessionUsageData, TaskSharedData } from "./types"
26
27
 
27
28
  /** Set by `TaskCockpitMobile` around its sheet, so Drop can close it. @internal */
28
29
  export const TaskDetailsSheetContext = createContext<{ close: () => void } | null>(null)
@@ -40,6 +41,11 @@ export interface TaskDetailsProps {
40
41
  * own block, absent while empty. Files need `attachmentUrl` to be drawn.
41
42
  */
42
43
  shared?: TaskSharedData | null
44
+ /**
45
+ * What the organization's apps say about the shared links (`GET .../tiles`, RFC 0053) — GitHub:
46
+ * the pull requests, and where each stands. One block per app, absent when it has nothing.
47
+ */
48
+ appTiles?: TaskAppTile[] | null
43
49
  attachmentUrl?: AttachmentUrl
44
50
  /** The Machine block's content — typically a `TaskMachine`. */
45
51
  machine?: ReactNode
@@ -131,6 +137,7 @@ export function TaskDetails({
131
137
  usage,
132
138
  pullRequests,
133
139
  shared,
140
+ appTiles,
134
141
  attachmentUrl,
135
142
  machine,
136
143
  commands = [],
@@ -220,12 +227,28 @@ export function TaskDetails({
220
227
  </Block>
221
228
  )}
222
229
 
230
+ {/* What only the harness knows about its session (its quota, its MCP servers, its skills…),
231
+ from the task's agent app — Session's numbers stay ours, the same for every harness. */}
232
+ {appTiles?.filter((tile) => tile.session).map((tile) => (
233
+ <Block key={tile.appId} variant={variant} title={tile.title} hint={tile.appName === tile.title ? undefined : tile.appName}>
234
+ <TaskAppTileContent tile={tile} />
235
+ </Block>
236
+ ))}
237
+
223
238
  {pullRequests?.supported && (
224
239
  <Block variant={variant} title="Pull request">
225
240
  <TaskPullRequest data={pullRequests} />
226
241
  </Block>
227
242
  )}
228
243
 
244
+ {/* Right under the branch's own PR: what the org's apps make of the links the conversation
245
+ shared — the other pull requests it talked about, with where each one stands. */}
246
+ {appTiles?.filter((tile) => !tile.session).map((tile) => (
247
+ <Block key={tile.appId} variant={variant} title={tile.title} hint={tile.appName === tile.title ? undefined : tile.appName}>
248
+ <TaskAppTileContent tile={tile} />
249
+ </Block>
250
+ ))}
251
+
229
252
  {/* After the PR, before the machine: what the conversation handed over is what a reader
230
253
  comes back for — the preview URL, the doc pasted at the start, the screenshot. */}
231
254
  {shared && shared.links.length > 0 && (
@@ -262,6 +262,63 @@ export interface TaskSharedData {
262
262
  files: TaskSharedFile[]
263
263
  }
264
264
 
265
+ /** A meaning an app gives a status; the design system picks the color (RFC 0053). */
266
+ export type TaskAppTileTone = "neutral" | "info" | "success" | "warning" | "danger" | "muted"
267
+
268
+ /** One row of an app's block: a thing it recognized (a shared link, a server…), and where it stands. */
269
+ export interface TaskAppTileItem {
270
+ /** Absent: a row that is not a link. */
271
+ url?: string
272
+ title: string
273
+ /** « #262 » */
274
+ label?: string
275
+ /** « coderhammer/spunto » */
276
+ subtitle?: string
277
+ status?: { label: string; tone: TaskAppTileTone }
278
+ badges?: { label: string; tone: TaskAppTileTone }[]
279
+ }
280
+
281
+ /** « Claude Code → 2.1.310 ». `copy`: the value is something to paste (an id). */
282
+ export interface TaskAppTileFact {
283
+ label: string
284
+ value: string
285
+ tone?: TaskAppTileTone
286
+ copy?: boolean
287
+ }
288
+
289
+ /** How much of something is used — a quota window. `value` from 0 to 1. */
290
+ export interface TaskAppTileMeter {
291
+ label: string
292
+ value: number
293
+ tone?: TaskAppTileTone
294
+ detail?: string
295
+ /** When it starts again from zero (ISO) — drawn as « resets in 2h 10m ». */
296
+ resetsAt?: string
297
+ }
298
+
299
+ /** A named set of short names — the skills a session loaded. */
300
+ export interface TaskAppTileList {
301
+ label: string
302
+ values: string[]
303
+ }
304
+
305
+ /**
306
+ * What an app draws in a task's details (`GET .../tiles`, capability `embed`). Every section is
307
+ * optional and drawn in this order: meters, facts, items, lists.
308
+ */
309
+ export interface TaskAppTile {
310
+ appId: string
311
+ appName: string
312
+ /** The block's heading — « Pull requests », « Claude Code ». */
313
+ title: string
314
+ /** From the app running the task's session: drawn right under Session rather than with the others. */
315
+ session?: boolean
316
+ meters?: TaskAppTileMeter[]
317
+ facts?: TaskAppTileFact[]
318
+ items?: TaskAppTileItem[]
319
+ lists?: TaskAppTileList[]
320
+ }
321
+
265
322
  // ── Machine ──────────────────────────────────────────────────────────────────────────────────
266
323
 
267
324
  /** The node a task's worker lives on. */